OmniTrader Professional Forum
-
Trade Plans In Strategies
Nbar stop with condition |
^ Top | ||
Sergey![]() Posts: 6 Joined: 2/11/2016 ![]() | Hello! I 'm trying to make a stop which work same as Nbars stop but closes the position only if market does not move in position direction, therefore leave the position open if price is higher then entry price. It must be something like this: If after specified number of bars C < EntryPrice then Signal=ExitSignal (for long position). Can anyone give me an idea how to tell omnitrader to check for this condition only after specified number of bars(default 2 bars)? Thank you | |
^ Top | ||
Jim Dean![]() Posts: 3433 Joined: 3/13/2006 Location: L'ville, GA ![]() | #Stop #param "Delay", 2, 1, 10 dim Bcnt as integer = 0 if Bcnt >= Delay then if Signal = LongSignal then if C < EntryPrice then Signal=ExitSignal else if C > EntryPrice then Signal=ExitSignal end if end if Bcnt += 1 ... not tested but it should work OK | |
^ Top | ||
Sergey![]() Posts: 6 Joined: 2/11/2016 ![]() | Thank you Jim. It works but not as I want. This stop continues to follow the position after 2nd bar so it can close position on 3rd, 4th or any other following bars. My idea is to wait 2 bars after position opening and if it non profitable at this time then close it. But if it profitable at 3rd bar then leave it to go no matter where the market will go after. Anyway your stop almost correct in my situation, I just change "if Bcnt >= Delay" to "if Bcnt = Delay" and now it work exactly the way I want. Thank you very much one more time for help. |