I would have thought that each call of "SetStopLoss" places it where it is desired...the manual suggests that a previous call is used as a beginning point...or something to that effect. Thanks again.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Problem re-setting StopLoss
Collapse
X
-
Thank you for your reply. Can you explain a bit about your statement "make sure that you reset your stop loss values when you are flat"...I saw this in the help manual as well...I simply do not understand what that means exactly.
I would have thought that each call of "SetStopLoss" places it where it is desired...the manual suggests that a previous call is used as a beginning point...or something to that effect. Thanks again.
-
Thanks again. I took this code from that strategy link you provided:
//in "Variables"
private int stoplossticks = 20;
//In "OnBarUpdate"
// Resets the stop loss to the original value when all positions are closed
if (Position.MarketPosition == MarketPosition.Flat)
{
SetStopLoss(CalculationMode.Ticks, stoplossticks);
}
I guess that explains what is needed to do, but not why. I'm still not following why this procedure is necessary--seems like extra code...
Comment
-
Thank you. I've done the following modification to my previous code at the end (replacing the Position.Quantity):
if(Position.MarketPosition == MarketPosition.Flat)
{
if(subsequentCounter == 1)
{
subsequentCounter = 0; inflator = 1;
SetStopLoss(CalculationMode.Ticks, ExitPlace);
}
} //reset counter if it needs to be after trade triggers
I saw no difference. So I replaced:
"if(Position.MarketPostion == MarketPosition.Flat)"
with "if(Position.Quantity == 0)"
I saw no difference. So I replaced:
"SetStopLoss(CalculationMode.Ticks, ExitPlace);"
with "SetStopLoss(CalculationMode.Price, ExitPlace);"
Still no luck, I never expected to have so many problems with something as (what I thought was) simple as moving a StopLoss...I do not believe the other areas of code have a problem...of course I could be wrong.
Am I supposed to set a new variable in the "Variables" section to be equal to "0" and then use that as the "resetter" (replacing "ExitPlace")?
Comment
-
It seems to me that the problems I'm experiencing are related to the resetting of the StopLoss. In debugging my code I've concluded that:
1. I've stripped the strategy down to only 1 possible trade condition
2. The calculations seem correct
3. The condition for entry seems to be working properly
4. The procedure to prevent "re-submission" of orders on each bar seems correct
5. The entry point seems correct
6. The INITIAL StopLoss seems correct
7. The FIRST reset of the StopLoss on the chart seems correct
8. Subsequent StopLoss "resets" are problematic...
As my last couple of posts suggest I'm having a difficult time determining what is wrong with that reset logic...anybody got any ideas? Any advice much appreciated.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
656 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
371 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
579 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment