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
    BertrandNinjaTrader Customer Service

    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 GussJ, 03-04-2020, 03:11 PM
      14 responses
      3,244 views
      0 likes
      Last Post GussJ
      by GussJ
       
      Started by lorem, Today, 09:18 AM
      0 responses
      2 views
      0 likes
      Last Post lorem
      by lorem
       
      Started by hazylizard, Today, 08:38 AM
      4 responses
      11 views
      0 likes
      Last Post hazylizard  
      Started by geddyisodin, Today, 05:20 AM
      2 responses
      20 views
      0 likes
      Last Post geddyisodin  
      Started by Max238, Today, 01:28 AM
      5 responses
      48 views
      0 likes
      Last Post Max238
      by Max238
       
      Working...
      X