Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Associate Values from Price NOT Time

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

    Associate Values from Price NOT Time

    Hello Ninja-script community and experts,
    What is the best practice to associate an indicator value with the Price Range (on the y-axis) at which those indicator values were produced and NOT the time or Bar Number (x-axis) at which those values happened to happen???

    Click image for larger version

Name:	Associate with Price NOT Time.png
Views:	57
Size:	61.3 KB
ID:	1316298


    For example in this attached photo, the indicator needs to associate thoseGreen valueson the lower Panel to the Prices within the Green sections of the price chart.
    Likewise, the indicator also needs to associate those Red Valueson the lower Panel to the Prices within the Red sections of the price chart.

    After searching references, I failed to find the best practices on this topic... I have had the opportunity to work with Lists and Arrays but I was uncertain which way was the best direction to begin and so I felt it necessary to ask for guidance.

    I have made this same indicator in less advanced coding languages than C# so I do know that it is possible but I lack the expertise and familiarity to access the Price Range and assign Values to that y-axis.


    Attached Files

    #2
    Hello DynamicTest,

    There is not a way to change how data is associated with the X and Y scale. To plot anything you need to provide a time where that data would be present which is represented using the X scale, the price would be represented with the y scale.

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Hello DynamicTest,

      There is not a way to change how data is associated with the X and Y scale. To plot anything you need to provide a time where that data would be present which is represented using the X scale, the price would be represented with the y scale.
      My mistake, I completely went offtrack, and I did not explain what I am trying to do.
      Absolutely I understand we won't change the orientation of the time on the x-axis and price on the y-axis.


      However I need to leave a running total for all the prices which occur on the chart. For each price on the chart which visits a range I must add the indicator value which occurs at that range.

      For example the price of some asset regularly returns to the same price $ on a chart we must sum those indicator values. For instance we are currently at some price which has previously visited ranges where the indicator values returned lower values of 7, 1, 3, and 5 and NOT any other ranges on the chart we need a value of (7 + 1 + 3 + 5 = 16) for that price.

      Click image for larger version

Name:	Associate with Price NOT Time.png
Views:	44
Size:	96.1 KB
ID:	1316396
      Attached Files

      Comment


        #4
        So I need to store some running total for prices on a chart. While I am familiar with Array, Lists, and perhaps Matrices which I used to create this chart; I am not certain what is the Best Practice for NinjaScript and so I thought I should ask guidance before I head down the wrong path.

        Comment


          #5
          Hello DynamicTest,

          You can use any C# types that serve the purpose you are trying to achieve. NinjaScript is just C# language. In NinjaScript the only custom type of data holder would be a series, that is where you have 1 value per bar and the series extends for the whole bar series. If you just need 1 value per bar a series would likely work for that use.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          648 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          369 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          108 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          572 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          573 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X