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 argusthome, 03-08-2026, 10:06 AM
      0 responses
      23 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      20 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      14 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      10 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      41 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X