Say I have a long position.
[FONT=Courier New][COLOR=black][COLOR=black][FONT=Courier New]entryOrder = EnterLong(0, 100, For the entry order (within OnBarUpdate):
[/COLOR][COLOR=maroon][FONT=Courier New]"Long Entry"[/FONT][/COLOR][COLOR=black][FONT=Courier New]);[/FONT][/COLOR]
[/COLOR][/FONT]
[FONT=Courier New][COLOR=black][COLOR=black][FONT=Courier New]stopOrder = ExitLongStop(0, For the stop loss order (within OnBarUpdate):
[/COLOR][COLOR=blue][FONT=Courier New]true[/FONT][/COLOR][COLOR=black][FONT=Courier New], [/FONT][/COLOR][COLOR=black][FONT=Courier New]100[/FONT][/COLOR][COLOR=black][FONT=Courier New], Positions[0].AvgPrice - (stopLoss*[/FONT][/COLOR][COLOR=purple][FONT=Courier New]0.01[/FONT][/COLOR][COLOR=black][FONT=Courier New]), [/FONT][/COLOR][COLOR=maroon][FONT=Courier New]"Long Entry - Stop"[/FONT][/COLOR][COLOR=black][FONT=Courier New], [/FONT][/COLOR][COLOR=maroon][FONT=Courier New]"Long Entry"[/FONT][/COLOR][COLOR=black][FONT=Courier New]);[/FONT][/COLOR]
[/COLOR][/FONT]
For the target order (within OnExecution):
[COLOR=black][FONT=Courier New]targetOrder = ExitLongStop(0, [COLOR=blue][FONT=Courier New]true[/COLOR][COLOR=black][FONT=Courier New], execution.Order.Filled, execution.Order.AvgFillPrice + (profitTarget*[/FONT][/COLOR][COLOR=purple][FONT=Courier New]0.01[/FONT][/COLOR][COLOR=black][FONT=Courier New]) , [/FONT][/COLOR][COLOR=maroon][FONT=Courier New]"Long Entry - Target"[/FONT][/COLOR][COLOR=black][FONT=Courier New], [/FONT][/COLOR][COLOR=maroon][FONT=Courier New]"Long Entry"[/FONT][/COLOR][COLOR=black][FONT=Courier New]); [/FONT][/COLOR]
[/FONT]
I am coding the orders as above, but TraceOrders reports that the target order is cancelled as the stop price (in the target order) is not valid.
Am I using ExitLongStop() correctly for the target order?
Any ideas what’s wrong or what I should do to achieve what I am after?
Many thanks.
Comment