I am using Limit OR market orders for entry and have used SetStopLoss and SetProfitTarget for exits.
If I understand correctly, SetProfitTarget is a limit order.
When the price is trading on my target for exit, based on few conditions I would like to convert limit order to market order.
Do I need to change the order using SetProfitTarget (CalculationMode.Price, GetCurrentBid() + TickSize) to cover long position and SetProfitTarget (CalculationMode.Price, GetCurrentAsk() - TickSize) to cover Short position?
I like to use OCO orders as my target and exits are predefined based on entry.
Thanks for the reply and great work on LOM.
I am using SetProfitTarget to exit and trying to modify the same order to get it filled(modifying it to below or above current bid or ask price). Not issuing any new Exit orders to exit.
if we modify the SetProfitTarget values, it should update/modify the existing order in the market if it is not yet filled. If the order get filled before it gets updated with new price, my OCO order will get cancelled because of filled leg and the reference to change of price will be lost.
Can you please provide me the case where we get over fill with OCO (Market entry, exits with SetProfitTarget and SetStopLoss?
Can you please point me to any document or any thread related to more information on over filling related SetProfitTarget?
Thanks for the help and suggestions. If I make the below changes to the existing OCO order resting in the exchange should not over fill theoretically. I haven’t coded for this yet, I am still in the design and learning phase. If anyone has used this method for filling please through some light on any issues faced.
I have also discussed this in ninja form. OCO to Market Order - NinjaTrader Support Forum
sequence of steps.
1. Use the SET methods to set profit target and stop loss
2. Enter the position in OnMarketData based on the flags set in on bar update
3. Once the position is filled exchange will have working initial profit target and stop orders
4. Based on few conditions verified in OnBarUpdate, need to set the flags to move profit target or close the position at market
5. Case1: once the conditions are met to increase PT without closing position
• In OnExecution check for any fill or partial fill @ initial PT
• If there is no fill call the setptofittraget with new price. This will change the PT to new price
• If the position gets filled before updating the price in exchange, order(new change) will get rejected
Case2: conditions are met to close the existing position @ market
• In OnExecution check for any fill or partial fill @ initial PT and collet order status and PT price into variables
• If the order is not completely filled use the set profit target method to move the PT way far from market (may be 20 ticks)
• In OnOrderUpdate check for change in the order status and price comparing the data collected in the above steps and issue the market order to close the position.
6. If the position is flat and there is no working orders in the exchange, rest the initial profit and stop loss to initial values
As per the information got from ninjaform, we don’t need to cancel the pending PT and stop loss orders in the exchange. Ninja should cancel these orders once the position goes to flat.
Can you please point me if I am missing anything in this design that needs to be taken care?
Are there any drawdowns in this approach? I really need second look in this design since this is the first time I am trying to do something in this area of scripting.