I'm using MTF with the main Data being 15 Mins and the Secondary being 1 Tick, Unrealized Account PnL is updated in 'BarsInProgress == 1' so at a 1 tick resolution. This is looking for an Unrealized PnL of $100+ then when that is seen to have the strategy 'bank' that $100 by exiting the order and then put a Market order back in.
Normal order entry and exit is conducted under the 15 Min time frame and works as it should with a fixed SL and a coded TP point (If Position Long && other criteria then exit) and the same for short, this all works as expected. (Except I've not hit an SL yet to make sure that part works).
Where my issue lies is with the orders at the +$100 PnL mark, I've scripted to check order direction, check PnL, and if conditions are met then to Exit DataSeries[0]'s Order and place a new order and new SL, this is where I am running into trouble.
Exiting the original order seems to go OK, but the new order doesn't get entered...
Sometimes the PnL keeps running, is this Position PnL or is it from when the Strategy is first activated?
Sometimes the PnL just sits at zero, regardless of what the actual PnL is, restarting the Strategy TWICE is needed to fix this.
And once the new order is placed, I want it to repeat, EG +$100 Exit, Place Order, + another $100 Exit, Place Order Etc and repeat until either the SL is hit, OR the original closing criteria is met.
This leads me to a couple more questions if I submit a Market Order for DataSeries[0] from DataSeries[1], will it wait up to 15 minutes until the next bar close or will it be submitted when called? Would it better to just submit the subsequent orders on DataSeries[1] and just set a flag so it knows where to ExitOrders from? Is this even an issue if the orders are from the same strategy?
This is what I have so far for the subsequent order handling... Any help or ideas would be very much appreciated...
Thanks in advance, Paul
edit: 'earlyProfit' is just a bool flag which in this case is always set true, 'contractQty' is a fixed number.
else if (BarsInProgress == 1) { if ((Position.MarketPosition == MarketPosition.Long) && (earlyProfit == true) && (PositionAccount.GetUnrealizedProfitLoss(Performan ceUnit.Currency) > 100.00)) { ExitLong(0, contractQty,"MR0NEW_LONG", "MR0NEW_LONG"); SetStopLoss("MR0NEW_LONG", CalculationMode.Currency, StopLoss, false); EnterLong(contractQty, "MR0NEW_LONG"); } if ((Position.MarketPosition == MarketPosition.Short) && (earlyProfit == true) && (PositionAccount.GetUnrealizedProfitLoss(Performan ceUnit.Currency) > 100.00)) { ExitShort(0, contractQty, "MR0NEW_SHORT", "MR0NEW_SHORT"); SetStopLoss("MR0NEW_SHORT", CalculationMode.Currency, StopLoss, false); EnterShort(contractQty, "MR0NEW_SHORT"); } Print(" MR0NEW: " + PositionAccount.GetUnrealizedProfitLoss(Performanc eUnit.Currency)); }
Comment