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

trying to normalize two indicator plots in same window

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

    trying to normalize two indicator plots in same window

    i've got two indicators i like in the same window
    in other charting packages i've been able to set them to have separate auto heights so that both the plots are not on one axis.
    this has allowed me to have an indicator plot that plots in integer values, say, 1 to 400 overlay on top of another indicator plot that plots values less than one, say, .0003 to .0125.
    and since, somehow, the two plots are given Y axis independence from each other the two plots seem to autosize on top of each other.
    this is really helpful when you're running out of monitor acreage and you have two plots that are unrelated to each other that can be seen together without confusion.

    i have a bollinger band width indicator plotting over a bar timer when on tick charts
    this presents the scaling problem the clearest...
    timer is in seconds (integers)
    bolinger band width is sometimes as small as .0008 on currencies (dec.fraction)

    i couldn't find any way to give two plots, in the same indicator window, independent scaling - did i completely miss something that would allow this?

    so i was trying to change double numbers, like the result of (1.3176 - 1.3154), into an integer - but was not having any luck... (string functions?)(parses?)
    so that the bbandwidth and timer can more easily print on top of each other...

    thanks,
    w

    #2
    Hi stafe, this would depend on how the ScaleJustification of your indicators is set - http://www.ninjatrader.com/support/h...Bjustification

    The issue here is - you would need to separate plots via 2 indicators to adjust differently for your needs (for example for combining right and left scale in one panel). You could unfortunately not set this on a per plot basis for one indicator.

    All the best,
    BertrandNinjaTrader Customer Service

    Comment


      #3
      the other way, as i mentioned would be to normalize the two plots together...
      ie. changing the decimal fraction to an integer...
      how would i do that?
      thanks,
      w

      Comment


        #4
        Which code snippet did you use here to attempt achieving that? Did you store the different in an int variable and plotted that?
        BertrandNinjaTrader Customer Service

        Comment


          #5
          that's the thing...
          i couldn't figure out how to take fractional doubles and produce an integer from the sum of the subtraction and i've spent hours looking through C# programming tips - it seems nobody cares about a lowly fractional sum and besides i'm not so good at programming.

          here's the BBwidth calc, just the usual double - double = double
          in most cases i'll be trading currency 1.21652 - 1.21321 = 0.00331

          double smaValue = SMA(Period)[0];
          double stdDevValue = StdDev(Period)[0];
          Top.Set(smaValue + NumStdDev * stdDevValue);
          Mid.Set(smaValue);
          Bot.Set(smaValue - NumStdDev * stdDevValue);
          BBandWidth.Set ( Top[0] - Bot[0] );

          and so here's the bar timer calculation that produces an integer

          if (Bars.Period.Id == PeriodType.Tick)
          {
          if (CurrentBar<3) return;
          TimeSpan ts1 = Time[0] - new DateTime(1970,1,1,0,0,0);
          TimeSpan ts2 = Time[1] - new DateTime(1970,1,1,0,0,0); int timeGap = (int) ts1.TotalSeconds - (int) ts2.TotalSeconds;
          }

          if i plot two indicators on top of each other that are integers things should be much closer to what i'm looking for, then i can add a value limiter to the bar timer plot so the first bars of the session don't off-scale as they're usually quite lengthy in time...

          Comment


            #6
            Easiest for you would be using two indicator and using different scales, you could then adjust each scale as needed to create an optimal visual display. If that's not an option for you, I would look into multiplying the decimal result of the width with a constant to scale it 'up'.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              i did build in a "scaling factor" to multiply the decimal difference and "scale up" the BBwidth but it's klunky klunky klunky...

              why is there no "easy" way to convert the decimal difference to an integer?

              Comment


                #8
                Bertrand, thanks for the help so far...

                i was just wondering about work-arounds for this
                is there any function that can check the price format of the current chart data?
                that way it would be easy to do a section of if clauses to set the multiplier automatically...

                if price data is #.#####
                then multiplier = 100000
                if price data is ##.###
                then multiplier = 1000
                etc...

                Comment


                  #9
                  For further finetuning you could be checking into the DoubleMA post on our sharing section, it contains code in it's Initialize() (which you would move to OnStartUp() now in NT7) to make this determination.

                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    oh brother... how easy can it be...
                    right out of the manual (pg.731)

                    protected override void OnBarUpdate()
                    {
                    int rangeInTicks = (int) ((High[0] - Low[0]) /TickSize);
                    myIntSeries.Set(rangeInTicks);
                    }

                    guess i'm blind, don't know how i missed that one...
                    TickSize...
                    Last edited by stafe; 12-01-2012, 10:49 PM.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Gerik, Today, 09:40 AM
                    1 response
                    6 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Started by RookieTrader, Today, 09:37 AM
                    1 response
                    10 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by alifarahani, Today, 09:40 AM
                    0 responses
                    5 views
                    0 likes
                    Last Post alifarahani  
                    Started by KennyK, 05-29-2017, 02:02 AM
                    3 responses
                    1,284 views
                    0 likes
                    Last Post NinjaTrader_Clayton  
                    Started by AttiM, 02-14-2024, 05:20 PM
                    11 responses
                    186 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Working...
                    X