• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to change indicator value?

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

    How to change indicator value?

    I use an indicator script to calculate some resistance and support lines every five minutes and draw them on the chart using DrawLine() and delete the old R/S lines at the same time. However if I click mouse on the chart to scroll the chart to the right, in most cases some line object would get selected and moved instead of the chart being scrolled, and I have to reload the indicators by pressing "F5". So I decide to use something like Add(new Line(MyColor, MyRSValue, "RSTag") to show the calculated R/S lines as horizontal lines. My question is how to change the MyRSValue in realtime to the calculated value? In those indicator script like pivot or rsi, the value is either set every tick/bar or set to a fixed value in intialize() function. What is the correct way to set my R/S lines? Your help is greatly appreciated.

    - Clearpicks

    #2
    Try something like this in OnBarUpdate()

    Lines[0].Value = yourValue;
    RayNinjaTrader Customer Service

    Comment


      #3
      Ray,

      What if I want to use Add(Plot plot) instead of using Add(Line line)? The lines drawn by Add(Line line) extend to the right of the last bar, which make them interfere with the lines drawn by ChartTrader. Is there a simple way to move the line drawn by Add(Plot plot) to different R/S value in realtime trading similar to
      Lines[0].Value = yourValue;
      you just taught me?

      - Clearpicks

      Comment


        #4
        Unfortunately not. You would have to dive into overriding the Plot method which is beyond the level we can support. We have on our list of considerations some improvements to the Draw() methods that may help alleviate this usage case though.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Why couldn't you do something like this:

          Code:
          protected override void Initialize()
          {
              Add(new Plot(Color.Magenta, PlotStyle.Line, "Sup")); // Plots[0]
              Add(new Plot(Color.Orange,  PlotStyle.Line, "Res")); // Plots[1]
          
              Overlay               = true;  // Display over price panel.
              PriceTypeSupported    = false; // Don't display price marker on right.
          }
          
          protected override void OnBarUpdate()
          {
              //
              // Calculate new support value and save it as NewSup
              //
          
              for (int idx=0; idx < CurrentBar; idx++)  // Set all values of Sup plot.
                  Plots[0].Set( idx, NewSup );
          }
          This should move the line to the new value every time you come up with a different value of "NewSup".
          Last edited by KBJ; 04-26-2008, 05:45 PM. Reason: Fixed silly typo.

          Comment


            #6
            Thanks KBJ. Worth a shot.
            Josh P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Burak, Yesterday, 10:40 PM
            1 response
            3 views
            0 likes
            Last Post NinjaTrader_ChrisL  
            Started by AdmiralUptick, Today, 05:35 AM
            1 response
            13 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by Gav_G, Today, 02:12 PM
            2 responses
            4 views
            0 likes
            Last Post Gav_G
            by Gav_G
             
            Started by Gav_G, Today, 01:41 PM
            0 responses
            5 views
            0 likes
            Last Post Gav_G
            by Gav_G
             
            Started by kweiss, Today, 01:21 PM
            0 responses
            5 views
            0 likes
            Last Post kweiss
            by kweiss
             
            Working...
            X