I have small catch in this code, i am not getting it work. Basically i want to submit stop loss order to low of previous bar of entry condition bar. But i am getting error after multiple tries. Can you suggest what is going wrong. I am also using Exit On Close.
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
SetStopLoss Order not submitting
Collapse
X
-
SetStopLoss Order not submitting
Hello,
I have small catch in this code, i am not getting it work. Basically i want to submit stop loss order to low of previous bar of entry condition bar. But i am getting error after multiple tries. Can you suggest what is going wrong. I am also using Exit On Close.Tags: None
-
Hi Paul,
thanx for looking it here.
As you suggest i printed that value and it seems ok, i checked maually on all 8 trades.
But 2 of them as its clear that stop order didnt executed. Notie also the error on log is still generating. May be that error is due to setting signalBar_low = 0 when it gets Flat. But i am not sure that is causing any problem.
One more thing , i am setting a huge value of initial Stop Loss in Initialize() to ensure that Calculated Stop is used for trigger.I have used ST = 200,000 in that. I set this huge values because on smaller value strategy was not using Calculated Stop Price rather than hitting Stop order with smaller values.
Comment
-
Hello,
Thanks for your reply.
Does it make sense to add a condition, where you set your stop loss, to first test if the current bar low is less than or equal to the low 1 bar ago? Or perhaps check the difference between the current Low and the Low[1] and if less than some value set your stoploss at some other value?Paul H.NinjaTrader Customer Service
Comment
-
Well thats very annoying and confusing me more.
I cant understand why i need to compare CurrentBar Low to Low[1] ?
As i am using CalculationMode.Price then any price lower than entry price i can set for Stop Loss in case of Long and it should be submitted as soon as long triggers.
Well i set lower Value of ST = 300 ticks and now error is not appearing but also number of prints of signalBar_low in output is also reduce. Trades that hit stop with ST = 300 ticks are absent from that. Look at prior post figures, first print value of 7798.4 is absent now from here and corresponding trade had hit the stop with ST = 300 ticks.
Looks also next trade with signalBar_low = 8451.05 which never retraced and hence its signalBar_low value is appearing in output.
I have attached snap of current code also with slight modification like commenting the line
signalBar_low =0;
Comment
-
Hello devdas,
Thanks for your reply.
Sorry if this is confusing but I only know what snippets of your code you share and evidence of results so I am guessing at what the issues are. I suggested a comparison from the Low 1 bar ago to the current bar low to ensure that price had not retraced, is that not possible or do you have other code that checks for this?Paul H.NinjaTrader Customer Service
Comment
-
Hello Paul.
I got it working. Actually catch was "DoneForSession" variable and i guess to some extent fix Stop Value ST. Ultimately its comparing the User Calculated Stop to Fix Stop for submission, this is what i am taking this from it.
I need to set ST = 10000 ticks which is relatively large value compared to session range we get. But again too high value again threw error as before.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by andrewtrades, Today, 04:57 PM
|
1 response
10 views
0 likes
|
Last Post Today, 05:02 PM | ||
Started by chbruno, Today, 04:10 PM
|
0 responses
6 views
0 likes
|
Last Post
by chbruno
Today, 04:10 PM
|
||
Started by josh18955, 03-25-2023, 11:16 AM
|
6 responses
436 views
0 likes
|
Last Post
by Delerium
Today, 03:42 PM
|
||
Started by FAQtrader, Today, 03:35 PM
|
0 responses
9 views
0 likes
|
Last Post
by FAQtrader
Today, 03:35 PM
|
||
Started by rocketman7, Today, 09:41 AM
|
5 responses
20 views
0 likes
|
Last Post Today, 03:33 PM |
Comment