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

indicator scale

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

    indicator scale

    Hello, i have an indicator i wrote which compare some values of instruments added using AddDataSeries in the configure section.

    What i wanted to ask was - i save the calculated values then plot and ema of the saved series of values and this is plotted in onbarupdate using the
    AddPlot(new Stroke(Brushes.Red, 2), PlotStyle.Line, "Correlation");

    So when i add the indicator to the chart i am adding to the same panel as price and on the left. I have set autoscale to both false and true in my tests and doesnt seem to make difference.

    The problem is initially the scaling looks fine .. showing the values on the scale relevant to the actual values in the visible chart range - then periodically the scale adjust to include
    the entire range for the loaded chart - this has the effect of flatlining the line plot since it is scaling to the range for all the plots since the first bar and not just the values in the range.

    Is there something i am missing or need to do here when using the plot set in onbarupdate?

    I have other code that uses Onrender in other indicators which draws based on the values in the visible screen range.

    What is it that is affecting the scale to go from the actual range for bars in visible chart to then the entire scale since the first bar?

    thanks

    #2
    Hello explorer101,

    Thank you for your post.

    When you say "then periodically the scale adjust to include the entire range for the loaded chart" do you mean when you manually adjust the scale so all bars are on screen? Would you be able to provide screenshots of the behavior you're referring to?


    To send a screenshot with Windows 7 or newer I would recommend using the Windows Snipping Tool.

    Click here for instructions

    Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screenshot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save as a jpeg file and post the file as an attachment.

    Click here for detailed instruction

    Thanks in advance; I look forward to assisting you further.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hello, ive enclosed some graphics of indicator which uses AddDataSeries for 1minute period and this is a 1min ES chart
      You can see the line flat in the ninja***1 image - then i scroll slightly right and the indicator appears as normal with the correct scale for the value in display in ninja**2
      I also scrolled to the first bars and you can see the initial values - whatever the data read in those first bars that is the value at that time in ninja**3
      I then scroll just past those bars and you see in ninja**4 the correct scale for the displayed values in the plot

      So the question is why is it showing those lower values when they are not in range in the visible portion of the chart ? So why is the scale showing as in **1 ?
      It seems to initially be ok then resets to the expanded value to include all values since the first bars loaded. As per my initial question.

      i stripped this to use standard ninja bars as was using on custom bar chart but you can see the issue is the same on standard minute chart

      thanks
      Attached Files

      Comment


        #4
        hello, not heard back yet but here also is the properties of the scales in the price panel on left and right.
        So is clearly set to screen date range ... yet the values on the left are outside of the bounds of this ?
        is happening again as i test this where it flatlines ... and there are no values in the range of the scale when it shows this
        Attached Files

        Comment


          #5
          Hello explorer101,

          Thank you for your reply.

          I wouldn't be able to tell exactly what's going on with the indicator unless I took a look at at least the code you're using to plot. However, I don't believe it's the scaling that's the issue, it looks like perhaps something isn't being recalculated as things move. The price and the indicator are working on separate vertical scales; those have no bearing on the other. However, the horizontal time scale is shared by both.

          Are you calculating any of the plot values outside of OnBarUpdate? Any code samples you can provide showing how you're calculating and plotting would be helpful.

          Thanks in advance; I look forward to assisting you further.
          Kate W.NinjaTrader Customer Service

          Comment


            #6
            In reviewing the code - the initial part i am looking at in terms of how many BarsRequiredToPlot - from the calculated data stored as a series - i then do an EMA of period 5.
            So for purposes of the display i guess the plot needs to start near 0 as this is how the plot works?

            Anyways that aside - what i think may be occurring is that the main instrument on the chart is ES for example - i am doing a calculation on some instruments in the indicator added with AddDataSeries - and in onbarupdate i was trying to use on price change . on each tick - in terms of the calculation part. I changed to onbarclose for now.
            I think the issue may be that there were no ticks or price changes in the instruments being calculated vs the ES which is obviously more active.

            In the code where i process
            if (BarsInProgress == 0)
            {
            Cumulative[0] = (Closes[2][0]/Closes[1][0])*weightLeg2;

            // next step calculate ema of the cumulative series

            Correlation[0] = EMA(Cumulative,weightLeg1)[0];

            }

            so ES is BarsInProgress 0 - what happens if there was no new bar for either Closes[2] or Closes[1] - this is based on 1 minute data series - so i would presume there would be a new bar.

            But it seems to in trying to process on each tick / on each price change - results in the line as i described above going flat and the scale screwing up to include the entire range as i explained before

            any insights?

            thanks

            Comment


              #7
              Hello explorer101,

              Thank you for your reply.

              Are you ensuring you have enough bars for each data series you've added?

              As before, I really wouldn't be able to tell you too much about what may be happening without looking at your script and testing. However, I would encourage you to add prints to your script so you can tell what the values of your variables are at times when the indicator isn't plotting as you'd expect.

              This forum post goes into great detail on how to use prints to help figure out where issues may stem from — this should get you going in the correct direction. You can even add these using the Strategy Builder.



              If you run into issues like you are seeing here, the above information will allow you to print out all values used in the condition in question that may be evaluating differently. With the printout information you can assess what is different between the values produced by the strategy and the values you'd expect..

              Please let us know if we may be of further assistance to you.
              Kate W.NinjaTrader Customer Service

              Comment


                #8
                Hello, yes i am aware of using prints and do so and did so and nothing was apparent. As i said this seems to be working fine when using on bar close
                So i think you are missing perhaps the subtleties of what i am sharing here and that question on why it occurs with on each tick / on price change setting.

                You ask 'are you ensuing you have enough bars for each data series added? i am using many days data - and how would i ensure this for a series in indicator AddDataSeries for 1 minute data?
                I dont believe that is the issue

                Perhaps i can separately send the script to you outside of this forum - how can i email this to you ? via platfform support ?

                thanks

                Comment


                  #9
                  Hello explorer101,

                  Thank you for your reply.

                  Yes, please send an email with your script attached to platformsupport [at] ninjatrader [dot] com. Please put 2273512 ATTN Kate W. in the subject line and a link to this forum post in the body.

                  Thanks in advance; I look forward to resolving this for you.
                  Kate W.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Aviram Y, Today, 05:29 AM
                  4 responses
                  11 views
                  0 likes
                  Last Post Aviram Y  
                  Started by algospoke, 04-17-2024, 06:40 PM
                  3 responses
                  27 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Started by bmartz, 03-12-2024, 06:12 AM
                  3 responses
                  30 views
                  0 likes
                  Last Post NinjaTrader_Zachary  
                  Started by gentlebenthebear, Today, 01:30 AM
                  1 response
                  8 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Started by cls71, Today, 04:45 AM
                  1 response
                  7 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Working...
                  X