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 DJ888, 04-16-2024, 06:09 PM
              6 responses
              18 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by Jon17, Today, 04:33 PM
              0 responses
              1 view
              0 likes
              Last Post Jon17
              by Jon17
               
              Started by Javierw.ok, Today, 04:12 PM
              0 responses
              6 views
              0 likes
              Last Post Javierw.ok  
              Started by timmbbo, Today, 08:59 AM
              2 responses
              10 views
              0 likes
              Last Post bltdavid  
              Started by alifarahani, Today, 09:40 AM
              6 responses
              41 views
              0 likes
              Last Post alifarahani  
              Working...
              X