Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help with Code please.

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

    Help with Code please.

    Hello,
    I can get this to compile but did doesnt plot an Diamond.
    Does anyone know why?
    protectedoverridevoid OnBarUpdate()
    {
    if (SMA(5)[0] > SMA(5)[1]
    && SMA(
    5)[1] < SMA(5)[2])
    {
    DrawDiamond(
    "Up Diamond" + CurrentBar, 0, SMA(5)[0], Color.Blue);
    }

    if (SMA(5)[0] < SMA(5)[1]
    && SMA(
    5)[1] > SMA(5)[2])
    {
    DrawDiamond(
    "Down Diamond" + CurrentBar, 0, SMA(5)[0], Color.Magenta);

    }
    }

    Thanks

    #2
    Hi dwalls,

    You need to make sure you have enough bars present to start your calculations, so please add this check at the start of your OnBarUpdate() section -

    Code:
    [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][SIZE=2][SIZE=2] (CurrentBar < [/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]5[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2])
    [/SIZE][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][FONT=Verdana];[/FONT][/SIZE][/FONT][/SIZE][/FONT]
    [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][FONT=Verdana][/FONT][/SIZE][/FONT][/SIZE][/FONT]


    Then you should see the diamonds plot as per your conditions.

    Please also review this link here - http://www.ninjatrader-support2.com/...ead.php?t=3170

    Comment


      #3
      Thanks...That worked.
      I learn something new here eveyday.

      Thanks for your help.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      129 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      74 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      116 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      111 views
      1 like
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      89 views
      0 likes
      Last Post CarlTrading  
      Working...
      X