if (CrossBelow(Open, SMA(50), 1) && gap >= 20){ profitTarget = 110; trailStop = gap/.25; SetProfitTarget("SE", CalculationMode.Ticks,profitTarget+tickChange); SetTrailStop("SE",CalculationMode.Ticks, trailStop, false); EnterShort(Quantity, "SE"); } else if(gap < 7){ SetStopLoss("", CalculationMode.Ticks, stopLoss, false);//Even though this never gets called when it's performing the trade above, it will mess up the trailing stop } }
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Using trail stop and stop loss
Collapse
X
-
Using trail stop and stop loss
I have written a strategy that determines the type of trade to do (if any) once per day. Most of the trades use SetStopLoss and work fine, however two of the trades within the strategy use SetTrailStop. I can't figure out how to make them execute properly with out the SetStopLoss some how overriding it.
Code:Tags: None
-
Hello Shazzmoe,
SetStopLoss() can't be used concurrently with SetTrailStop() unless your signal names are unique. The SetStopLoss() method is called the first time the condition is true (else if(gap < 7)), and will be used instead of the trail stop for the remainder of the strategy instance.
To resolve, try providing your SetStopLoss() with a unique fromEntrySignal value.
More information on this can be found at the links for these methods below.
Ryan M.NinjaTrader Customer Service
-
thank you very much I was under the assumption that only the trailstop needed a signal name, but it works now.
One more question this has brought up though, I want to make sure that calling
ExitShort();
will exit any short position I am in regardless of the signals name.
Comment
-
Yes, that will exit all short positions regardless of signal name.
ExitShort();Ryan M.NinjaTrader Customer Service
Comment
-
Thank you for all the previous help. I didn't want to start a new thread but I have a question about SetStopLoss
what will happen if i call the following in the ES
SetStopLoss("someTrade", CalculationMode.Ticks, 28.5, false);
28.5 ticks is not a valid tick amount for the ES. Will the trade throw an error in real time or will it round one way or the other?
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by fx.practic, 10-15-2013, 12:53 AM
|
5 responses
5,404 views
0 likes
|
Last Post
by Bidder
Today, 12:22 AM
|
||
Started by Shai Samuel, 07-02-2022, 02:46 PM
|
4 responses
95 views
0 likes
|
Last Post
by Bidder
Today, 12:11 AM
|
||
Started by DJ888, Yesterday, 10:57 PM
|
0 responses
8 views
0 likes
|
Last Post
by DJ888
Yesterday, 10:57 PM
|
||
Started by MacDad, 02-25-2024, 11:48 PM
|
7 responses
159 views
0 likes
|
Last Post Yesterday, 10:23 PM | ||
Started by Belfortbucks, Yesterday, 09:29 PM
|
0 responses
8 views
0 likes
|
Last Post
by Belfortbucks
Yesterday, 09:29 PM
|
Comment