Current location | Thread information | |
![]() ![]() ![]() ![]() ![]() ![]() |
Last Activity 10/5/2024 12:51 AM 8 replies, 2833 viewings |
|
|
Printer friendly version |
^ Top | |||
Diamondjag![]() Legend ![]() ![]() ![]() ![]() Posts: 404 Joined: 3/12/2006 Location: Brighton, Colorado ![]() |
My local investing club put together their “ideal” system and I agreed to program it and run it in OmniTrader to see how it does. They have so many filters in it that it hardly ever trades. Clearly it will be a terrible system but I want to run it for them. I’ve programmed all except the stops. They have three stops and a profit target. I’m not really a programmer and a couple of stops I’m especially having trouble with. I would think all should be fairly easy for a real programmer: They want a stop ATR(5) X 1.65 below the entry. I’ve programmed: Stop 1: If Signal = LongSignal And Entryprice-(ATR(5)*1.67) < Entryprice then Signal = ExitSignal ElseIf Signal = ShortSignal And Entryprice+(ATR(5)*1.67) > Entryprice then Signal = ExitSignal End If Doesn’t seem to work. I have no stops in my Omni language files that I can use as an example that deal with stops from the entry price. Any help would be appreciated. Stop 2: 2% below the Lowest Low of the past 5 days. I’ve programmed: If Signal = LongSignal And C < (LLV(5)-(LLV(5)*.02))[1] then Signal = ExitSignal ElseIf Signal = ShortSignal And C > (HHV(5)+(HHV(5)*.02))[1] then Signal = ExitSignal End If Stop 3: And the final stop is a close that crosses a Parabolic SAR. I’ve programmed: If Signal = LongSignal And C[1] > SAR(0.02,0.2) and C < SAR(0.02,0.2) then Signal = ExitSignal ElseIf Signal = ShortSignal And C[1] < SAR(0.02,0.2) and C > SAR(0.02,0.2) then Signal = ExitSignal End If PProfit Target: Finally, they have a profit target that I haven’t even tackled…. Profit Target - 2 times (the entry price minus the initial stop loss price). Any help on these would be greatly appreciated. Thanks [Edited by Diamondjag on 6/7/2018 10:50 PM] | ||
^ Top | |||
Mel![]() Veteran ![]() ![]() ![]() Posts: 235 Joined: 3/18/2006 ![]() |
Use the Nirvana Fixed Profit Stop for Stop 1 Use the Nirvana Parabolic SAR stop for Stop 3 Stop 2: I have attached a simple pct Stop (haven't tested it, but it shows the form you can use to write simple stops.) Modify the pct stop to compute you profit target in the initial part to get Stop 4 ![]() | ||
^ Top | |||
Diamondjag![]() Legend ![]() ![]() ![]() ![]() Posts: 404 Joined: 3/12/2006 Location: Brighton, Colorado ![]() |
Mel, Appreciate the reply. Will be looking into your suggestions today. Thanks. | ||
^ Top | |||
Diamondjag![]() Legend ![]() ![]() ![]() ![]() Posts: 404 Joined: 3/12/2006 Location: Brighton, Colorado ![]() |
Mel, or anyone else...I think I've got everything working except the stop for an entry price plus or minus ATR(5)*1.67. In other words a stop 5 ATR's times 1.67 below entry on long trades and 5 ATR's times 1.67 above entry for short trades. I've programmed this but it doesn't seem to work...the stops are too far away. Any help would be appreciated. #Stop 'CSG FIB ATR Stop '1.67 time ATR(5) from Entry dim myLevel as single if myLevel = 0 then 'this must be first bar of the trade if myLevel=0 'set the fixed level if Signal = LongSignal then myLevel = EntryPrice-(ATR(5)+(1.67*(ATR(5)*EntryPrice))) elseif Signal = ShortSignal then myLevel = EntryPrice+(ATR(5)+(1.67*(ATR(5)*EntryPrice))) end if end if if Signal = LongSignal then if C end if elseif Signal = ShortSignal then if C>myLevel then Signal = ExitSignal end if end if ExitLevel = myLevel 'so it will plot on chart | ||
^ Top | |||
Jim Dean![]() Sage ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3433 Joined: 3/13/2006 Location: L'ville, GA ![]() |
Here ya go: myLevel = EntryPrice-1.67*ATR(5) elseif Signal = ShortSignal then myLevel = EntryPrice+1.67*ATR(5) Also correct/simplify the final if then to: If Signal = LongSignal and C < myLevel then Signal = ExitSignal elseif Signal = ShortSignal and C > myLevel then Signal = ExitSignal end if PS: although is legal not to in OL, when you post code on the forum the > < disappear unless you put spaces around them. [Edited by Jim Dean on 6/13/2018 6:46 AM] | ||
^ Top | |||
Diamondjag![]() Legend ![]() ![]() ![]() ![]() Posts: 404 Joined: 3/12/2006 Location: Brighton, Colorado ![]() |
Jim, I really appreciate the response. I put in the code and get one error. Tried all kinds of things but can't straighten it out. Simple, I'm sure but my coding skill is pretty far down the scale. myLevel = EntryPrice-1.67*ATR(5) elseif Signal = ShortSignal then myLevel = EntryPrice+1.67*ATR(5) If Signal = LongSignal and C < myLevel then Signal = ExitSignal elseif Signal = ShortSignal and C > myLevel then Signal = ExitSignal end if Line: 13; 'ElseIf' must be preceded by a matching 'If' or 'ElseIf'. | ||
^ Top | |||
Jim Dean![]() Sage ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3433 Joined: 3/13/2006 Location: L'ville, GA ![]() |
Hi sorry I was unclear. I was providing snippets not complete code. Here is the complete version: #Stop 'CSG FIB ATR Stop '1.67 time ATR(5) from Entry dim myLevel as single if myLevel = 0 then 'this must be first bar of the trade if myLevel=0 'set the fixed level myLevel = EntryPrice-1.67*ATR(5) elseif Signal = ShortSignal then myLevel = EntryPrice+1.67*ATR(5) end if end if If Signal = LongSignal and C elseif Signal = ShortSignal and C>myLevel then Signal = ExitSignal end if Exitlevel = myLevel 'so it will plot on chart PS - I normally use a plotprice command instead of the last line. [Edited by Jim Dean on 6/13/2018 1:34 PM] | ||
^ Top | |||
Diamondjag![]() Legend ![]() ![]() ![]() ![]() Posts: 404 Joined: 3/12/2006 Location: Brighton, Colorado ![]() |
Jim, Sorry. Shows my level of coding expertise although I have a lot of stops, systems, indicators I've coded throughout the years but obviously all of them relatively simple. I really appreciate your help. Need to get this local club system off my back so I can get back to working with all the new Nirvana goodies. Hard to keep up with them. Missed seeing you at the BASH. Thanks again. Dave | ||
^ Top | |||
Jim Dean![]() Sage ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3433 Joined: 3/13/2006 Location: L'ville, GA ![]() |
Glad I could help ... missed seeing you and other friends. Next year! |
|
|
Legend | Action | Notification | |||
Administrator
Forum Moderator |
Registered User
Unregistered User |
![]() |
Toggle e-mail notification |