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

Bug with the Min function?

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

    Bug with the Min function?

    Not sure if I am doing something wrong here, but here's my problem:

    In the OnBarUpdate I have set the following:
    myBidSeries.Set(GetCurrentBid());

    in one of my methods, I set the following variables:
    iMax = MAX(myBidSeries, iBars)[0];
    iMin = MIN(myBidSeries, iBars)[0];

    My output however is inconsistent:
    for iMax I always get a proper value, for iMin however, for the same set of ranges, I get a 0.

    This problem is only resolved when I substitue myBidSeries with Close price. Why doesn't this work with my Bid Price Data Series??? Interestingly, when I print out the myBidSeries[i], and Close[i] in a for loop, I get the same values, but when used with the Min function it does not work...

    Please help, btw, I am using market replay to test this function.
    Thanks,
    Gary

    #2
    Gary, welcome to the forums here! Which NinjaTrader version are you using currently? You can check this under Help > About.

    Do you get the same printouts if used on a live data stream?

    For which product and timeframe(s) are you testing this?

    Please keep in mind there's no historical bid / ask data available so instead in a backtest the Close would be substituted then.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Maybe the iBars =0? You know that minimum of 0 and positive number equals ZERO.

      Baruch

      Comment


        #4
        Bug with the Min Function?

        Hi Guys,

        I am using version 6.5.1000.11 LIVE
        Looking at 1 second chart of the EUR/GBP pair. I have a full days worth of data.

        I have verified that iBars >0, moreover, the MAX function works with the same exact parameters, that's why it is soo confusing to me.

        I am doing market replay as I know this test would not work if I would be backtesting, however with market replay, to my understanding, the getCurrentBid() function should work -- and does as I get the print out for every bar available.

        Also, just tried in live, get same results.
        Thanks for your help guys.

        Comment


          #5
          Gary, can't reproduce this here, both min and max of the bidseries return proper values after the needed startup time to fill the bidseries...on which broker / feed are you testing this?
          BertrandNinjaTrader Customer Service

          Comment


            #6
            Bug with the Min Function?

            Using forex.com

            Also, I made sure for bidseries to be full before I start debugging.

            Anything else I can try to see where the issue is?

            Comment


              #7
              Which Pip setting are you using for Gain / Forex.com? For simulation, please set this to 'Pip'. I was testing on the same connection this morning and it worked as expected, so perhaps you can post your full code so I can let exactly the same code run on my end to compare.
              BertrandNinjaTrader Customer Service

              Comment


                #8
                Here's the partial code, I have defined all variables...
                #region Variables
                DataSeries myBidSeries;
                #endregion
                protected override void Initialize()
                {
                //Bid Prices Array
                myBidSeries = new DataSeries(this);
                int iBars = 300;
                }
                protected override void OnBarUpdate()
                {
                // Bid Price array
                myBidSeries.Set(GetCurrentBid());

                iMax = MAX(myBidSeries, iBars)[0];
                iMin = MIN(myBidSeries, iBars)[0];

                Print("iMin = MIN(myBidSeries, iBars)[0] " + MIN(myBidSeries, iBars)[0] );
                Print("iMin = MIN( Close, iBars)[0] " + MIN(Close, iBars)[0] );
                }

                This should show you that when I use myBidSeries in the Min function I get a 0, and when I use Close, I get a value.

                Thanks,
                Gary

                Comment


                  #9
                  Hi there Gary, I just tested this on my end with YM on the Simulated Data Feed and this is the output from your script:
                  Code:
                  iMin = MIN(myBidSeries, iBars)[0] 9318
                  iMin = MIN( Close, iBars)[0] 9318
                  It isn't reporting 0 for a min value, is that what you get?
                  AustinNinjaTrader Customer Service

                  Comment


                    #10
                    This is what I get: (as you can see I have printer myBidSeries and Close and they are equal, as soon as I use the min function, I get a 0.

                    Interesting, eh??? I am sure it is something silly, just want to make sure I understand it!

                    myBidSeries 0.8512
                    Close price 0.8512
                    iMin = MIN(myBidSeries, iBars)[0] 0
                    iMin = MIN( Close, iBars)[0] 0.8512

                    Thanks!

                    Comment


                      #11
                      If you get a 0 for a Min function, that means your data series has a 0 in it somewhere. Can you send me the full script so I can try to reproduce this behavior? If that isn't possible, can you try it with the script attached to this post?
                      Attached Files
                      AustinNinjaTrader Customer Service

                      Comment


                        #12
                        Your indicator works fine.

                        Okay, I will spend more time on this before bugging you guys. Must be something else in my code that screws it up.
                        thank you!
                        -Gary

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by rhyminkevin, Today, 04:58 PM
                        3 responses
                        47 views
                        0 likes
                        Last Post Anfedport  
                        Started by iceman2018, Today, 05:07 PM
                        0 responses
                        5 views
                        0 likes
                        Last Post iceman2018  
                        Started by lightsun47, Today, 03:51 PM
                        0 responses
                        7 views
                        0 likes
                        Last Post lightsun47  
                        Started by 00nevest, Today, 02:27 PM
                        1 response
                        14 views
                        0 likes
                        Last Post 00nevest  
                        Started by futtrader, 04-21-2024, 01:50 AM
                        4 responses
                        50 views
                        0 likes
                        Last Post futtrader  
                        Working...
                        X