Basically, when the order is placed, to entry orders are placed, 2 stop orders are placed, and one limit order is placed to remove a portion of the the trade with a profit. When that happens, the stop for the second entry moves closer to the entry price and then is managed on virtually every bar following that.
I have looked through all of the great examples that have been given about this and am running into some serious confusion - so much so that I don't really know what questions to even ask - so we will do the best that I can.
First of all, here is the code that I now have. It is running into errors. When I comment it out, the script compiles without problem.
protected override void OnExecution(IExecution execution) { TargetPriceLong = Position.AvgPrice + (longSignalHigh - longSignalLow)*TargetPerc; TargetPriceShort = Position.AvgPrice - (shortSignalHigh - shortSignalLow)*TargetPerc; //Setting Long Profit Target if (execution.Order != null && execution.Order.OrderState == OrderState.Filled) LongLimit = ExitLongLimit(0, true,DefaultQuantity,TargetPriceLong,"LongTarget","LongEntryA"); //Setting Short Profit Target if (execution.Order != null && execution.Order.OrderState == OrderState.Filled) ShortLimit = ExitShortLimit(0, true, DefaultQuantity,TargetPriceShort,"ShortTarget","ShortEntryA");
In light of the fact that everything needs to be traceable, can somebody help me find out what the errors are?
It is important that the secondary stop loss does not moved until the initial profit target is hit - and then, it needs to move on the execution of the target and not at the end of the bar. This will be running on small time frames so it is better if it does not wait for the bar to close to insure risk is under control.
Thank you for your help in advance and I am sure that we will get this thing figured out together.
Comment