NexusFi: Find Your Edge


Home Menu

 





code to calculate distance to orders


Discussion in NinjaTrader

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




 
Search this Thread
  #1 (permalink)
ycomp
Europe-ish
 
Posts: 177 since Sep 2013
Thanks Given: 12
Thanks Received: 60

Does anyone have any code that calculates the distance (ticks or points) to the closest limit order? or something similar?


Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Bookmap Global Plus Lifetime + Lifetime Addons For Sale
Platforms and Indicators
Iran Lebanon Problem Kills Switzerland Talks, Brent at $ …
Prediction Markets & Event Contracts
Iran Airspace Contract Surges to 33.5% as Project Freedo …
Prediction Markets & Event Contracts
Wood Mackenzie Drops $200 Oil Forecast -- Airspace Expir …
Prediction Markets & Event Contracts
Second Night of US Strikes Crushes Iran June 15 to 3.6% …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
16 thanks
Darmok and Jalad at Tanagra
3 thanks
30 Sessions
1 thanks
Big Mike in Ecuador
1 thanks
  #2 (permalink)
 iantg 
charlotte nc
 
Experience: Advanced
Platform: My Own System
Posts: 409 since Jan 2015
Thanks Given: 91
Thanks Received: 1,154

In NinjaTrader syntax this is just GetCurrentBid() and GetCurrentAsk(). This will give you the current bid / ask price that is transacting.

If you have a limit order you submitted on the DOM that is k ticks out and over time as the market moves, if you want to know how far away your resting order is from the current best bid / best ask, all you would do is something like.

MyAskOrder -GetCurrentAsk()
or GetCurrentBid() - MyBidOrder

The difference will be the total number of ticks.



Ian






ycomp View Post
Does anyone have any code that calculates the distance (ticks or points) to the closest limit order? or something similar?


In the analytical world there is no such thing as art, there is only the science you know and the science you don't know. Characterizing the science you don't know as "art" is a fools game.
Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #3 (permalink)
TravelingSalesmen
Tucson arizona
 
Posts: 31 since Jun 2018
Thanks Given: 4
Thanks Received: 4



ycomp View Post
Does anyone have any code that calculates the distance (ticks or points) to the closest limit order? or something similar?

ya this is actually quite easy in NT8 even in the Strategy analyzer. just build it your self. you would want to set up a condition the first checks if there are any active orders or open positions which ever limit order your talking about. then set an action to take the absolute value of the difference of current price - that limit order. this will give you the distance in points. then you could divide by the tick value to get ticks.

hope that helps.


Reply With Quote




Last Updated on March 26, 2019


© 2026 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 - Downloads - Top
no new posts