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

Convert Simple Indicator from NT7 to NT8

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

    Convert Simple Indicator from NT7 to NT8


    Hi there. I am trying to convert a simple Indicator from NT7 to NT8.

    This is the NT7 version and it works just fine:
    // plot below by replacing 'Close[0]' with your own formula.
    if (High[0]>High[6])
    {
    LongEntry.Set(High[1]-4);
    ShortEntry.Set(High[1]-4);
    }
    else if (Low[0]<Low[6])
    {
    ShortEntry.Set(Low[1]+4);
    LongEntry.Set(Low[1]+4);
    }
    }

    ---------------
    This version in NT8 does not work:

    {
    //Add your custom indicator logic here.
    if (Bars.GetHigh(0)>Bars.GetHigh(6))
    {
    LongEntry[0] = (Bars.GetHigh(1)-4);
    ShortEntry[0] = (Bars.GetHigh(1)-4);
    }
    else if (Bars.GetLow(0)<Bars.GetLow(6))
    {
    ShortEntry[0] = (Bars.GetLow(1)+4);
    LongEntry[0] = (Bars.GetLow(1)+4);
    }
    }

    -----------
    And this version in NT8 plots, but not correctly:

    {
    //Add your custom indicator logic here.
    if (Bars.GetHigh(256)>Bars.GetHigh(250))
    {
    LEntry[0] = (Bars.GetHigh(256)-1);
    SEntry[0] = (Bars.GetHigh(256)-1);
    }
    else if (Bars.GetLow(256)<Bars.GetLow(250))
    {
    SEntry[0] = (Bars.GetLow(256)+1);
    LEntry[0] = (Bars.GetLow(256)+1);
    }
    }​

    ------------

    Can someone please help me fix it?

    Thank you very much.



    #2

    Might swap GetHigh(x) and GetLows(x) to the more direct High[x] and Low[x].. so Bars.GetHigh(1) would be High[1]
    and if using multiple bars series would be Highs[1] and Lows[1].

    Also just for kicks try dropping down from 256 ...GetHigh(256) > GetHigh(250) down to High[254] > High[248]

    Hedge
    Last edited by hedgeplay; 12-28-2022, 10:40 AM.

    Comment


      #3
      Hello dooneyb11,

      hedgeplay is correct, Bars.GetHigh is not the same as High[0]. The Get methods like GetClose or GetHigh use a bar index or left to right numbering. The code you have for NT7 can still be used in NT8, that uses the High series and BarsAgo or right to left numbering.

      The only part of your NT7 code you need to convert for what you have shown is the plots. It would end up looking like this:
      Code:
      if (High[0]>High[6])
      {
          LongEntry[0] = High[1]-4;
          ShortEntry[0] = High[1]-4;
      }
      else if (Low[0]<Low[6])
      {
          ShortEntry[0] =Low[1]+4;
          LongEntry[0] =Low[1]+4;
      }


      JesseNinjaTrader Customer Service

      Comment


        #4
        Thank you both! Works a treat.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by algospoke, Yesterday, 06:40 PM
        2 responses
        24 views
        0 likes
        Last Post algospoke  
        Started by ghoul, Today, 06:02 PM
        3 responses
        15 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        46 views
        0 likes
        Last Post jeronymite  
        Started by Barry Milan, Yesterday, 10:35 PM
        7 responses
        23 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by AttiM, 02-14-2024, 05:20 PM
        10 responses
        181 views
        0 likes
        Last Post jeronymite  
        Working...
        X