NexusFi: Find Your Edge


Home Menu

 





Convert Limit to Market Order


Discussion in NinjaTrader

Updated
    1. trending_up 2,441 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread

Convert Limit to Market Order

  #1 (permalink)
 GSREDDY 
sanfrancisco
 
Experience: Advanced
Platform: Ninjatrader,TS,IRT
Broker: IQfeed
Trading: ES
Posts: 45 since Feb 2012
Thanks Given: 26
Thanks Received: 21

Hi,
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,
GSREDDY.

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
REcommedations for programming help
Sierra Chart
What broker to use for trading palladium futures
Commodities
How to apply profiles
Traders Hideout
 
  #2 (permalink)
 
NJAMC's Avatar
 NJAMC 
Atkinson, NH USA
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader 8/TensorFlow
Broker: NinjaTrader Brokerage
Trading: Futures, CL, ES, ZB
Posts: 1,970 since Dec 2010
Thanks Given: 3,037
Thanks Received: 2,395


GSREDDY View Post
Hi,
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,
GSREDDY.

Great question, I could never figure out how to "unset" a PT with NT7. I would away move it way out of range so I didn't end up with an overfill if I threw a Market Order to exit.

Nil per os
-NJAMC [Generic Programmer]

LOM WIKI: NT-Local-Order-Manager-LOM-Guide
Artificial Bee Colony Optimization
Visit my NexusFi Trade Journal Reply With Quote
  #3 (permalink)
 GSREDDY 
sanfrancisco
 
Experience: Advanced
Platform: Ninjatrader,TS,IRT
Broker: IQfeed
Trading: ES
Posts: 45 since Feb 2012
Thanks Given: 26
Thanks Received: 21


Hi
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,
GSREDDY.

Started this thread Reply With Quote
  #4 (permalink)
 GSREDDY 
sanfrancisco
 
Experience: Advanced
Platform: Ninjatrader,TS,IRT
Broker: IQfeed
Trading: ES
Posts: 45 since Feb 2012
Thanks Given: 26
Thanks Received: 21

hi,
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 [AUTOLINK]Market Order[/AUTOLINK] - [AUTOLINK]NinjaTrader[/AUTOLINK] 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.
Thanks
gsreddy

Started this thread Reply With Quote




Last Updated on August 13, 2012


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts