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

Help with DrawHorizontalLine

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

    Help with DrawHorizontalLine

    Hi there,

    I am pretty new to Ninja and am trying some simple stuff to get over the learning curve, here is a piece of code I wrote to draw a horizontal line when the slope marked ' 0 slope'

    if (Slope(EMA(20), 5, 0) > -0.01 && Slope(EMA(20), 5, 0) < 0.01 )
    {
    DrawText("MyText" + CurrentBar, "0 Slope", 0, GetCurrentAsk() + 5 * TickSize, Color.Red);
    DrawHorizontalLine("my", Close[0], Color.Blue);
    flatSlope = true;
    }else
    {
    flatSlope = false;
    }

    Here is the backtest result; I can see 'drawText' is working with ' 0 slope', but where is my horizontal line?

    This is the NT7 documentation:

    Syntax

    DrawHorizontalLine(string tag, double y, Color color)


    Examples
    // Draws a horizontal line
    DrawHorizontalLine("tag1", 1000, Color.Black);
    What did I do wrong?

    Thanks!




    #2
    Hello PowerGrid,

    Because the tag name is not unique (the way the text tag name is unique by adding CurrentBar to the string) there will only be one horizontal line that is being updated to a new price.

    What was the close price the last very last time the object was drawn?

    (For multiple horizontal lines, use unqiue tag names like "my" + CurrentBar)
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3

      Thanks Chelsea B, I got it working... it was there at last '0 slope' at the very end of my backtest

      Comment


        #4
        Hi Chelsea B, I got another issue in backtest, when the price moves up'n'down, eventually, it moved OUTSIDE the screen, how do you 're-center' it back ? (see attached screenshot), I tried to shrink it, but it's just too small to be useful...

        Thanks!

        Comment


          #5
          Hello PowerGrid,

          To return to automatic scaling, click the small F in the upper right corner of the chart.

          Below is a link to the help guide on navigating a chart. Please see the section 'How to change the vertical scale and range of a chart'
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Thank you Chelsea B! works beautifully!

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by wzgy0920, 04-20-2024, 06:09 PM
            2 responses
            27 views
            0 likes
            Last Post wzgy0920  
            Started by wzgy0920, 02-22-2024, 01:11 AM
            5 responses
            32 views
            0 likes
            Last Post wzgy0920  
            Started by wzgy0920, 04-23-2024, 09:53 PM
            2 responses
            49 views
            0 likes
            Last Post wzgy0920  
            Started by Kensonprib, 04-28-2021, 10:11 AM
            5 responses
            193 views
            0 likes
            Last Post Hasadafa  
            Started by GussJ, 03-04-2020, 03:11 PM
            11 responses
            3,235 views
            0 likes
            Last Post xiinteractive  
            Working...
            X