NexusFi: Find Your Edge


Home Menu

 





Determining order of OHLC


Discussion in NinjaTrader

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




 
Search this Thread
  #1 (permalink)
 halliwm 
Calgary
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Piano
Posts: 2 since Mar 2013
Thanks Given: 1
Thanks Received: 0

Hi,

If I am trying to have an if statement determine what order the current sessions high and low occurred, would this be the correct way to build the if statement?

//if High occurred before Low
if (HighestBar(High, Bars.BarsSinceSession - 1)> LowestBar(Low, Bars.BarsSinceSession - 1))

and vice versa

//if low occurred before high
if (LowestBar(Low, Bars.BarsSinceSession - 1)> HighestBar (High, Bars.BarsSinceSession - 1))

Any help would be appreciated. Cheers.


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Hungary Called for Magyar at 97pct, Ending 16-Year Orban …
Prediction Markets & Event Contracts
Penalties in Budapest, Peace Deadline in Tehran: Arsenal …
Prediction Markets & Event Contracts
Irans Dual Probability: Guns Quiet at 99.95% While Forma …
Prediction Markets & Event Contracts
Bookmap Global Plus Lifetime + Lifetime Addons For Sale
Platforms and Indicators
More Than Capable: Hegseths War Warning Validates $114M …
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
Lady Vols Primer: Trading Volatility Journal
8 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #3 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader
Broker: Interactive Brokers
Trading: Futures & Stocks
Posts: 9,887 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,114


If you do it this way and set the indicator/ strategy to CalculateOnBarClose = false, the indicator/strategy would perform a complex calculation with every incoming tick. However, this is creating an unnecessary CPU load.

It would be more efficient to declare two variables of type double to store the current high and low, then declare two variables of type int to store the bar count of current high and current low. You just would need check for the first bar of a session and set highCount and lowCount to 1, respectively currentHigh and currentLow to the high and low of the first bar. Then update with every new bar, if necessary.


Reply With Quote
Thanked by:




Last Updated on June 26, 2014


© 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