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

Indicator colour coding one bar too early

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

    Indicator colour coding one bar too early

    Hi all,

    I attach an image of an indicator I've written. The indicator panel should be coloured red for instance if the curve is between the two dashed horizontal lines. However you can see that it draws the colour one bar early everywhere.

    The colour is chosen after the indicator is set by testing on its value. In rough pseudocode:

    Set value of indicator using Close[0] and SMA(50)[0]
    If the set value is between -0.01 and -0.02 then set background color as red

    What is my obvious error here?

    Thanks,
    darmbk.
    Attached Files

    #2
    Originally posted by darmbk View Post
    Hi all,

    I attach an image of an indicator I've written. The indicator panel should be coloured red for instance if the curve is between the two dashed horizontal lines. However you can see that it draws the colour one bar early everywhere.

    The colour is chosen after the indicator is set by testing on its value. In rough pseudocode:

    Set value of indicator using Close[0] and SMA(50)[0]
    If the set value is between -0.01 and -0.02 then set background color as red

    What is my obvious error here?

    Thanks,
    darmbk.
    Congrats on writing the indicator, looks good.

    When it comes to painting a background, note that the painting occurs from the center of the distance between bars, so the background will always encompass (both sides of) the bar. While your calculations are correct it is the width of the bar and space between bars that is creating the illusion of being one bar early. You can validate this yourself by drawing an object such as a triangle at the point of the detection and it should be plotted at that point of detection and not one bar before.

    Comment


      #3
      Hello Darmbk,

      Thank you for your post and thank you to Tasker for answering.

      Yes, this is correct. I would follow Tasker's example with the triangle and see how that plots in relation to the chart.

      Let me know if I can be of further assistance.
      Cal H.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Rapine Heihei, Today, 08:19 PM
      1 response
      3 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by Rapine Heihei, Today, 08:25 PM
      0 responses
      4 views
      0 likes
      Last Post Rapine Heihei  
      Started by f.saeidi, Today, 08:01 PM
      1 response
      4 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by Rapine Heihei, Today, 07:51 PM
      0 responses
      6 views
      0 likes
      Last Post Rapine Heihei  
      Started by frslvr, 04-11-2024, 07:26 AM
      5 responses
      96 views
      1 like
      Last Post caryc123  
      Working...
      X