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

  • Stanfillirenfro
    replied
    Many thanks ChrisL!

    Leave a comment:


  • NinjaTrader_ChrisL
    replied
    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

    Leave a comment:


  • 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!

Latest Posts

Collapse

Topics Statistics Last Post
Started by GussJ, 03-04-2020, 03:11 PM
11 responses
3,227 views
0 likes
Last Post xiinteractive  
Started by andrewtrades, Today, 04:57 PM
1 response
13 views
0 likes
Last Post NinjaTrader_Manfred  
Started by chbruno, Today, 04:10 PM
0 responses
7 views
0 likes
Last Post chbruno
by chbruno
 
Started by josh18955, 03-25-2023, 11:16 AM
6 responses
440 views
0 likes
Last Post Delerium  
Started by FAQtrader, Today, 03:35 PM
0 responses
11 views
0 likes
Last Post FAQtrader  
Working...
X