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
SetStopLoss Method move in one direction only
Collapse
X
-
SetStopLoss Method move in one direction only
Hi, I use the setstoploss method for a trailing stop. as an example here is my stoploss after each candle 1 tick below the bottom of the last completed candle. how can i limit the direction to long only, so that with long only the long direction is followed? the stop at long should only be tightened in this direction and not in the opposite direction. in the picture you can see very well what I mean. the red dotted line is the current stoploss line and the yellow line is to become. i have been trying to find a solution for 2 days now and i just cannot come up with a good idea, there's certainly an easy way ;-)2 Photos -
Hello sidlercom80,
Thanks for your post.
You would need to create logic that compares the current stop position to the next position and if the next position is less than or equal to the current position then you do not change the stop. In pseudo code something like:
if(nextstop > currentstop) // next level must be greater than the current stop level
{
SetStopLoss(nextstop); // adjust to next level
currentstop = nextstop; // store the next level as the current stop level.
}
You would likely need to use a bool variable to know when the "initial" stop has been set to then enable the adjusting routine.
Paul H.NinjaTrader Customer Service
-
hello paulh thank you very much for the answer, i will test this
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Padan, Today, 02:02 AM
|
9 responses
21 views
0 likes
|
Last Post Today, 03:27 PM | ||
Started by spottysallrite, Today, 11:31 AM
|
7 responses
21 views
0 likes
|
Last Post Today, 03:26 PM | ||
Started by nandhumca, Today, 03:15 PM
|
1 response
2 views
0 likes
|
Last Post Today, 03:23 PM | ||
Started by PopovDS, 03-11-2024, 12:49 PM
|
3 responses
17 views
0 likes
|
Last Post
by PopovDS
Today, 03:16 PM
|
||
Started by Lele2k24, Yesterday, 11:24 AM
|
12 responses
37 views
0 likes
|
Last Post Today, 03:07 PM |
Comment