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 proptradingshop, 03-21-2024, 09:50 AM
|
5 responses
25 views
0 likes
|
Last Post Today, 05:17 AM | ||
Started by MaupinFinche, Today, 05:08 AM
|
0 responses
2 views
0 likes
|
Last Post
by MaupinFinche
Today, 05:08 AM
|
||
Started by Enkidu, Yesterday, 06:40 AM
|
9 responses
35 views
0 likes
|
Last Post
by Enkidu
Yesterday, 01:11 PM
|
||
Started by Mestor, 03-10-2023, 01:50 AM
|
12 responses
307 views
0 likes
|
Last Post
by z.franck
Today, 04:29 AM
|
||
Started by AgriTrdr, 07-16-2023, 12:54 PM
|
32 responses
268 views
0 likes
|
Last Post
by f.saeidi
Yesterday, 06:49 AM
|
Comment