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

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]
    Shawn B.NinjaTrader Customer Service

    Comment


      #3
      Great it works thanks !

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by inanazsocial, Today, 01:15 AM
      0 responses
      2 views
      0 likes
      Last Post inanazsocial  
      Started by trilliantrader, 04-18-2024, 08:16 AM
      5 responses
      22 views
      0 likes
      Last Post trilliantrader  
      Started by Davidtowleii, Today, 12:15 AM
      0 responses
      3 views
      0 likes
      Last Post Davidtowleii  
      Started by guillembm, Yesterday, 11:25 AM
      2 responses
      9 views
      0 likes
      Last Post guillembm  
      Started by junkone, 04-21-2024, 07:17 AM
      9 responses
      70 views
      0 likes
      Last Post jeronymite  
      Working...
      X