NexusFi: Find Your Edge


Home Menu

 





program a limit order in a strategy


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one bob998 with 6 posts (0 thanks)
    2. looks_two monpere with 5 posts (0 thanks)
    3. looks_3 NinjaTrader with 3 posts (6 thanks)
    4. looks_4 MWinfrey with 1 posts (0 thanks)
    1. trending_up 8,773 views
    2. thumb_up 7 thanks given
    3. group 6 followers
    1. forum 18 posts
    2. attach_file 0 attachments




 
Search this Thread

program a limit order in a strategy

  #11 (permalink)
 
NinjaTrader's Avatar
 NinjaTrader  NinjaTrader is an official Site Sponsor
Site Sponsor

Web: NinjaTrader
AMA: Ask Me Anything
Webinars: NinjaTrader Webinars
Elite offer: Click here
 
Posts: 1,713 since May 2010
Thanks Given: 203
Thanks Received: 2,686


monpere View Post
A 3 tick offset would be: EnterShortLimit(1, Close[0]-(3*TickSize), "SMA");


If want to get into the market, I would not offset the current close price by 3 ticks, I would offset the current bid if selling or the current ask if buying. I would also use the methods GetCurrentAsk() and GetCurrentBid() to retrieve those prices. This will give you the best chance of getting filled at market.

Follow me on Twitter Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
PowerLanguage & EasyLanguage. How to get the platfor …
EasyLanguage Programming
MC PL editor upgrade
MultiCharts
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Exit Strategy
NinjaTrader
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
30 thanks
Spoo-nalysis ES e-mini futures S&P 500
28 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
20 thanks
GFIs1 1 DAX trade per day journal
16 thanks
  #12 (permalink)
 bob998 
West Palm Beach, FL
 
Experience: Intermediate
Platform: Ninja
Trading: TF, NQ ES,CL,6E
Posts: 6 since Mar 2012
Thanks Given: 1
Thanks Received: 0

Thank you.

How would I add a time period to it. To only trade between certain hours?

Started this thread Reply With Quote
  #13 (permalink)
 
monpere's Avatar
 monpere 
Bala, PA, USA
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Mirus, IB
Trading: SPY, Oil, Euro
Posts: 1,854 since Jul 2010
Thanks Given: 300
Thanks Received: 3,371



NinjaTrader View Post
If want to get into the market, I would not offset the current close price by 3 ticks, I would offset the current bid if selling or the current ask if buying. I would also use the methods GetCurrentAsk() and GetCurrentBid() to retrieve those prices. This will give you the best chance of getting filled at market.

Interesting. I may need to reconsider how I code that in my own strategies. My approach is generally I want to enter at market, but not if the price has already moved x ticks away from the last traded price. Why would an offset on the bid or ask give a better chance to get filled at market? Because of potential large spread of certain instruments?

Reply With Quote
  #14 (permalink)
 
NinjaTrader's Avatar
 NinjaTrader  NinjaTrader is an official Site Sponsor
Site Sponsor

Web: NinjaTrader
AMA: Ask Me Anything
Webinars: NinjaTrader Webinars
Elite offer: Click here
 
Posts: 1,713 since May 2010
Thanks Given: 203
Thanks Received: 2,686


bob998 View Post
Thank you.

How would I add a time period to it. To only trade between certain hours?

Check out this reference sample on time filtering - Strategy: Using a time filter to limit trading hours - [AUTOLINK]NinjaTrader[/AUTOLINK] Support Forum

Follow me on Twitter Reply With Quote
  #15 (permalink)
 
MWinfrey's Avatar
 MWinfrey 
Lubbock TX
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Stage 5 Trading
Trading: CL
Posts: 1,878 since Jul 2009
Thanks Given: 1,450
Thanks Received: 3,335


bob998 View Post
Thank you.

How would I add a time period to it. To only trade between certain hours?

 
Code
if (ToTime(Time[0]) > 83000 && ToTime(Time[0]) < 133000)
...do something

Reply With Quote
  #16 (permalink)
 
NinjaTrader's Avatar
 NinjaTrader  NinjaTrader is an official Site Sponsor
Site Sponsor

Web: NinjaTrader
AMA: Ask Me Anything
Webinars: NinjaTrader Webinars
Elite offer: Click here
 
Posts: 1,713 since May 2010
Thanks Given: 203
Thanks Received: 2,686


monpere View Post
Interesting. I may need to reconsider how I code that in my own strategies. My approach is generally I want to enter at market, but not if the price has already moved x ticks away from the last price on my chart. Why would an offset on the bid or ask give a better chance to get filled at market? Because of potential large spread of certain instruments?

If you want to enter market with limit based on an offset from the last price on your chart then your approach is correct. If you want to enter at market, then there are several reasons for offsetting the bid/ask price:

- For example, it is very possible that Close - 3 tick offset to sell might be still greater than the bid price --> No fill
- GetCurrentAsk() and GetCurrentBid() return the current prices which is especially in fast moving markets will be more recent/ahead of the event driven OnMarketData(). This is due to the asynchronous aspect of the actual market data/brokerage adapter.

Follow me on Twitter Reply With Quote
Thanked by:
  #17 (permalink)
 
monpere's Avatar
 monpere 
Bala, PA, USA
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Mirus, IB
Trading: SPY, Oil, Euro
Posts: 1,854 since Jul 2010
Thanks Given: 300
Thanks Received: 3,371


NinjaTrader View Post
If you want to enter market with limit based on an offset from the last price on your chart then your approach is correct. If you want to enter at market, then there are several reasons for offsetting the bid/ask price:

- For example, it is very possible that Close - 3 tick offset to sell might be still greater than the bid price --> No fill
- GetCurrentAsk() and GetCurrentBid() return the current prices which is especially in fast moving markets will be more recent/ahead of the event driven OnMarketData(). This is due to the asynchronous aspect of the actual market data/brokerage adapter.

Yes, thanks. If trading an instrument with occasional large spread, then I don't want the order executed if the spread is larger then x ticks at the moment. If trading a fast instrument, then I don't want the order executed if there is a fast move greater then x ticks away from my intended price. In both cases I want a No Fill.

Reply With Quote
  #18 (permalink)
 bob998 
West Palm Beach, FL
 
Experience: Intermediate
Platform: Ninja
Trading: TF, NQ ES,CL,6E
Posts: 6 since Mar 2012
Thanks Given: 1
Thanks Received: 0

if I add -3 ticks on the short order and it isn't met, how can I tell to keep try till it is?

Started this thread Reply With Quote
  #19 (permalink)
 
monpere's Avatar
 monpere 
Bala, PA, USA
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Mirus, IB
Trading: SPY, Oil, Euro
Posts: 1,854 since Jul 2010
Thanks Given: 300
Thanks Received: 3,371


bob998 View Post
if I add -3 ticks on the short order and it isn't met, how can I tell to keep try till it is?

I said 3 ticks, just as an example. I think the actual number of ticks you would use would depend on the instrument you are trading because of any of the reasons mentioned above. Also depends on your trading methodology. It could be 1000 ticks if you just want to enter the market at any price for example. I generally trade instruments with very tight spreads so 3 ticks is plenty for me, others may require more to guarantee a fill. Also, for me there is a certain price after which I no longer want that trade. For instance, I don't want to enter 5 ticks away from the last trade price, if my profit target is 10 ticks away from that last traded price. Half my potential profit would be gone, so that trade is not worth for me at that price.

Reply With Quote




Last Updated on April 24, 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