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

only one plot displaying

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

    only one plot displaying

    why is that only one line plot is displaying with this code:

    protected override void OnBarUpdate()
    {

    if(CurrentBar<(Period*2))
    {
    return;
    }

    double currHigh=0;
    double currLow=0;
    double currTotal=0;
    double currRange=0;
    double prevHigh=0;
    double prevLow=0;
    double prevTotal=0;
    double prevRange=0;

    for(int i=0;i<Period;i++)
    {
    currHigh=High[i];
    currLow=Low[i];
    prevHigh=High[i+3];
    prevLow=Low[i+3];
    currTotal+=(currHigh-currLow);
    prevTotal+=(prevHigh-prevLow);
    }

    currRange=(currTotal/Period);
    prevRange=(prevRange/Period);

    CurrAvgRng.Set(currRange);
    PrevAvgRng.Set(prevRange);

    }
    Last edited by d.allen101; 11-26-2009, 10:41 AM.

    #2
    Please post your Initialize() as well.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      protected override void Initialize()
      {
      Add(new Plot(Color.FromKnownColor(KnownColor.Turquoise), PlotStyle.Line, "CurrAvgRng"));
      Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "PrevAvgRng"));
      CalculateOnBarClose = true;
      Overlay = false;
      PriceTypeSupported = false;
      }

      Comment


        #4
        Are those setup with the indicator wizard, so pointing to two different Values series in the 'Properties' section of the code?

        Thanks
        BertrandNinjaTrader Customer Service

        Comment


          #5
          yes, both plots are in the Values collection. Values[0] and Values[1] of DataSeries data type and they are in the properties of the class

          Comment


            #6
            Please apply the indicator and open the databox to compare the plot value, perhaps they are the same so you couldn't tell visually?
            BertrandNinjaTrader Customer Service

            Comment


              #7
              CurrAvgRng.Set(currRange) has a value. PrevAvgRng(prevRange) value is 0

              Comment


                #8
                You have defined -

                currRange=(currTotal/Period);
                prevRange=(prevRange/Period);

                Shouldn't this be ? -

                currRange=(currTotal/Period);
                prevRange=(prevTotal/Period);
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Hey Bertrand, don't worry about...I'd rather figure it out myself, that's the best way for me to learn. But thanks anyway!

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by carnitron, Today, 08:42 PM
                  0 responses
                  6 views
                  0 likes
                  Last Post carnitron  
                  Started by strategist007, Today, 07:51 PM
                  0 responses
                  8 views
                  0 likes
                  Last Post strategist007  
                  Started by StockTrader88, 03-06-2021, 08:58 AM
                  44 responses
                  3,974 views
                  3 likes
                  Last Post jhudas88  
                  Started by rbeckmann05, Today, 06:48 PM
                  0 responses
                  9 views
                  0 likes
                  Last Post rbeckmann05  
                  Started by rhyminkevin, Today, 04:58 PM
                  4 responses
                  58 views
                  0 likes
                  Last Post dp8282
                  by dp8282
                   
                  Working...
                  X