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 cmoran13, 04-16-2026, 01:02 PM
          0 responses
          51 views
          0 likes
          Last Post cmoran13  
          Started by PaulMohn, 04-10-2026, 11:11 AM
          0 responses
          31 views
          0 likes
          Last Post PaulMohn  
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          165 views
          1 like
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          100 views
          1 like
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          160 views
          2 likes
          Last Post CaptainJack  
          Working...
          X