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 algospoke, 04-17-2024, 06:40 PM
          6 responses
          48 views
          0 likes
          Last Post algospoke  
          Started by arvidvanstaey, Today, 02:19 PM
          4 responses
          11 views
          0 likes
          Last Post arvidvanstaey  
          Started by samish18, 04-17-2024, 08:57 AM
          16 responses
          61 views
          0 likes
          Last Post samish18  
          Started by jordanq2, Today, 03:10 PM
          2 responses
          9 views
          0 likes
          Last Post jordanq2  
          Started by traderqz, Today, 12:06 AM
          10 responses
          19 views
          0 likes
          Last Post traderqz  
          Working...
          X