• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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

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

        Comment


          #5
          Brilliant!

          the 2 thing worked, cheers for that

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by guvenators, Today, 05:18 PM
          1 response
          13 views
          0 likes
          Last Post NinjaTrader_ShawnB  
          Started by LANwarr1or, Today, 03:00 PM
          2 responses
          8 views
          0 likes
          Last Post LANwarr1or  
          Started by Newtrader101, Today, 02:53 PM
          2 responses
          10 views
          0 likes
          Last Post Newtrader101  
          Started by JuanPabloQuevedo, Today, 02:53 PM
          2 responses
          9 views
          0 likes
          Last Post JuanPabloQuevedo  
          Started by samir, Today, 03:16 PM
          2 responses
          14 views
          0 likes
          Last Post samir
          by samir
           
          Working...
          X