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

Need help with AutoScale

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

    Need help with AutoScale

    I've put together an indicator that draws a rectangle and lines, and uses various plots based on several timeframes. Left part of the first attached image shows all of this but the scaling is weird. Now, when I switch Autoscale from TRUE to FALSE it erases everything. See right part of first image.

    When I set Autoscale to TRUE and turn off what I called pricemarkers30-120 in my code it then has the correct scaling.

    What am I missing?
    Part of the code is as follows. If that's not enough, please tell me who to send the full code to; as an indicator or a cs file.

    protected override void Initialize()
    {
    PaintPriceMarkers = true;
    Overlay = true;
    AutoScale = true;
    (...)
    Add(new Plot(Color.Snow, PlotStyle.Hash, "Average5")); // 0
    (...)
    Add(PeriodType.Minute, 5); // 1
    (...)
    }
    protected override void OnBarUpdate()
    {
    if (CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired || CurrentBars[2] < BarsRequired || CurrentBars[3] < BarsRequired || CurrentBars[4] < BarsRequired || CurrentBars[5] < BarsRequired)
    return;

    if(BarsInProgress != 0) return;

    {
    if (pricemarkers_On)
    {
    Average5.Set(Instrument.MasterInstrument.Round2Tic kSize(EMA(BarsArray[1],13)[0])); //0
    Average15.Set(Instrument.MasterInstrument.Round2Ti ckSize(EMA(BarsArray[2],13)[0])); //1

    PlotColors[0][1] = Color.Transparent;
    PlotColors[1][1] = Color.Transparent;
    }
    (...)
    if (pricemarkersb_On)
    {
    Average30.Set(Instrument.MasterInstrument.Round2Ti ckSize(EMA(BarsArray[3],13)[0])); //2
    (...)
    PlotColors[2][1] = Color.Transparent;
    PlotColors[3][1] = Color.Transparent;
    PlotColors[4][1] = Color.Transparent;
    }
    }

    sandman
    Attached Files

    #2
    Hello sandman,

    Thank you for your note.

    I see you are referencing a 3rd and 4th data series however from the snippet you have shared you only have added a second series,

    Code:
    Add(PeriodType.Minute, 5); // 1
    The following would not be referring to a data series.

    Code:
    BarsArray[2]
    BarsArray[3]
    You should add additional data series or set BarsArray to existing series, ex BarsArray[1].

    Does fixing the above resolve the issue?

    I look forward to your reply.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Hello AlanP,

      Thanks. Sorry, I had thought the "(...)" would make it clear that it wasn't the full code I was posting. I took the liberty to email the full indicator/code to Support attention to you and would appreciate if you could have a look at it to perhaps see something I obviously did not.

      sandman

      Comment


        #4
        Hello AlanP,

        Thanks for your help. It resolved.

        sandman

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by rtwave, 04-12-2024, 09:30 AM
        4 responses
        30 views
        0 likes
        Last Post rtwave
        by rtwave
         
        Started by yertle, Yesterday, 08:38 AM
        7 responses
        29 views
        0 likes
        Last Post yertle
        by yertle
         
        Started by bmartz, 03-12-2024, 06:12 AM
        2 responses
        22 views
        0 likes
        Last Post bmartz
        by bmartz
         
        Started by funk10101, Today, 12:02 AM
        0 responses
        6 views
        0 likes
        Last Post funk10101  
        Started by gravdigaz6, Yesterday, 11:40 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X