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

Ema(20)[0] = 0???

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

    Ema(20)[0] = 0???

    I'm coding an indicator using NT7 beta 19 and any indicators I use inside of it are returning 0.

    Code:
                double f = EMA(20)[0];
                double s = EMA(50)[0];
                Print(f + "::" + s);
    Prints several lines of this to my output window
    Code:
    0::0
    0::0
    0::0
    0::0
    0::0
    0::0
    0::0
    0::0
    0::0
    0::0
    0::0
    0::0
    0::0
    What gives? The chart is not a bunch of bars with price = 0.

    #2
    Originally posted by shodson View Post
    I'm coding an indicator using NT7 beta 19 and any indicators I use inside of it are returning 0.

    Code:
                double f = EMA(20)[0];
                double s = EMA(50)[0];
                Print(f + "::" + s);
    Prints several lines of this to my output window
    Code:
    0::0
    0::0
    0::0
    0::0
    0::0
    0::0
    0::0
    0::0
    0::0
    0::0
    0::0
    0::0
    0::0
    What gives? The chart is not a bunch of bars with price = 0.
    Hi shodson,

    Stick this in there and see where it gets hung up.

    Want to make sure you have enough bars.

    Print(" CurrentBar = " + CurrentBar);

    RJay
    RJay
    NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

    Comment


      #3
      Originally posted by rt6176 View Post
      Hi shodson,

      Stick this in there and see where it gets hung up.

      Want to make sure you have enough bars.

      Print(" CurrentBar = " + CurrentBar);

      RJay
      Still no good...

      Code:
              protected override void OnBarUpdate()
              {
                  if (CurrentBar <= 50)
                      return;
                  
                  double f = EMA(20)[0];
                  double s = EMA(50)[0];
                  Print(CurrentBar + "==> " + f + "::" + s);
              }
      And these are the results

      Code:
      51==> 0::0
      52==> 0::0
      53==> 0::0
      54==> 0::0
      55==> 0::0
      56==> 0::0
      57==> 0::0
      58==> 0::0
      ...
      2622==> 0::0
      2623==> 0::0
      2624==> 0::0
      2625==> 0::0

      Comment


        #4
        Hi shodson,

        You may have to create series first, then double.


        EMA ema1 = EMA(Close, 20);

        EMA ema2 = EMA(Close, 50);


        double f = ema1[0] ;

        double s = ema2[0] ;


        Print(f + "::" + s);


        RJay
        RJay
        NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

        Comment


          #5
          Originally posted by rt6176 View Post
          Hi shodson,

          You may have to create series first, then double.


          EMA ema1 = EMA(Close, 20);

          EMA ema2 = EMA(Close, 50);


          double f = ema1[0] ;

          double s = ema2[0] ;


          Print(f + "::" + s);


          RJay
          Yeah, I tried that, that's the sort of thing I usually do, I just dumbed it down for the sake of posting a simple example to the forums. It still doesn't work even if I use an EMA object. If I specify the Close DataSeries I then get a runtime error:

          Failed to call method 'Initialize' for indicator '______': 'BarsInProgress' property can't be accessed from within 'Initialize' method

          Huh? I'm not even using BarsInProgress, it must think I'm trying to use multiple time frames.

          Forget it, NT7 is a fail, again. Worse product beta I've ever seen.

          Comment


            #6
            works fine at my end. did i miss something

            Comment


              #7
              shodson,

              If you actually posted your Initialize() code we could then tell you which parts are erroneous. Otherwise we can only see what you have in OnBarUpdate() and would have no way to help with your Initialize() method.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Hi Shodson,

                Try using Zerolag MACD in the NT 6.5 download area.



                Just download, import, rename, and modify that indicator to your criteria.

                Simple and Easy!!!

                RJay
                RJay
                NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by zstheorist, Today, 07:52 PM
                0 responses
                3 views
                0 likes
                Last Post zstheorist  
                Started by pmachiraju, 11-01-2023, 04:46 AM
                8 responses
                149 views
                0 likes
                Last Post rehmans
                by rehmans
                 
                Started by mattbsea, Today, 05:44 PM
                0 responses
                5 views
                0 likes
                Last Post mattbsea  
                Started by RideMe, 04-07-2024, 04:54 PM
                6 responses
                33 views
                0 likes
                Last Post RideMe
                by RideMe
                 
                Started by tkaboris, Today, 05:13 PM
                0 responses
                5 views
                0 likes
                Last Post tkaboris  
                Working...
                X