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
Stop Loss Offset
Collapse
X
-
Try SetStopLoss(MIN(Low, 5)[0] - 2 * TickSize)
If TickSize is not what you want you can also try Instrument.MasterInstrument.PointValue.Josh P.NinjaTrader Customer Service
-
Right buy stop orders cannot be placed there. Please see this tip: http://www.ninjatrader-support.com/v...ead.php?t=3271Josh P.NinjaTrader Customer Service
Comment
-
Hey Craig and Josh, thanks for posting up how to do this, I've been sweating over this for two full days...Now I've tried your syntax and I can't quite work out why it doesn't do the calculation it should. I have
SetStopLoss(CalculationMode.Price, MIN(Low, 5)[0] - 6 * TickSize);
So theoretically it should take the lowest low for the last five candles and then subtract a further 6 pips to set the stop loss - what I want is one pip below the lowest low of the last five candles and then I'm adding the 5 pips broker's spread on - which gives me my 6 below. But when I run it and read off the charts, for example, a buy is marked and the low of the candle before it is 1.8364, but the stop loss exits the trade at 1.8365. That's 1 pip above the low of the last candle not 6 pips below it. I'm sure there's a good explanation, but I can't fathom it right now. Can you help?
Comment
-
Hi Red Fish,
Best way to check is to print values instead of trying to visualize it from the chart. Reason for printing is so you know for sure what the system thinks the value is.
Try printing out the value for your MIN(Low, 5)[0] - 6 * TickSize and then comparing it to the value that your stop loss is at.Josh P.NinjaTrader Customer Service
Comment
-
Do this.
Print(Time[0] + " " + MIN(Low, 5)[0] + " " + TickSize);
You will get two numbers. Use your calculator to find your stop loss value between those values. Then figure out the time that your stop loss is submitted and compare the value of your stop loss to the value that your prints come out as. They should match.Josh P.NinjaTrader Customer Service
Comment
-
Visualization is not necessarily wrong. It may just be that you are correlating values from the wrong bar to be what you think the stop loss should be.
What you want to do is find your entry trade. Look at the chart and determine what you wish the stop loss should be in theory. Then look at the values you did earlier and see if those values match up with what you want them to be. If they match you are golden. You may be off by a bar to the left or right due to miscounting when you say "5 bars back". Just come back to your code and adjust the 5 accordingly to match up the stop loss with what you want.Josh P.NinjaTrader Customer Service
Comment
-
Josh, now I've put in my other conditions and try and run this from the strategy analyser it gives me a blank screen when I select this strategy. If I set my stop loss to 25 ticks
SetStopLoss(CalculationMode.Ticks, 25);
it gives me the normal screen to fill in my parameters. But if I alter the same test strategy to
SetStopLoss(CalculationMode.Price, MIN(Low, 5)[0] - 6 * TickSize);
it gives me a blank screen. If I try and run it with the blank screen it tells me NT needs to close down. I have even uninstalled and reinstalled NT and did it again but it does the same thing. If I then amend it back to a simple 25 ticks stop loss it allows me to run it.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Brevo, Today, 01:45 AM
|
0 responses
6 views
0 likes
|
Last Post
by Brevo
Today, 01:45 AM
|
||
Started by aussugardefender, Today, 01:07 AM
|
0 responses
3 views
0 likes
|
Last Post Today, 01:07 AM | ||
Started by pvincent, 06-23-2022, 12:53 PM
|
14 responses
241 views
0 likes
|
Last Post
by Nyman
Today, 12:47 AM
|
||
Started by TraderG23, 12-08-2023, 07:56 AM
|
9 responses
384 views
1 like
|
Last Post
by Gavini
Today, 12:29 AM
|
||
Started by oviejo, Today, 12:28 AM
|
0 responses
6 views
0 likes
|
Last Post
by oviejo
Today, 12:28 AM
|
Comment