Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

plots current bar but nothing else

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

    plots current bar but nothing else

    Hi there,

    v simple, why is it that if i have SMA(4)[2] in the if statement i get nothing on chart or in output window

    but when I change it to SMA(4)[0] it works?

    what do i have to do to get it to work with 2 etc.?

    if
    (CurrentBar < 1) return;

    double sum = 6;

    if (SMA(4)[2] > 0) ;
    Print (
    "3<0 pos sum " + sum + " SMA2 " + SMA(4)[0]);


    TF.Set(sum/
    6);

    #2
    Please see the link I pointed you to on the other thread: http://www.ninjatrader-support.com/v...ead.php?t=3170

    Comment


      #3
      Hi there

      hmm, yea, I have tried that.

      1. When I try the first example

      it compiles OK but no output.

      2. when i try the second i get an error on compile for the line
      double sum = 6
      embedded statement can't be a declaration or labeled statement

      I can programe in vba, but this is totally new to me and i'm sure it's something simple i'm doing wrong, just been striping code out and building up, checking it, adding one line at a time but can't get past this.

      protectedoverridevoid OnBarUpdate()
      {
      if (Close[0] > Close[Math.Min(CurrentBar, 1)])
      //if (CurrentBar < 1) return;
      double sum = 6;

      if (SMA(4)[2] > 0) ;
      Print (
      "3<0 pos sum " + sum + " SMA2 " + SMA(4)[0]);


      TF.Set(sum/
      6);
      }

      Comment


        #4
        Not sure what you want to achieve but your code below is incorrect and won't even compile.

        Unfortunately we can not provide support down to the level of plain C# coding but here are two hints. Try:

        if (CurrentBar < 2) return;

        if (SMA(4)[2] > 0) ; <- semicolon probably incorrect

        Comment


          #5
          Brilliant!

          the 2 thing worked, cheers for that

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          566 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          330 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          547 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          548 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X