Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 geddyisodin, 04-25-2024, 05:20 AM
          8 responses
          60 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by jxs_xrj, 01-12-2020, 09:49 AM
          4 responses
          3,287 views
          1 like
          Last Post jgualdronc  
          Started by Option Whisperer, Today, 09:55 AM
          0 responses
          5 views
          0 likes
          Last Post Option Whisperer  
          Started by halgo_boulder, 04-20-2024, 08:44 AM
          2 responses
          22 views
          0 likes
          Last Post halgo_boulder  
          Started by mishhh, 05-25-2010, 08:54 AM
          19 responses
          6,189 views
          0 likes
          Last Post rene69851  
          Working...
          X