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

plotting an EMA from added dataseries

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

    plotting an EMA from added dataseries

    Hi, I'm trying to plot the EMA of an added dataseries, but it's not coming out correctly. Am I doing this correctly?

    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
    Overlay = false;

    Add(PeriodType.Volume,anchorMultiplier);

    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.

    try
    {

    if (BarsInProgress == 1)
    {
    Plot0.Set(EMA(Close,maLength)[0]);
    //this should plot the MA of the larger chart???? doesn't work.

    }
    }
    catch(Exception err) {Print(err.ToString());}

    #2
    Hello jfw215,

    You will have to use BarsArray and reference the added series through the bracket [ ] specified.

    BarsArray[0] = The first series - the series the indicator or strategy is applied to.
    BarsArray[1] = The second series.


    Plot0.Set(EMA(BarsArray[1], maLength)[0]);
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      thanks......

      Comment


        #4
        Hi Ryan,

        I tried doing as you suggested. It's still not working. I've attached ths cs file for your review.

        Thanks

        Jimmy
        Attached Files

        Comment


          #5
          Jimmy, please try plotting the BIP 1 MA value when you're in BIP 0, this should then work as you would expect.
          BertrandNinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_Bertrand View Post
            Jimmy, please try plotting the BIP 1 MA value when you're in BIP 0, this should then work as you would expect.
            Thanks Ryan,

            I did as you instructed. The results still don't come up correctly. I've attached the updated cs file for your review.

            Jimmy
            Attached Files

            Comment


              #7
              Please try the attached on 1 min chart, it would then show you the 20 bar 5 Minute EMA on it.
              Attached Files
              BertrandNinjaTrader Customer Service

              Comment


                #8
                kickass! thanks!

                Comment


                  #9
                  Hi,
                  Another related question. How do I access the volume in added chart?

                  I tried using this line to store the volume of the the 2nd chart to a variable then accessing it but gives me 0.
                  if(BarsInProgress==1) myVol=Volume[0];
                  if(BarsInProgress==0) Print(myVol);

                  Comment


                    #10
                    never mind figured it out Volumes!!! thanks.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by algospoke, Yesterday, 06:40 PM
                    2 responses
                    23 views
                    0 likes
                    Last Post algospoke  
                    Started by ghoul, Today, 06:02 PM
                    3 responses
                    14 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Started by jeronymite, 04-12-2024, 04:26 PM
                    3 responses
                    45 views
                    0 likes
                    Last Post jeronymite  
                    Started by Barry Milan, Yesterday, 10:35 PM
                    7 responses
                    22 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