protected override void Initialize()
{
CalculateOnBarClose = true;
}
protected override void OnBarUpdate()
{
if(CurrentBar <= BarsRequired)
return;
if(Low[0] > SMA(High, 10)[0] &&
Low[1] > SMA(High, 10)[1] &&
Momentum(28)[0] > SMA(Momentum(28), 28)[0] &&
Position.MarketPosition == MarketPosition.Flat)
{
EnterLongLimit(SMA(High, 10)[0], "LE");
//DrawDot("LD", true, 0, SMA(High, 10)[0], Color.Green);
SetStopLoss(DonchianChannel(20).Lower[0]);
DrawDot("TEST", true, 0, DonchianChannel(20).Lower[0], Color.Blue);
}
if(High[0] < SMA(Low, 8)[0] &&
High[1] < SMA(Low, 8)[1] &&
Momentum(28)[0] < SMA(Momentum(28), 28)[0] &&
Position.MarketPosition == MarketPosition.Flat)
{
EnterShortLimit(SMA(Low, 8)[0], "SE");
//DrawDot("LD", true, 0, SMA(Low, 8)[0], Color.Red);
SetStopLoss(DonchianChannel(20).Upper[0]);
DrawDot("TEST", true, 0, DonchianChannel(20).Upper[0], Color.Blue);
}
}
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Another Stop Loss Issue
Collapse
X
-
Another Stop Loss Issue
I want a stop loss at DonchianChannel upper or lower depending on if I'm long or short. I have drawn a dot on the chart at the appropriate stop placement however applying DoncianChannel indicator parameter to the SetStopLoss function yields a different stop placement than expected. Currently I'm getting a number far below what it should be. it should be 12920 but i'm getting 10348 according to the order tab in the Performance window. what am I doing wrong??
Code:Tags: None
-
Hello ShruggedAtlas,
Thanks for writing in and I am happy to assist you.
Please use the overload SetStopLoss(CalculationMode mode, double value) to set the stop and set the CalculationMode to Price.
Please let me know if I can assist you any further.Code:SetStopLoss(CalculationMode.Price, this.DonchianChannel(20)[0]);
JoydeepNinjaTrader Customer Service
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
650 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
370 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
109 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
574 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
577 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment