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

Multiple Trades at one price

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

    Multiple Trades at one price

    Hello everyone,

    first of all, my strategy in the strategy builder already says, "only one trade per direction".

    And, the higher I go with the minutes in the chart, the more I get this error.

    Is there a way in the strategy builder to say him, he has to do one trade per 10 minutes or similar?
    Or can I really say at another option, that he has to do really one trade...?

    I searched in the forum about this topic but found nothing useful...sorry.

    Thank you very much,
    Andi

    #2
    Here is the error.
    Attached Files

    Comment


      #3
      Hello andi5385,

      Thanks for your post.

      Is your strategy being run on live data, replay data, or Strategy analyzer data?

      Is your strategy using Calculate.OnBarClose, Calculate.OnEachTick, or Calculate.OnpriceChange?

      Are you wanting to limit your trades to no more than 1 per bar?
      Paul H.NinjaTrader Customer Service

      Comment


        #4
        Hello Paul,
        thank you for your quick answer.

        - My strategy runs on a live CQG-Connection in Global Simulation Mode
        - My strategy uses Calculate on each tick

        Perhaps this is the solution, to limit my trades to no more than 1 bar, how can I do that in the strategy builder?

        Have a good day,
        Andi

        Comment


          #5
          Hello andi5385,

          Thanks for your reply.

          Correct, Calculate.OnEachTick will cause your strategy conditions to be true many times per bar and as you have seen will submit more than intended orders. The strategy executes far faster than the time it takes for the orders to be transmitted/received and acknowledged by the exchange so the protective features of 'Entries per direction" will not help until the first order is acknowledged which in the case of Calculate.OnEachTick or Calculate.OnPriceChange, will too slow.

          You can limit the trades to one per bar by creating an int variable (for example named "EntryBar") and using it to test against the current bar as an entry condition. If they are the same then no entry occurs if they are different then that means no previous entry has occurred on that bar. As this is logic it will operate as quickly as your code.

          In each Entry set, add the condition Misc>Current bar, NOT equal, User Variables>EntryBar
          In each Entry set, add the action User Variable>Entry bar, click "set", select Misc>Curent bar - this assigns the current bar to the entry bar variable.

          Note: If you have multiple entry sets, you may want to create additional EntryBar int type variables (with different names) to keep things organized.
          Paul H.NinjaTrader Customer Service

          Comment


            #6
            Paul, thank you very much. I will try this!

            Comment


              #7
              Sorry Paul, but after your Strategy Builder tipps, I already get the same error of multiple trades.
              Did I do something wrong?
              Please see the attached screenshots for infos, thank you very much.
              Attached Files

              Comment


                #8
                Hello andi5385,

                Thanks for your reply.

                You created the condition correctly. the issue is with the action.

                You have entrybar = entrybar and you want entrybar = CurrentBar as this is where you set the current bar to the entry bar on the very first order (on that bar).

                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  Sorry Paul, I did something wrong in the actions. Attached you find the correct action, thank you very much for your great help! Now it works!
                  Attached Files

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by funk10101, Today, 09:43 PM
                  0 responses
                  2 views
                  0 likes
                  Last Post funk10101  
                  Started by pkefal, 04-11-2024, 07:39 AM
                  11 responses
                  36 views
                  0 likes
                  Last Post jeronymite  
                  Started by bill2023, Yesterday, 08:51 AM
                  8 responses
                  44 views
                  0 likes
                  Last Post bill2023  
                  Started by yertle, Today, 08:38 AM
                  6 responses
                  25 views
                  0 likes
                  Last Post ryjoga
                  by ryjoga
                   
                  Started by algospoke, Yesterday, 06:40 PM
                  2 responses
                  24 views
                  0 likes
                  Last Post algospoke  
                  Working...
                  X