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 Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      672 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      379 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      111 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      575 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      582 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X