SetStopLoss("EnterLong", CalculationMode.Ticks, stopticks, true);//100
SetStopLoss("EnterShort", CalculationMode.Ticks, stopticksS, true);//85
SetProfitTarget("EnterLong", CalculationMode.Ticks, profittarget);//79
SetProfitTarget("EnterShort",CalculationMode.Ticks, profittargetS);//55
}
protected override void OnBarUpdate()
{
#region Stoploss Modification
// Resets the stop loss to the original value when all positions are closed
if (Position.MarketPosition == MarketPosition.Flat)
{
SetStopLoss("EnterLong", CalculationMode.Ticks, stopticks, true);
}
// If a long position is open, allow for stop loss modification
else if (Position.MarketPosition == MarketPosition.Long)
{
if (Close[0] >= Position.AvgPrice + (TickSize*10))
{
SetStopLoss("EnterLong", CalculationMode.Price, Close[0] - (TickSize*15), true);
}
}
if (Position.MarketPosition == MarketPosition.Short)
{
if (Close[0] <= Position.AvgPrice - (TickSize*12))
{
SetStopLoss("EnterShort", CalculationMode.Ticks, TickSize*15, true);
}
}
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
stoploss modification
Collapse
X
-
stoploss modification
I looked over the sample stoploss modification but its for long only, how would u set it up for combination w a short? Should there be a seperate reset if flat for both sides? I tried the below but only one of the stops triggers orders.
Code:Last edited by zachj; 02-10-2014, 03:09 PM.Tags: None
-
I think I got it working. Just to make sure though, should I have seperate code as I have below to reset the Long and then another to reset the Short position? The "fromEntrySignal" directs each accordingly?
Code:if (Position.MarketPosition == MarketPosition.Flat) { SetStopLoss("EnterLong", CalculationMode.Ticks, 100, true); } if (Position.MarketPosition == MarketPosition.Flat) { SetStopLoss("EnterShort", CalculationMode.Ticks, 85, true); }
Comment
-
Not quite how you're thinking it will work.
Since you are using different fromEntrySignals the StopLoss's that are being called will have their own separate logic for the entries.
If you combined them you would be telling the system that any Entry Signal with those names to use the associated parameters.Cal H.NinjaTrader Customer Service
Comment
-
I don't want them to use any Entry Signal, I am wanting the stop for the Entry signal for the long to use its associated parameters and vice versa for the short. The long has a stop of 100 ticks and the short 85 ticks. So I need to keep them seperate?Originally posted by NinjaTrader_Cal View PostNot quite how you're thinking it will work.
Since you are using different fromEntrySignals the StopLoss's that are being called will have their own separate logic for the entries.
If you combined them you would be telling the system that any Entry Signal with those names to use the associated parameters.
Comment
-
Zachj,
ORCode:if (Position.MarketPosition == MarketPosition.Flat) { SetStopLoss("EnterLong", CalculationMode.Ticks, 100, true); } if (Position.MarketPosition == MarketPosition.Flat) { SetStopLoss("EnterShort", CalculationMode.Ticks, 85, true); }
Both will produce the same results the bottom has just one less logic to calculate.Code:if(Position.MarketPosition == MarketPosition.Flat) { SetStopLoss("EnterLong", CalculationMode.Ticks, 100, true); SetStopLoss("EnterShort", CalculationMode.Ticks, 85, true); }Cal H.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
581 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
338 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
103 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
554 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
552 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment