OmniTrader Professional Forum OmniTrader Professional Forum
forums calendars search
today this week
 
register logon control panel Forum Rules
You are currently browsing as a guest.
You should logon to access more features
A Self-Moderated Community - ALL MEMBERS, PLEASE READ!
Vote for Members who contribute the most to your trading, and help us moderate content within the Forums.


  Current location        Thread information  
OmniTrader Professional Forum
Trade Plans In Strategies
Nbar stop with condition
Last Activity 5/21/2018 12:01 PM
2 replies, 973 viewings

Jump to page : 1
Now viewing page 1 [25 messages per page]
 
back reply
Printer friendly version

^ Top
Sergey

Member

Posts: 6

Joined: 2/11/2016

User Profile
 
Subject : Nbar stop with condition
Posted : 2/11/2016 2:44 PM
Post #25007

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

Sage
2000100010025
Posts: 3147

Joined: 3/13/2006
Location: L'ville, GA

User Profile
 
Subject : RE: Nbar stop with condition
Posted : 2/11/2016 2:56 PM
Post #25008 - In reply to #25007

#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

Member

Posts: 6

Joined: 2/11/2016

User Profile
 
Subject : RE: Nbar stop with condition
Posted : 2/11/2016 8:24 PM
Post #25009 - In reply to #25008

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.
Jump to page : 1
Now viewing page 1 [25 messages per page]
back reply

Legend    Action      Notification  
Administrator
Forum Moderator
Registered User
Unregistered User
E-Mail this thread to a friend
Toggle e-mail notification


Nirvana Systems
For any problems or issues please contact our Webmaster at webmaster@nirvsys.com.