Thank you.
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
Trail Stops
Collapse
X
-
Trail Stops
I would like to see an enhanced Trail Stop in NT8 as a feature. Like put a Stop at say the Lowest Low of X bars and then begin to trail it by X ticks instead of using ticks or currency at present. Not sure if the ATM can do it either.
Thank you.Tags: None
-
Hello Trader17, thanks for your note.
It is already possible to do this in a custom strategy written in NinjaScript. If you are interested in searching the NinjaTrader Ecosystem for a software consultant please let me know and I can forward your request to our sales team. I will submit a feature request to add this ability through the user interface.
Kind regards.Chris L.NinjaTrader Customer Service
-
Hi Trader17, thanks for your reply.
You can use LowestBar and pass in the Low series to get the price needed for the initial stop.
e.g.
var x = LowestBar(Low, 20);
Print(x + " Close: " + Close[x]);
SetTrailStop can be called from within OnBarUpdate, so the trailing price can be modified dynamically.
Kind regards.Last edited by NinjaTrader_ChrisL; 07-02-2019, 02:40 PM.Chris L.NinjaTrader Customer Service
Comment
-
Hello Trader17, thanks for your reply.
I fixed the link above. In this case, you would just use the Currency CalculationMode. Otherwise just make a method that will convert that price difference to ticks. Get the price from the var x and pass in Low[x] that will be the lowest low of y bars where y is the period of LowestBar.
Best regards.Chris L.NinjaTrader Customer Service
Comment
-
Looks like it is not being picked up by NT. I do not see the Trail Stop applied on the chart. I did it this way:
var x = MIN(Low, 3)[1];
{
SetTrailStop("LongTrailStop", CalculationMode.Price, x, false);
EnterLong(Convert.ToInt32(DefaultQuantity), "");
}
Thank you.
Comment
-
Hi Trader17, thanks for your reply.
Try printing out the value of x here:
var x = MIN(Low, 3)[1];
Print(x);
That should tell you why you're not seeing a stop being applied. I can take a look at your script if that does not get you in the right direction.
Kind regards.Chris L.NinjaTrader Customer Service
Comment
-
Thanks. I have a "x" and "y" for longs and shorts and it seems to be printing more than once on a bar different values. And the stop is not triggered either. Basically I want it to start trailing from the highest high or lowest low of the last X bars and to not update that lowest low or highest high value once when in a position, just trail it from original spot.
Also can a trail be done in increments of say 5 ticks instead of a tick at a time?
Thanks a lot.
Comment
-
HelloTrader17, thanks for your reply.
If you are getting unexpected results with the code, I recommend using the Print statement to print data at run time and see what the actual values of your stop and target are, also turn on Trace Orders and look to the output window when an order should have been submitted but did not. Trace orders will print a message when orders are ignored for whatever reason.
If you wanted to control the frequency of the trail stop update, you should just use the regular SetStopLoss, and perform the trailing manually with logic from OnBarUpdate. Something like: if you get a price change, set a boolean flag, then do not update the price again once 5 ticks have passed. Once 5 ticks have passed, reset the flag and the stop can be moved again.
Best regards.
Chris L.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by ZenCortexCLICK, Today, 04:58 AM
|
0 responses
2 views
0 likes
|
Last Post Today, 04:58 AM | ||
Started by sidlercom80, 10-28-2023, 08:49 AM
|
172 responses
2,280 views
0 likes
|
Last Post
by sidlercom80
Today, 04:40 AM
|
||
Started by Irukandji, Yesterday, 02:53 AM
|
2 responses
17 views
0 likes
|
Last Post
by Irukandji
Today, 03:55 AM
|
||
Started by adeelshahzad, Today, 03:54 AM
|
0 responses
4 views
0 likes
|
Last Post
by adeelshahzad
Today, 03:54 AM
|
||
Started by Barry Milan, Yesterday, 10:35 PM
|
3 responses
13 views
0 likes
|
Last Post Yesterday, 11:58 PM |
Comment