Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Show block if a condition is true

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

    Show block if a condition is true

    Hey guys !

    I'm got an indicator which plot a line. I just would like to plot blocks (or dash or whatever) only when the value changes. Is there any easy way to do this ?

    Thanks !
    Attached Files

    #2
    Hello After,


    You could do this by comparing the current value of your indicators current bar value to the previous bar value. I have included our Help Guides on Developing Indicators to assist you further in getting familiar with building indicators.
    I have included an example below of what this would look like.
    Code:
    [COLOR=#000000][FONT=Tahoma][LEFT][FONT=Courier New][SIZE=2][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000FF]protected[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000FF]override[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000FF]void[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2]OnBarUpdate()[/SIZE][/FONT][/FONT][LEFT][/LEFT][/COLOR][LEFT][/LEFT]
    [COLOR=#000000][FONT=Tahoma][LEFT][FONT=Courier New][SIZE=2]      {[/SIZE][/FONT][/LEFT][/FONT][LEFT][/LEFT][/COLOR][LEFT][/LEFT]
    [COLOR=#000000][FONT=Tahoma][LEFT][FONT=Courier New][SIZE=2][COLOR=#0000FF]     if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]/*Replace SMA your Indicator name, Replace myInput0 with your period*/[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2]SMA(myInput0)[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] != SMA(myInput0)[[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]])[/SIZE][/FONT][/LEFT][/FONT][LEFT][/LEFT][/COLOR][LEFT][/LEFT]
    [COLOR=#000000][FONT=Tahoma][LEFT][FONT=Courier New][SIZE=2]     {PlaySound([/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#800000]@"Alert1.wav"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT][/LEFT][/FONT][LEFT][/LEFT][/COLOR][LEFT][/LEFT]
    [COLOR=#000000][FONT=Tahoma][LEFT][FONT=Courier New][SIZE=2]     DrawArrowDown(CurrentBar.ToString(),[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000FF]true[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2], Close[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] + TickSize, Color.Blue);} [/SIZE][/FONT][FONT=Courier New]}[/FONT][/LEFT][/FONT][LEFT][/LEFT][/COLOR][LEFT][/LEFT]
    [FONT=Courier New][SIZE=2][/SIZE][/FONT]
    [/LEFT][/FONT][/COLOR]

    Comment


      #3
      Great it works thanks !

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      648 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      369 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      108 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      572 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      574 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X