NexusFi: Find Your Edge


Home Menu

 





code to calculate distance to orders


Discussion in NinjaTrader

Updated
    1. trending_up 1,084 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?
Prediction Markets Expiry Day: Trump Eyes War Exit, $230 …
Prediction Markets & Event Contracts
CFTC Opens First COT Report Review in 20 Years -- Asks W …
Traders Hideout
Irans Dual Probability: Guns Quiet at 99.95% While Forma …
Prediction Markets & Event Contracts
Double Deadlock: Rubio Calls Hormuz Tolls "Unfeasib …
Traders Hideout
US Navy Blockade of Hormuz Starts Today -- Oil Surges 8p …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #2 (permalink)
 iantg 
charlotte nc
 
Experience: Advanced
Platform: My Own System
Posts: 409 since Jan 2015
Thanks Given: 91
Thanks Received: 1,152

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