Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Referencing Previous Instance(s) Of Condition

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

    Referencing Previous Instance(s) Of Condition

    If I want to reference the bar on which a trade was instigated or a bar (or set of bars) nbars ago when a condition(s) was last satisfied,how do I do this please?

    #2
    Try e.g.
    SMA(14)[5]
    to retrieve the 14 period SMA 5 bars ago.

    Comment


      #3
      I really do want to escape Tradestation's hegemony but easylanguage gives them the killer punch until you're able to upgrade your wizard to a comparable level.Either that or provide an EL to C# translator.

      Comment


        #4
        We currently do not have a method to be able to check "How many bars ago did condition X occur". You would have to code this yourself.
        RayNinjaTrader Customer Service

        Comment


          #5
          Next update will support TradeStation like logic for CountIf, MRO and LRO.

          Comment


            #6
            Countif for Multiple Timeframe Strategies

            I've noticed in the help that the Countif function (as well as MRO/LRO functions) is caveated in that it will not work with multiple instruments or timeframes. Is this still the case, and if so, do you offer an alternative approach? Converting boolean expressions to doubles, setting these 1/0 values to a dataseries and then using the SUM function on this dataseries to count the occurances didn't work as expected.

            Regards,

            Whitmark
            whitmark
            NinjaTrader Ecosystem Vendor - Whitmark Development

            Comment


              #7
              You always could code a workaround going with similar logic (by running the checks on all bars of the lookback period). The methods provided are just for convenience.

              Comment


                #8
                For clarification, consider the following example where Low[0] and Close[0] are from an hourly series (BarsInProgress = 0) and user defined variable YestDailyLow is assigned during a Daily series bar close event (BarsInProgress = 1). One would think the way to invoke a CountIf would be:

                Code:
                If (BarsInProgress == 0)
                {
                     myCond = CountIF( delegate (return Low[0] <= YestDailyLow && Close[0] >= YestDailyLow;), 5) > 2);
                }
                But I can see how an extended lookback might not correctly evaluate the BarsArray[1] values retained in the user defined variable YestDailyLow. Would it be helpful to retain the BarsArray[1] values in a dataseries aligned to the BarsArray[0] interval to make the CountIF work properly for multiple timeseries strategies? For example:
                Code:
                If (BarsInProgress == 0)
                {
                     myCond = CountIF( delegate (return Low[0] <= YestDailyLowSeries[0] && Close[0] >= YestDailyLowSeries[0] ;), 5) > 2);
                }
                Will this work to address the caveat on the CountIf function?

                Regards,

                Whitmark
                whitmark
                NinjaTrader Ecosystem Vendor - Whitmark Development

                Comment


                  #9
                  You can't fit a square peg in a round hole .

                  The method will not work on a multi-time frame strategy.
                  RayNinjaTrader Customer Service

                  Comment


                    #10
                    Okay, but do I get points for trying? I'll cry "uncle" and use the brute force method below:

                    Code:
                    if (BarsInProgress == 0)
                    {
                         YestDailyLowSeries.Set( YestDailyLow );
                         int count = 0;
                         for ( int i = 0, i < 5 && CurrentBar - 5 >= 0; i++ )
                         {
                              if ( Low[i] <= YestDailyLowSeries[i] && Close[i] >= YestDailyLowSeries[i] ) Count++;
                         }
                         myCond = count > 2;
                    Any chance a "square peg" version of CountIf is on the development horizon? As you can image, having a function that can determine whether X conditions occured across Y events within Z bars can be pretty useful and something AmiBroker can apparently do across multiple timeframes. Thanks.

                    Regards,

                    Whitmark
                    Last edited by whitmark; 08-01-2007, 03:50 PM.
                    whitmark
                    NinjaTrader Ecosystem Vendor - Whitmark Development

                    Comment


                      #11
                      Any alternatives/workaround for this countif in multitimeframe

                      Ray,

                      Looking at Marks' post and your reply now....So what are the options for countif where multitimeframe is involved?. Can you pls suggest some alternatives if that means coding in c# thats fine..But I just need some ideas so that I can get the function created in C#.

                      Thanks.

                      Cheers,Padhu

                      Comment


                        #12
                        You have to self code a loop that iterates through a specified number of bars checking for your condition.
                        RayNinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by cre8able, Yesterday, 04:16 PM
                        1 response
                        14 views
                        0 likes
                        Last Post NinjaTrader_Gaby  
                        Started by cre8able, Yesterday, 04:22 PM
                        1 response
                        13 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by stafe, 04-15-2024, 08:34 PM
                        5 responses
                        28 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by StrongLikeBull, Yesterday, 04:05 PM
                        1 response
                        12 views
                        0 likes
                        Last Post NinjaTrader_Gaby  
                        Started by Mestor, 03-10-2023, 01:50 AM
                        14 responses
                        375 views
                        0 likes
                        Last Post z.franck  
                        Working...
                        X