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 funk10101, Today, 12:02 AM
              0 responses
              3 views
              0 likes
              Last Post funk10101  
              Started by gravdigaz6, Yesterday, 11:40 PM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by MarianApalaghiei, Yesterday, 10:49 PM
              3 responses
              10 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by XXtrader, Yesterday, 11:30 PM
              0 responses
              4 views
              0 likes
              Last Post XXtrader  
              Started by love2code2trade, 04-17-2024, 01:45 PM
              4 responses
              28 views
              0 likes
              Last Post love2code2trade  
              Working...
              X