I have been struggling recently to implement a strategy with first a stop and then a trailing stop, I am desperately looking for help.
I read all the posts on the forum I could find on trailing including the Tips often referenced on trailing questions but I am still stuck (Due to the number of posts on trailing it seems I am not the only one having difficulty using it.).
It could be worth mentioning that I am using the OnOrderUpdate and OnExecution to monitor my strategy. Very few examples are using these methods which doesn't help!
The logic could be summarized like this
1) When we have en entry set a stop loss and a profit target
2) When the profit target is hit cut the position in 2, i.e. take a profit.
3) Cancel the stop loss and replace it with a trailing stop. The trailing starts at break-even.
In more detailed it works like this
1) OnBarUpdate fires the entry when the condition is met.
entryOrder = EnterLongStop(0, true, quantity, Entry, "Entry");
2) OnExecution will be called after the entry has been executed. When called, set a stop and the first target
stopOrder = ExitShortStop(0, true, execution.Order.Filled, Stop, "Stop", "Entry");
targetOrderX1 = ExitShortLimit(0, true, execution.Order.Filled/2, X1, "Target1", "Entry");
3) OnExecution will then either be called if the stop is hit or if targetOrderX1 is executed.
if targetOrderX1 is executed I cancel the stop with
CancelOrder(stopOrder);
and create the trailing order
SetTrailStop("Entry", CalculationMode.Ticks, RiskPoint , false);
Is their a flaw in the design? Is it supposed to work like this, i.e. attaching a trailing after an execution?
It seem that if the trailing is executed, the strategy stops working. The trailing order is executed (closing the position) but “position.ToString()“ still say I am long or short.
Post
was similar to what I am trying to achieve but the link in post 2 doesn’t work anymore.
I remember having read a post from a NT Team member saying that an example will soon be posted but it never was.
Any help would be greatly appreciated. I was wondering if the NT Team could not release an official 2 phases scaling out example using OnOrderUpdate and OnExecution.
Thanks in advance.
Amiral

Comment