I'm having trouble with my stops constantly cancelling, and I can't work out if its a bug in my code of me misunderstanding the behavior in Ninjatrader.
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Does SetStopLoss() Cancel on Next Bar ?
Collapse
X
-
Does SetStopLoss() Cancel on Next Bar ?
Just wanted to clarify something. If I am in a position via EnterLong() or EnterShort(). And I have called SetStopLoss(). Do I need to keep calling it on every bar?
I'm having trouble with my stops constantly cancelling, and I can't work out if its a bug in my code of me misunderstanding the behavior in Ninjatrader.Tags: None
-
Hello kevinenergy,
Thank you for the post.
This is likely related to the specific logic you have used, if you are simply using SetStopLoss with an entry, it should remain active. You can create small tests to confirm items like this, here is an example you could apply to a 10 second chart to see what the expected outcome is.
Code:protected override void OnBarUpdate() { if(State != State.Realtime) return; if(Position.MarketPosition == MarketPosition.Flat) { EnterLong(); } if(Position.MarketPosition == MarketPosition.Long && BarsSinceEntryExecution() == 1) { Print("called SetStopLoss"); SetStopLoss(CalculationMode.Ticks, 10); } }
You can also form other samples like this to be more like what you have created to see if the logic you used is part of the problem. If you are unsure why something is happening still after reducing the logic or making a sample like this, I would be happy to review that with you.
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by PaulMohn, Today, 12:36 PM
|
2 responses
16 views
0 likes
|
Last Post
by PaulMohn
Today, 01:48 PM
|
||
Started by Conceptzx, 10-11-2022, 06:38 AM
|
2 responses
53 views
0 likes
|
Last Post
by PhillT
Today, 01:47 PM
|
||
Started by Kaledus, Today, 01:29 PM
|
0 responses
4 views
0 likes
|
Last Post
by Kaledus
Today, 01:29 PM
|
||
Started by yertle, Yesterday, 08:38 AM
|
8 responses
37 views
0 likes
|
Last Post
by ryjoga
Today, 01:22 PM
|
||
Started by rdtdale, Today, 01:02 PM
|
1 response
6 views
0 likes
|
Last Post Today, 01:13 PM |
Comment