Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Conditions are sometimes ignored

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

    Conditions are sometimes ignored

    Hello.

    I have two simple sets of conditions in strategy builder (NT8):

    SET1
    Default input[1]>Open[1]
    Default input[0]>Low[1]
    ___________________
    EnterLongLimit(1, Low[1])


    and the opposite for enter short:

    SET2
    Default input[1]<Open[1]
    Default input[0]<High[1]
    ___________________
    EnterShortLimit(1, High[1]).


    Tested on ES futures, RTH trading hours, 10min timeframe; 26.3. 2018 - 26.4 2018

    If I use just one of these sets, everything works good, but if I want to combine both, some opportunities are overlooked (specifically 26.3. 10:00; 5.4. 10:00; 11.4. 9:30; 12.4. 9:30; 19.4. 9:50).

    If I cancel RTH settings and run the test in ETH trading hours, these overlooked trades are completed correctly, and if I use ETH and add a time condition in "condition and action", the behavior is wrong again - the same like run in RTH range.

    I don´t know what´s wrong - how to test both sets together in RTH?


    ...And I have another (smaller) question - in strategy builder, if I use moving average from different timeframe, how can I plot it on chart in strategy analyzer?

    For example:
    High[0]>SMA(<Primary> (Daily), 14)[1]
    _______________________________
    EnterLong

    If I test this condition (using intraday data), I would like to see the daily calculated SMA on intraday chart.


    Thank you, I´ll be very grateful for any ideas.


    #2
    Hello Bonifac,

    Thanks for your post and welcome to the NinjaTrader forums!

    When you find that a script (Indicator or strategy) is not functioning as expected, please check the "log" tab of the control center for any error messages produced by your strategy. You may need to scroll back if your strategy has been running for a while.

    In your entry sets, I recommend adding a draw object (Dot, arrow, square, etc.) on the chart so that you can see on the chart where the conditions are true (where you expect an entry). This at least lets you know where you should see the entry. Here is a link to a short video on how to approach this: https://Paul-ninjaTrader.tinytake.co...A4M184NTkwOTg3

    Regarding the indicator from another time frame, there would be no way to accomplish this directly. What you could do is again create a drawing object where you set the Y value to the SMA. In the case of a daily SMA in (I assume an intraday chart) the value of SMA would be basically a straight line all day (unless you are using Calculate.OnPriceChange or Calculate.OnEachTick). Please note that in order for you to have a meaningful SMA value, with 14 periods you would need at least 14 days of historical data on your chart and more would be better in terms of accuracy of the moving average.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thank you for your answer and suggestions. Log tab don´t notify any error. I think, the problem is in changing directions of limit orders. If I replace limit order by market with an additional condition (insted of BUY LIMIT at LOW; set IF LOW <= LOW-1 BUY MARKET), than it works fine - without ignoring any entry opportunities.. I have attached two screenshots for better explanation.

      I also tried to draw arrows according to your recommendation (thanks for that) and each omission is preceded by a potential opposite opportunity (I attached another picture).

      I have no idea why these inputs are omitted. I'll be grateful for the advice.
      Attached Files

      Comment


        #4
        Hello Bonifac,

        Thanks for your reply and observations.

        I suspect the orders are being ignored due to the "Managed Approach" which the strategy builder uses and is governed by. From the help guide, " The Managed approach in NinjaScript is designed to offer the greatest ease of use for beginner to intermediate programmers. The order methods are wrapped in a convenience layer that allows you to focus on your system's trading rules, leaving the underlying mechanics of order management and the relationships between entry orders, exit orders, and positions to NinjaTrader. " Reference link: https://ninjatrader.com/support/help...d_approach.htm

        In the link above you will find the section, "Internal Order Handling Rules that Reduce Unwanted Positions". The rule that applies here is, "Methods that generate orders to enter a position will be ignored if: The strategy position is flat and an order submitted by an enter method (EnterLongLimit() for example) is active and the order is used to open a position in the opposite direction"
        The rule does not apply when using market orders.

        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Thank you very much for the link. Although you didn't please me too much ... It looks like the only possibility is to test long and short entries separately. But it is quite problematic, because if I generate only long entries, many of them will be incorrect - many long entries should not be filled because a short entry would be filled in before (on the same day).

          So if there is no way to use these long and short entries both in one analysis, is there a possibility to solve the problem from the other end?? I mean a condition that would forbid opening a long position if different conditions for opening a short position had already been met. I think this is the only way I can test separately long and short entries without distortion. Or not?

          It's a little tangled - have I described the problem understandably enough? Thank you. I'll be glad for any ideas.

          Comment


            #6
            Hello Bonifac,

            Thanks for your reply.

            " I mean a condition that would forbid opening a long position if different conditions for opening a short position had already been met." Yes, you could accomplish this by using bool variables (these are either true or false) that you would set when one condition set is true to prevent entering in the other direction. Bools can be created in the strategy builder in the "variables" section and then can be "read" in the conditions section and can be "set to the other state in the "actions (do the following)" section.

            There are two other alternatives to consider:
            1) Create the strategy in Ninjascript and specify to use the "Unmanaged approach" which has no handling rules and you can place orders as you wish however you as the programmer must also then account for all order states and strategy actions in the event of any errors. If you are relatively new to programming, this would not be recommended but did want you to know of this alternative.
            2) Hire a 3rd party programmer who could create your strategy for you, we can provide references to 3rd party programmers.

            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by Bonifac View Post
              ...

              So if there is no way to use these long and short entries both in one analysis, is there a possibility to solve the problem from the other end?? I mean a condition that would forbid opening a long position if different conditions for opening a short position had already been met. I think this is the only way I can test separately long and short entries without distortion. Or not?
              It may very well be possible, in some convoluted manner, to use the Strategy Builder to do what you want, but it will certainly be easier to just open the code and edit it manually, (or just code from scratch).

              You will need to use boolean gates to determine allowed trading direction. Here is a reference to an answer that I gave to pretty much the obverse of what you are asking, but the same idea of gating trade direction.

              ref: https://ninjatrader.com/support/foru...127#post845127

              Comment


                #8

                Thank you gentlemen for your advice. The bool variant works fine, which is a more useful option for me at the moment than opening the code. So thank you again!

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by geddyisodin, Yesterday, 05:20 AM
                8 responses
                49 views
                0 likes
                Last Post geddyisodin  
                Started by DayTradingDEMON, Today, 09:28 AM
                3 responses
                19 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by Stanfillirenfro, Today, 07:23 AM
                9 responses
                23 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by George21, Today, 10:07 AM
                0 responses
                8 views
                0 likes
                Last Post George21  
                Started by navyguy06, Today, 09:28 AM
                1 response
                7 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Working...
                X