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 charlesugo_1, 05-26-2026, 05:03 PM
|
0 responses
66 views
0 likes
|
Last Post
by charlesugo_1
05-26-2026, 05:03 PM
|
||
|
Started by DannyP96, 05-18-2026, 02:38 PM
|
1 response
149 views
0 likes
|
Last Post
|
||
|
Started by CarlTrading, 05-11-2026, 05:56 AM
|
0 responses
162 views
0 likes
|
Last Post
by CarlTrading
05-11-2026, 05:56 AM
|
||
|
Started by CarlTrading, 05-10-2026, 08:12 PM
|
0 responses
99 views
0 likes
|
Last Post
by CarlTrading
05-10-2026, 08:12 PM
|
||
|
Started by Hwop38, 05-04-2026, 07:02 PM
|
0 responses
286 views
0 likes
|
Last Post
by Hwop38
05-04-2026, 07:02 PM
|

Comment