Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Dynamic order size

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

    Dynamic order size

    Hello,

    Can you please tell me if the order size of a certain strategy can be modified according to what happened in the previous trades?

    Let me give an example to make myself more clear:

    standard order quantity 10.000 units

    if at the last 2 trades the stop loss was hit, for the third trade I would like that the quantity to be smaller with 20% (8.000 units).

    Can it be done?

    Mitnick

    #2
    Yes this can be done. You would need to use your own tracking variable for quantity but you can use the following as a good example for tracking performance



    Along with looking at the above example, I'd suggest also looking at the help guide links in the post as well.

    Let me know if I can further assist.
    LanceNinjaTrader Customer Service

    Comment


      #3
      Unfortunately, I am not much of a coder... For example purposes I placed the orders on a simple MA cross strategy

      I set some conditions, but:

      1. it executes only the last one ( EnterShort(100000, "") )
      2. what condition should I use in order for the strategy to use only the most recent consecutive losses

      Thank you in advance!

      protected override void OnBarUpdate()
      {
      // Condition set 1
      if (CrossBelow(SMA(5), SMA(14), 1))


      if(Performance.AllTrades.TradesPerformance.MaxCons ecLoser > 4);
      if(Performance.AllTrades.TradesPerformance.GrossLo ss > 601);
      if(Performance.AllTrades.TradesPerformance.GrossLo ss < 700);
      {
      EnterShort(70000, "");
      }

      if(Performance.AllTrades.TradesPerformance.MaxCons ecLoser > 3);
      if(Performance.AllTrades.TradesPerformance.GrossLo ss > 500);
      if(Performance.AllTrades.TradesPerformance.GrossLo ss < 600);
      {
      EnterShort(80000, "");
      }


      if(Performance.AllTrades.TradesPerformance.MaxCons ecLoser > 2);
      if(Performance.AllTrades.TradesPerformance.GrossLo ss > 301);
      if(Performance.AllTrades.TradesPerformance.GrossLo ss < 400);
      {
      EnterShort(90000, "");
      }

      {
      EnterShort(100000, "");
      }


      }

      Comment


        #4
        Hello Mitnick,

        Thank you for your response.

        1. The strategy is likely not entering more than once per the EntriesPerDirection setting of 1 (by default).
        You can change this in your code with the following:
        Code:
        protected override void Initialize() 
        { 
            EntriesPerDirection = 4;
        2. There is no method to pull the most recent consecutive losers, you will need create your own logic to manage this using the Trade Collection values at the following link: http://www.ninjatrader.com/support/h...collection.htm

        Please let me know if I may be of further assistance.

        Comment


          #5
          I ordered it to a developer and solved the case.

          Thank you Lance and Patrick for your support!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by wzgy0920, 04-20-2024, 06:09 PM
          2 responses
          26 views
          0 likes
          Last Post wzgy0920  
          Started by wzgy0920, 02-22-2024, 01:11 AM
          5 responses
          32 views
          0 likes
          Last Post wzgy0920  
          Started by wzgy0920, Yesterday, 09:53 PM
          2 responses
          49 views
          0 likes
          Last Post wzgy0920  
          Started by Kensonprib, 04-28-2021, 10:11 AM
          5 responses
          192 views
          0 likes
          Last Post Hasadafa  
          Started by GussJ, 03-04-2020, 03:11 PM
          11 responses
          3,234 views
          0 likes
          Last Post xiinteractive  
          Working...
          X