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

Are Plots the only way to get prices highlighted in the Price Scale?

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

    Are Plots the only way to get prices highlighted in the Price Scale?

    Hi,

    Is it possible to get this to display in the Price Scale without using a Plot?

    Code:
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)​
    {
    
    AddLine(new Stroke(new SolidColorBrush((Color)ColorConverter.ConvertFromS tring("#90FFFF00")), DashStyleHelper.Dash, 1), 250, "250");
    AddLine(new Stroke(new SolidColorBrush((Color)ColorConverter.ConvertFromS tring("#FF464A55")), DashStyleHelper.Dash, 2), 100, "100");
    Thanks​

    #2
    Hello davydhnz,

    Thank you for your post.

    Price markers are only generated for plots and only when the PaintPriceMarkers property is set to true. AddLine() results in a line that is added to the chart without a price marker. You will have to use a plot if you'd like a price marker to be displayed in the price scale.

    Please let us know if we may be of further assistance.
    Emily C.NinjaTrader Customer Service

    Comment


      #3
      NinjaTrader_Emily,

      thank you for your reply. It was helpful.

      Follow up question, is there a way to set plots so that they don't have to be constantly updated in OnBarUpdate?

      i.e. set them once.

      Something like:

      Code:
      protected override void OnBarUpdate()
      {
      if (FirstRun)
      {
      // Assign values to your plots
      Values[0][0] = 250; // Plot250
      Values[1][0] = 100; // Plot100
      
      FirstRun = false;
      }
      
      }
      except it's static.

      Much appreciated,
      David​

      Comment


        #4
        Hello David,

        Thank you for your reply.

        Since plot values are held in a Series<double> object, you would need to assign the value continuously and not just one time. You could call them once per bar using a script that calculates On Each Tick or On Price Change by checking if IsFirstTickOfBar is true:
        Code:
        protected override void OnBarUpdate()
        {​
        if (IsFirstTickOfBar)
        Values[0][0] = 250;
        Values[1][0] = 100;
        }
        This will assign the plot's value for the current bar only on the close of each bar rather than for every time that OnBarUpdate() is called.

        Please feel free to reach out with any additional questions or concerns.
        Emily C.NinjaTrader Customer Service

        Comment


          #5
          Thanks NinjaTrader_Emily

          One last question, famous last words

          Is there a way to make plot lines transparents, but retain their set colours in the price markers in the price scale?

          Thanks.

          Comment


            #6
            Originally posted by davydhnz View Post
            Thanks NinjaTrader_Emily

            One last question, famous last words

            Is there a way to make plot lines transparents, but retain their set colours in the price markers in the price scale?

            Thanks.
            For that use case, the PlotStyle.PriceBox should be used. This will use the stroke color fo the price box in the price scale and will not plot any lines on the chart itself. The AddPlot() page contains a list of the available plotStyle options:


            Feel free to reach out with any additional questions or concerns.
            Emily C.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Rogers101, 05-05-2024, 11:30 AM
            21 responses
            65 views
            0 likes
            Last Post Rogers101  
            Started by max1ci6, Today, 06:47 AM
            1 response
            3 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by Klaus Hengher, Today, 03:13 AM
            1 response
            13 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by JGriff5646, Yesterday, 10:02 PM
            1 response
            17 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by AdamDJ8, Yesterday, 09:18 PM
            1 response
            9 views
            0 likes
            Last Post NinjaTrader_LuisH  
            Working...
            X