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

Draw command when Close hits channel

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

    Draw command when Close hits channel

    I have a simple High-Low channel based on Lin Regs. Now I'd like to have it draw a dot when it hits either the High or Low but it does not compile.

    protected override void OnBarUpdate()
    {

    // Checks to make sure we have at least 1 bar before continuing
    if (CurrentBar < 1)
    return;

    LRLow.Set(LinReg(Low, period)[0]);
    LRHi.Set(LinReg(High, period)[0]);
    LRClose.Set(LinReg(Close, period)[0]);

    if (Close[0] >= LinReg(High,period)[0])
    {
    DrawDot("tag1", true, 0, High[0] + 2 TickSize, Color.Red);
    }

    if (Close[0] <= LinReg(Low,period)[0])
    {
    DrawDot("tag2", true, 0, Low[0] - 2 TickSize, Color.Green);
    }
    }

    An image of the code is also attached. I have looked over the {} and [] and ":" ad nauseum but can't find what I am doing wrong. Any help/advice?

    sandman
    Attached Files

    #2
    Hello,

    Please change the following syntax in both places it is used:

    Code:
    2 TickSize
    to

    Code:
    2 * TickSize
    If you want 2 Ticks, you would multiply two Times TickSize, the operator is missing from the syntax you are using currently.

    In the image, you can see the "Hint" or red line under TickSize, this indicates the error may be near what is currently Red Underlined. It is not 100% accurate but should give you a general idea on where the actual error is. As shown the error message does not say TickSize at all, but only that the structure of the file is incorrect.



    I look forward to being of further assistance.
    Last edited by NinjaTrader_Jesse; 07-28-2016, 03:30 PM. Reason: added error description
    JesseNinjaTrader Customer Service

    Comment


      #3


      sandman

      Thanks Jesse

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by algospoke, Yesterday, 06:40 PM
      2 responses
      19 views
      0 likes
      Last Post algospoke  
      Started by ghoul, Today, 06:02 PM
      3 responses
      14 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by jeronymite, 04-12-2024, 04:26 PM
      3 responses
      45 views
      0 likes
      Last Post jeronymite  
      Started by Barry Milan, Yesterday, 10:35 PM
      7 responses
      20 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by AttiM, 02-14-2024, 05:20 PM
      10 responses
      181 views
      0 likes
      Last Post jeronymite  
      Working...
      X