Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

New user query regarding strategies

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

    New user query regarding strategies

    I am trying to test a basic strategy created using the strategy builder. I want to buy when the price crosses over the 13 sma and to sell when the price goes under on a 1 minute chart. What I have created triggers a buy order immediately that the price crosses above the sma which is what I want to occur. Quite often the price drops back down below the SMA line, should a sell occur then? I guess not as you get get lots of buy and sell orders otherwise. If for the following 1 minute candle the price is still under the sma line should anything happen. I ask as I am getting a long triggered then the price drops below the sma and no sell gets triggered for the later candles.
    Is there a basic strategy like I am a describing available to download so that I can test it out please to see where I am going wrong?
    Should I be calculating using "tick" or "price change" ?
    For the buy order when going above the sma should I use "ask" or "close" as the trigger, should both work?
    I enclose an attachment of the a buy order getting triggered then the price closing below the sma for that bar then no further trades being triggered. Click image for larger version

Name:	NT chart screenshot.png
Views:	268
Size:	7.9 KB
ID:	1099670

    #2
    Hello kebabman,

    Thank you for your post.

    Would you be able to provide screenshots of all your condition sets on the Conditions and Actions screen of the builder? We'll need to see the logic you've got set up to understand why it's taking the trades it is taking or why it's not taking certain trades you think it should.

    Thanks in advance; I look forward to assisting you further.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Click image for larger version  Name:	Screenshot 2020-05-14 20.03.10.png Views:	0 Size:	27.8 KB ID:	1099780Click image for larger version  Name:	Screenshot 2020-05-14 20.03.16.png Views:	0 Size:	27.5 KB ID:	1099781

      As I said above the problem is when say I am Short and the price rises and touches the sma and triggers a reversal to go Long as desired. Often then the price moves back down again through the SMA line in the same bar, so obviously a reversal from Long back to short is required. This does not happen in the same bar, but I am ignorant whether this could be programmed for, but it doesn't get corrected on the next bars either. Then the market often continues short but the strategy is still long. Apologies for posting this in the wrong section.

      Comment


        #4
        Hello kebabman,

        Thank you for your reply.

        If you set the strategy to run on each tick or On Price Change rather than OnBarClose, it will be able to respond to intrabar movements like the price going back below the SMA in the same bar that you've previously entered long on - what results do you get changing the Calculate setting to On Price Change?

        Thanks in advance; I look forward to assisting you further.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Click image for larger version  Name:	NT strategy error.png Views:	0 Size:	77.0 KB ID:	1099835

          Hi, many thanks for your reply.
          I have spent a lot of time yesterday and another hour today testing out strategies. I have always been using "on each tick" or "on price change" for the calculate setting. I have had "close" selected mostly as everything else is worse. ie I tried both ASK and BID, they didn't work at all.
          There is no "last" available in the drop down list for Price in the conditions window that I can see. Maybe if there was a Last that would fix the problem?
          I am using IB price data for nasdaq micro emini MNQ.
          The strategy fails every time that you get the situation mentioned above, whereby the price momentarily moves out of a short trend, a long gets triggered and in the same bar it goes back to the short side again.
          The strategy will only ever get correct if the market does cross again to the long side AND that bar CLOSES on the long side. Then when the price next goes below the sma a short will be triggered.
          In the screenshot above you can see that the bar I have marked as 1 was short and correctly triggered a long on the white 5 sma line but CLOSED BELOW the sma. This is the problem. Bars 2,3 and four are obviously below the SMA but as you can see the last trade is still long. The strategy is incorrectly losing money fast.
          If when the strategy is still long when it should be short and you unclick and then reclick the enable button the strategy does correct itself and shows as 1S but I think the trade position will still be 1 long.
          Kind regards

          Andrew

          Edit, I see that there is price based upon "Last" in the Properties/data series for some other strategies.
          Last edited by kebabman; 05-15-2020, 07:26 AM.

          Comment


            #6
            Hello kebabman,

            Thank you for your reply.

            I would like to take a look at the code for your strategy. You can either export it from Tools > Export > NinjaScript Add-On and post it here if you're comfortable with that, or if you'd rather not post it publicly you can send it to platformsupport [at] ninjatrader [dot] com. Please include "2556017 ATTN Kate W." in the subject line if you send it by email.

            Thanks in advance; I look forward to assisting you further.
            Kate W.NinjaTrader Customer Service

            Comment


              #7
              Many thanks for your reply. I enclose the file as requested.
              Attached Files

              Comment


                #8
                Hello kebabman,

                Thank you for your reply.

                I've done some testing with this, and it looks like you'd actually want to use greater than and less than instead of CrossAbove and CrossBelow in this case. You can try switching set 1 to use greater, and set 2 to less. Basically, with CrossAbove() and CrossBelow what you're running into is that these look back over the lookback period of the whole bar. When the price repeatedly crosses the SMA it appears that only the first crossover is being registered for the lookback period and other crossovers are being ignored - this may be due to the crosses occurring so quickly that the position hasn't had time to update yet when the next cross occurs. However, using less than and greater than doesn't have a lookback period, so that works to switch the order direction. Give that a try and see if that's closer to what you were looking for.

                Please let us know if we may be of further assistance to you.
                Kate W.NinjaTrader Customer Service

                Comment


                  #9
                  Thank you very much for your reply, I will have a go testing out your correction tomorrow.

                  Kind regards

                  Andrew

                  Comment


                    #10
                    Hi Kate

                    The strategy is now working as it should. Thank you for your time spent helping me out.

                    Many thanks

                    Andrew

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by hazylizard, Today, 08:38 AM
                    2 responses
                    8 views
                    0 likes
                    Last Post hazylizard  
                    Started by geddyisodin, Today, 05:20 AM
                    2 responses
                    17 views
                    0 likes
                    Last Post geddyisodin  
                    Started by Max238, Today, 01:28 AM
                    5 responses
                    47 views
                    0 likes
                    Last Post Max238
                    by Max238
                     
                    Started by giulyko00, Yesterday, 12:03 PM
                    3 responses
                    13 views
                    0 likes
                    Last Post NinjaTrader_BrandonH  
                    Started by habeebft, Today, 07:27 AM
                    1 response
                    16 views
                    0 likes
                    Last Post NinjaTrader_ChristopherS  
                    Working...
                    X