Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Color band

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

    Color band

    Hi, I want to create a colored band using an EMA ... basically, take 5 ticks on both sides of the EMA and color is red when falling and green when rising. Got the 'falling' and 'rising' down, but now sure how to fill in the band with a color. Can you direct me to a resource that can help. thanks!

    #2
    Hello pman777,
    You can use the DrawRegion method to color a band around the MA. A sample code will be like:
    Code:
    if (CurrentBar > 1) DrawRegion("tag" + CurrentBar , 0, 1, SMA(14), SMA(14)[0] + 5 * TickSize , Color.Transparent, Color.Blue, 3);
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      OK ... I'm doing something wrong but cannot see it. Maybe you canhelp me. when compiling, I'm getting a CS1502 error message. This error can occur when you pass in incorrect parameter object types into a method such as an indicator.

      DrawRegion("tag1", CurrentBar , 0, EMA(160)[0], (EMA(160)[0] + (6* TickSize)) , Color.Transparent, Color.LightGreen, 3);

      Comment


        #4
        Hello pman777,
        The best overload for a draw region is
        • 2 IDataSeries
        • I IDataSereis and 1 double


        You have assigned 2 double and thus you are getting the error. Please modify your code as below and see if you can get it work.
        Code:
        DrawRegion("tag1", CurrentBar , 0,[B] EMA(160)[/B], (EMA(160)[0] + (6* TickSize)) , Color.Transparent, Color.LightGreen, 3);
        JoydeepNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        81 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        42 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        64 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        66 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        54 views
        0 likes
        Last Post CarlTrading  
        Working...
        X