Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Shift of the maximum value over a specific number of bars

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Shift of the maximum value over a specific number of bars

    Hello!
    I am sorry to bring a Metatrader’s term to this forum. I am struggling since one week already with this topic, but I am failing to solve the problem. I hope you could help me understanding this term.
    I have this function from Metatrader4:
    HTML Code:
    for (int i = 0; i <= 10; i++)
    {
    double a = iHighest(NULL, 0, MODE_LOW, Period, i);
    }
    I instantly thought this was equal to higher low in Ninjatrader8, because of iHighest and MODE_LOW. I then set the Period to 1, considering a single bar. “a” should be the low of the corresponding bar. But if I have
    HTML Code:
    double b = iHighest(NULL, 0, MODE_HIGH, Period, i);
    , according to my understanding, “b” should be the higher high. Considering a single bar, this should be the high of the bar. So that I have used the function MAX(High, 1) - MAX(Low, 1). With the operation b - a, the result will always be positive, regardless if the bar is bullish or bearish. This is not what I want to have.

    In Google, I found the definition of iHighest as followed: Returns the shift of the maximum value over a specific number of bars depending on type.
    But I want there my specific number of bars to be 1.
    In Ninjatrader documentation, I also found this:
    int highestBarsAgo = HighestBar(High, Bars.BarsSinceNewTradingDay);
    double highestPrice = High[highestBarsAgo];
    With this, I would already be out of range in my loop.
    Could someone advise me what could the the equivalent of double a = iHighest(NULL, 0, MODE_LOW, Period, i) in Ninjatrader?
    Any help would be very appreciate.

    Thanks!

    #2
    Hi Stan, thanks for posting.

    To find the highest high price over a certain period, use the MAX method. This example gives the highest high price over 20 bars:

    double value = MAX(High, 20)[0];

    The reason you would use this kind of method is to evaluate what the highest high price is over x amount of bars. If you only need to evaluate one bar, the prices can be accessed in the OHLC price arrays. The lowest period you can pass to MAX is 1 e.g. MAX(High, 1)[0] will return either the last bar or the most recent bar high price. This can also be written Math.Max(High[1], High[0]);

    Kind regards,
    -ChrisL
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Many thanks ChrisL!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by fx.practic, 10-15-2013, 12:53 AM
      5 responses
      5,404 views
      0 likes
      Last Post Bidder
      by Bidder
       
      Started by Shai Samuel, 07-02-2022, 02:46 PM
      4 responses
      95 views
      0 likes
      Last Post Bidder
      by Bidder
       
      Started by DJ888, Yesterday, 10:57 PM
      0 responses
      8 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by MacDad, 02-25-2024, 11:48 PM
      7 responses
      159 views
      0 likes
      Last Post loganjarosz123  
      Started by Belfortbucks, Yesterday, 09:29 PM
      0 responses
      8 views
      0 likes
      Last Post Belfortbucks  
      Working...
      X