Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Shading area between EMA and external indicator plot

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

    Shading area between EMA and external indicator plot

    Hi NT8 bods ..


    Trying to plot some colour between an EMA and an external indicator .. it almost works .. but the shading does not quite line up ..

    ref: https://ninjatrader.com/support/foru...71-vwap-in-nt8

    In my script I have the following ..

    Code:
    public class TestMAs : Indicator
        {
            //indicators
            VWAP8 myVWAP8;
    <snip>
    
    protected override void OnBarUpdate()
            {
    
            Region myreg = Draw.Region(this, "my zone", CurrentBar, 0, myVWAP8, EMA(100), null, Brushes.Silver, 50, 0);
    <snip>
    Then I add the vwap8 indicator and the ema 100 to see if it lines up and its not quite right ..

    Am assuming my plot is a bar out ? dunno .. any ideas ?

    Cheers

    #2
    Hi 12tkram, thanks for your post.

    The VWAP plot and a 100 EMA are not comparable (I don't expect them to match). Could you post a screen shot?

    Comment


      #3
      thanks for the response, not sure I follow as "not comparable" .. shouldn't you get a plot for each bar on the chart for both an ema and the vwap ? can you explain deeper ? cheers

      Comment


        #4
        I think what you mean is that the 100ema does not line up with VWAP ? is that correct ? ok, thats not what I am saying, i want to shade the area between the 100 ema and VWAP, the code is above and works (to a point) .. the edge shaded area lines up nicely with the 100 ema, but the other side of the shaded areas does not line up the the VWAP line

        Comment


          #5
          even tho the vwap line comes from the same indicator, once called from the script and one manually added to the chart .. does that make sense ?

          Comment


            #6

            Comment


              #7
              the blue line is the vwap, the yellow line is the 100, the grey area is the result of
              Code:
               
               Region myreg = Draw.Region(this, "my zone", CurrentBar, 0, myVWAP8, EMA(100), null, Brushes.Silver, 50, 0);

              Comment


                #8
                Hi 12tkram, thanks for your reply.

                My test seems to work fine:



                Could you run the script I attached and see what results you get? Insert the script into Documents\NinjaTrader 8\bin\Custom\Indicators then compile.
                Attached Files

                Comment


                  #9
                  cool, thanks for the response .. will check it out

                  Comment


                    #10
                    yeh, that works, so, could this be related to the other data series I have loaded .. I have 1 day and 1 tick

                    Code:
                    else if (State == State.Configure)
                                {
                                    AddDataSeries(Instrument.FullName, BarsPeriodType.Day, 1);
                                    AddDataSeries(Instrument.FullName, BarsPeriodType.Tick, 1);
                                }

                    .. but call the Draw.Region from within

                    Code:
                    if(CurrentBars[0] < (128) ) return;    
                    if (BarsInProgress == 0 ){
                    Region myreg = Draw.Region(this, "fzone", CurrentBar, 0, myVWAP8, EMA(200), null, Brushes.Silver, 50, 0);

                    Comment


                      #11
                      Hi 12tkram, thanks for your reply.

                      I was able to get correct results with this setup, my primary series is still a 1 Renko chart:

                      Code:
                                  else if (State == State.Configure)
                                  {
                                      AddDataSeries(Instrument.FullName, BarsPeriodType.Day, 1);
                                      AddDataSeries(Instrument.FullName, BarsPeriodType.Tick, 1);
                                  }
                                  else if (State == State.DataLoaded)
                                  {
                                      //myVWAP8 = VWAP8(BarsArray[0]);
                                      myVWAP8 = VWAP8();
                                  }
                              }
                      
                              VWAP8 myVWAP8;
                              protected override void OnBarUpdate()
                              {
                      
                                  if(CurrentBars[0] < (128) ) 
                                      return;    
                      
                                  if (BarsInProgress == 0 )
                                  {
                                      Region myreg = Draw.Region(this, "my zone", CurrentBar, 0, myVWAP8, EMA(100), null, Brushes.Silver, 50, 0);
                                  }
                              }

                      Comment


                        #12
                        thanks for looking, i will try to isolate the issue further ..

                        Comment


                          #13
                          I have worked it out .. my custom indicator is calculate "On each tick", and the vwap8 indicator was "On bar close" .. change the vwap8 to "On each tick" and it lines up .. which is not what I want lol .. I want the custom indicator to line up with the vwap8 .. not the other way round .. my plot is in the if (BarsInProgress == 0 )

                          Comment


                            #14
                            and as the plot is based on the
                            Code:
                            else if (State == State.DataLoaded){ myVWAP8 = VWAP8(); }
                            then is that picking up and calculating on each tick ? do we have to restrict that to each bar close in order to plot the same as the separate vwap8 indicator ?

                            Comment


                              #15
                              Hi 12tkram, thanks for your reply.

                              If you need to set a plot value once per bar, set it within if(IsFirstTickOfBar) { //here } That should line up your plot with the VWAP.

                              If you still have trouble with this I would be happy to take a look at a reduced test script.

                              I look forward to hearing of your results.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              649 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              370 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              109 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              574 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              576 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X