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

MRO searches when some can have multiple indeterminate consecutive bars

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

    MRO searches when some can have multiple indeterminate consecutive bars

    Hello,
    I am trying to code a signal for some bar setups, but I am uncertain of the easiest way to proceed. Say I have several different bar types: TypeA, TypeB & TypeC. I then want to search for a setup where the bars occur in the following order: TypeA, TypeB, TypeA, TypeC, TypeA. With Type B & C, I usually know what number of consecutive bars I am searching for, so I can set up an MRO to do the searches. But TypeA bars may occur anywhere from 1 to 7 consecutive times @ each TypeA position. What is the easiest way to code the MRO when I do not know the number of consecutive TypeA bars I am looking for. For example, if there are 4 TypeA bars in position 1, I might search for the 1st instance of this, but if I do not know that was the number of TypeA at position 1, how do I code for the next set of TypeA to search for, that is I cannot just code to find the 2nd instance of 4 Consecutive TypeA, as it may be the 1st instance of 6 Consecutive TypeA in that position. It also becomes difficult to code which TypeA TypeB should be >< etc. Is it possible to set up an MRO within an MRO? So I code MROs for all possible permutations of TypeA, then I include all of them under another MRO to find the 1st, 2nd etc to occur? Or include a counter within the MRO code. Any help much appreciated.

    Thank you.
    Last edited by GeorgeW; 12-02-2019, 05:04 AM.

    #2
    corrected some spelling.

    Comment


      #3
      Hello GeorgeW,

      Thank you for the post.

      It was not clear from your description, is this something you are currently doing and it is already working but wanted wanted to further simplify the code or are you looking for direction on how this may be accomplished in general?

      From the description it would be hard to say if that could be accomplished from the MRO directly. What you have described involves quite a few variables and some unknowns. This may be better suited as a few conditions in OnBarUpdate so that the values can be calculated before you run the final MRO.

      The MRO function will require that all information needed is available in the callback function which may pose a problem if you wanted to mix multiple MRO's or find a value while doing the MRO. In the described case you would likely need to do your MRO's separately to return values and then form a final condition after doing that so that it can access all the required pre-calculated data. You may also need to review the TypeA logic first to see how that value can be found before doing the MRO if it will be needed in the MRO.

      I look forward to being of further assistance.











      JesseNinjaTrader Customer Service

      Comment


        #4
        Thanks for your response, Jesse.
        It's something I have already started, and I can probably code the most basic examples where I give a value to the number of TypeA bars. But in many cases the number of TypeA bars will be different, and i am trying to find the most efficient way to code for that.

        Comment


          #5
          Hello GeorgeW,

          Thank you for clarifying.

          If this is something you have already started you may want to look at the areas which are repetitious and then see if there are any C# ways to do that better. If you wanted to post snippets of the logic in question I and other users can try to comment on that if we know of something better or more efficient. From the description you may need to use some additional logic or looping to cover a range of conditions, it would really depend on what you have requirements for in each of the conditions for your MRO.




          I look forward to being of further assistance.


          JesseNinjaTrader Customer Service

          Comment


            #6
            Thanks Jesse,
            I think I have figured out a way of doing it. I will do a count of all blocks of TypeA, then give one name to them, however many consecutive bars are in a TypeA block,, then the MRO searches for TypeA can be for these blocks.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by maybeimnotrader, Yesterday, 05:46 PM
            2 responses
            20 views
            0 likes
            Last Post maybeimnotrader  
            Started by adeelshahzad, Today, 03:54 AM
            5 responses
            32 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by stafe, 04-15-2024, 08:34 PM
            7 responses
            32 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by merzo, 06-25-2023, 02:19 AM
            10 responses
            823 views
            1 like
            Last Post NinjaTrader_ChristopherJ  
            Started by frankthearm, Today, 09:08 AM
            5 responses
            22 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Working...
            X