NexusFi: Find Your Edge


Home Menu

 





Determining order of OHLC


Discussion in NinjaTrader

Updated
    1. trending_up 1,658 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?
Would a node-based workflow for automated trading be useful?
Traders Hideout
Warsh Drops Easing Bias, December Hike Now Above 50% -- …
Prediction Markets & Event Contracts
Iran Lebanon Problem Kills Switzerland Talks, Brent at $ …
Prediction Markets & Event Contracts
Fed Hike Odds at 57% After Warsh: England Surges 12.9%, …
Prediction Markets & Event Contracts
Daytrading to swingtrading
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Want your NinjaTrader indicator created, free?
5 thanks
Denied 20K payouts: Alpha Futures
1 thanks
FootPrintV2 Chart for NT8
1 thanks
BERN ALGOS algo trading journal
1 thanks
Afternoon-close session
1 thanks
  #3 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Legendary 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,117


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