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 benmarkal, Yesterday, 12:52 PM
      3 responses
      22 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by helpwanted, Today, 03:06 AM
      1 response
      18 views
      0 likes
      Last Post sarafuenonly123  
      Started by Brevo, Today, 01:45 AM
      0 responses
      11 views
      0 likes
      Last Post Brevo
      by Brevo
       
      Started by aussugardefender, Today, 01:07 AM
      0 responses
      6 views
      0 likes
      Last Post aussugardefender  
      Started by pvincent, 06-23-2022, 12:53 PM
      14 responses
      244 views
      0 likes
      Last Post Nyman
      by Nyman
       
      Working...
      X