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

AddDataSeries from larger chart

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

    AddDataSeries from larger chart

    Hello, I've plotted fixed text in the top left corner that says "5 Min" when the WMA is up the text is green and when its down the text is red.
    I'm wanting to get the moving average from a 15min chart and a 60 min chart and display on the 5 min chart in the same manner so I don't need to change charts to see
    I have added spaces so they will appear bellow each other
    + "\n"
    + "\n\n"
    I'm just not sure how to call on the data for my WMA's

    if (WMA1[0] > WMA1[1]) //How to Add Data Series from 15 Minute Chart here?

    if (WMA1[0] > WMA1[1]) //How to Add Data Series from 60 Minute Chart here?



    thank you in advance


    My logic


    else if (State == State.Configure)
    {
    // Add Data Series from 15 Minute Chart
    AddDataSeries(BarsPeriodType.Minute,15, "None", false);

    // Add Data Series from 60 Minute Chart
    AddDataSeries(BarsPeriodType.Minute,60, "None", false);
    }

    else if (State == State.DataLoaded)
    {
    WMA1 = WMA(Close, 21);
    }
    }

    protected override void OnBarUpdate()
    {
    //Add your custom indicator logic here.
    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 1)
    return;


    if (WMA1[0] > WMA1[1]) //Add Data Series from 60 Minute Chart here?
    {
    Draw.TextFixed(this, "MADirectionIndicator", TextLine1 + "\n\n", DrawTextPosition, FontColor1, fontStyle, BackgroundColor3, BackgroundColor3, BackgroundColorOpacity);
    }

    if (WMA1[0] > WMA1[1]) //Add Data Series from 15 Minute Chart
    {
    Draw.TextFixed(this, "MADirectionIndicator", TextLine1 + "\n", DrawTextPosition, FontColor1, fontStyle, BackgroundColor3, BackgroundColor3, BackgroundColorOpacity);
    }

    if (WMA1[0] > WMA1[1]) //This is the 5 Minute
    {
    Draw.TextFixed(this, "MADirectionIndicator", TextLine", DrawTextPosition, FontColor1, fontStyle, BackgroundColor3, BackgroundColor3, BackgroundColorOpacity);
    }
    Last edited by Christopher Leggit; 01-20-2022, 03:00 AM.

    #2
    Hello Christopher Leggit,

    Thanks for your post.

    First, please review this complete section of the help guide to best understand how to work with a multi series or multi time frame script. All of the answers are there: https://ninjatrader.com/support/help...nstruments.htm

    You will need to create 2 more private WMA. You can then assign the added data series to them, for example:

    WMA1 = WMA(Close, 21); // this will be for the chart bars as "close" refers to the primary series.
    WMA2 = WMA(Closes[1], 21); // this is the first added data series
    WMA3 = WMA(Closes[2], 21); // this is the 2nd added dataseries

    In your OnBarUpdate() code then you would refer to WMA2 or WMA3 as needed
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi Paul thank you for your help, I feel I have a better understanding than usual it was very easy to follow all examples step by step provided, I'm adding 15 minute data series only for now

      I am coming up with an error though : Failed to resolve Instrument for market data: RTYH22 is not enabled for real-time quotes and trading

      My code reads - When the Current WMA on the primary data series is "Greater" than the WMA on the primary data series two candles prior

      draw text green and when "Lower" Draw text red


      When the Current WMA2 data series is "Greater" than the WMA2 data series two candles prior

      draw text green and when "Lower" Draw text red

      I've attached my script "MaDirectionalIndicator.zip" I hope I exported it from Ninjatrader correctly

      Last edited by NinjaTrader_PaulH; 01-24-2022, 06:48 AM. Reason: Removed DLL file.

      Comment


        #4
        Hello Christopher Leggit,

        Thanks for your reply.

        I removed your attached indicator because it was in DLL form which is prohibited in the forums. The .cs file is obfuscated source code which cannot really be read in any meaningful way. You are welcome to post your source code file.

        The error message you reported sounds more like you do not have access to the RTY instrument in your data subscription. Are you able to chart RTY 03-22? When you enable chart trader on that chart, do you see live bid and ask values? Do you see any error messages in the "log" tab of the NinjaTrader control center?
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Hi Paul,

          Sorry about the DLL file,
          I am able to load the RTY 03-22 chart and when enabling chart trader everything is accessible incl. Live Bid and Live Ask values.
          I have continued going over my code editing. The RTY error is no longer coming up in the Control Centre Log I dont know why that was happening.
          I'm not getting any new Error messages in Control Centre Log but It still is not working ,here is a .cs file I looked on the forum how to find it.

          thank you

          MADirectionIndicator.cs

          Comment


            #6
            Hello Christopher Leggit,

            Thanks for your reply.

            The code is using the same tag name for all 4 Draw.TextFixed() statements. This means only the last one will actually be drawn. Tag names must be unique per draw object, otherwise, they will be replaced by the latest. I would suggest using a different name for both the 15 minute DrawTextFixed(). So both the 5 minute will be one name and both the 15 minute would be a different name. This will allow one 5 minute and one 15 minute to show.


            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Thank you very much Paul,
              Such a simple oversight, copy and paste code, change the Array and values but neglect to change the Tag Names

              Bottom left corner of the charts is the outcome

              perfect thank you

              Click image for larger version

Name:	Screenshot 2021-06-18 082923.jpg
Views:	170
Size:	947.1 KB
ID:	1186929Click image for larger version

Name:	Screenshot 2021-09-17 124343.jpg
Views:	158
Size:	768.1 KB
ID:	1186930

              The Nasdaq has certainly tanked

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by ghoul, Today, 06:02 PM
              2 responses
              13 views
              0 likes
              Last Post ghoul
              by ghoul
               
              Started by jeronymite, 04-12-2024, 04:26 PM
              3 responses
              44 views
              0 likes
              Last Post jeronymite  
              Started by Barry Milan, Yesterday, 10:35 PM
              7 responses
              20 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by AttiM, 02-14-2024, 05:20 PM
              10 responses
              180 views
              0 likes
              Last Post jeronymite  
              Started by DanielSanMartin, Yesterday, 02:37 PM
              2 responses
              13 views
              0 likes
              Last Post DanielSanMartin  
              Working...
              X