Announcement

Collapse
No announcement yet.

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;
      }


      Comment


        #4
        Thank you both! Works a treat.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        57 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        78 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        41 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        101 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        61 views
        0 likes
        Last Post PaulMohn  
        Working...
        X