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

How to draw horizontal line on Indicator?

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

    How to draw horizontal line on Indicator?

    Hello,

    I am using this:
    Code:
    AddLine(Brushes.DarkGray, 10, NinjaTrader.Custom.Resource.NinjaScriptIndicatorZeroLine);

    But the line drawn is always at y=0?

    I am calling the method inside OnStateChange with state = SetDefaults.

    Many Thanks, Caesar.

    #2
    Hello Skechers,

    When you say y=0 do you mean a price of 0? Have you removed and re apply the script since you added this code?
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello Jesse,

      Yes, the line is always drawn on price = 0.

      Many Thanks, Caesar.

      Comment


        #4
        Hello Skechers,

        Have you tried making a new empty indicator to confirm that there is nothing else in that script that may be affecting the result?

        You can also try copying the help guide sample, I see that working on my end.



        JesseNinjaTrader Customer Service

        Comment


          #5
          Hello,

          It turns out that when I use a variable the is provided in the UI that variable's value is 0 in the State.SetDefaults state.

          How do I retrieve the variable value then?

          I was able to draw using Draw.HorizontalLine from StateDataLoaded.

          Many Thanks, Caesar.
          Last edited by Skechers; 10-18-2022, 02:11 PM.

          Comment


            #6
            Hello Skechers,

            Yes in SetDefaults you cant use a UI variable, if you take a look at the second sample in the help guide it shows how to use a variable from State.Configure.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Ah, I see that now. Many Thanks, Caesar.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by rhyminkevin, Today, 04:58 PM
              3 responses
              46 views
              0 likes
              Last Post Anfedport  
              Started by iceman2018, Today, 05:07 PM
              0 responses
              5 views
              0 likes
              Last Post iceman2018  
              Started by lightsun47, Today, 03:51 PM
              0 responses
              7 views
              0 likes
              Last Post lightsun47  
              Started by 00nevest, Today, 02:27 PM
              1 response
              14 views
              0 likes
              Last Post 00nevest  
              Started by futtrader, 04-21-2024, 01:50 AM
              4 responses
              50 views
              0 likes
              Last Post futtrader  
              Working...
              X