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
Create a stop order upon a trigger price
Collapse
X
-
Hello cfree5119,
I am following up Brett and is happy to assist you.
You can use Position.AvgPrice to calculate the new stop like
if (Position.MarketPosition == MarketPosition.Long && Close[0] >= Position.AvgPrice + Position.AvgPrice * .01 )
{
SetStopLoss(CalculationMode.Price, Position.AvgPrice);
}
The above code is for long only.
Please let me know if this works for you or not.
Regards,
Joydeep.JoydeepNinjaTrader Customer Service
Comment
-
-
Hello,
Yes, you would use SetStopLoss() before you enter the trade to the value you would like using the method Joydeep demontrated below. Instead of using Position.AvgPrice and MarketPosition however since that does not exist yet since you are not in a position you would instead just use the Close[0] price and find out where the 5% level would be. Then set your original stop loss to that value.
SetProfitTarget can be used like the following.
Also here is the reference for SetStopLoss()
Let me know if any questions.
-Brett
Comment
-
I setup my absolute 5% stop loss under the Initialize() method.
SetStopLoss("Long Turtle Entry", CalculationMode.Percent,stopTrigger1, false);
I then setup my breakeven stop loss under OnBarUpdate() as:
if (Position.MarketPosition == MarketPosition.Long && Close[0] >= Position.AvgPrice + Position.AvgPrice * breakEvenStopTrigger)
{
SetStopLoss(CalculationMode.Price, Position.AvgPrice);
}
The strategy does not recognize the latter when both stop losses are setup. Not sure how to "dynamically" change the sl. Thank you.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by kulwinder73, Today, 10:31 AM
|
1 response
8 views
0 likes
|
Last Post Today, 11:01 AM | ||
Started by RookieTrader, Today, 09:37 AM
|
3 responses
15 views
0 likes
|
Last Post Today, 10:32 AM | ||
Started by terofs, Yesterday, 04:18 PM
|
1 response
24 views
0 likes
|
Last Post
by terofs
Today, 10:14 AM
|
||
Started by CommonWhale, Today, 09:55 AM
|
1 response
6 views
0 likes
|
Last Post Today, 10:11 AM | ||
Started by Gerik, Today, 09:40 AM
|
2 responses
8 views
0 likes
|
Last Post
by Gerik
Today, 10:04 AM
|
Comment