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 samish18, Today, 12:20 PM
          0 responses
          3 views
          0 likes
          Last Post samish18  
          Started by thread, 04-15-2024, 11:58 PM
          3 responses
          48 views
          0 likes
          Last Post Georg1o
          by Georg1o
           
          Started by leojimenezp, 04-20-2024, 05:49 PM
          4 responses
          47 views
          0 likes
          Last Post leojimenezp  
          Started by nicthe, Today, 09:24 AM
          1 response
          5 views
          0 likes
          Last Post nicthe
          by nicthe
           
          Started by samish18, Today, 10:13 AM
          0 responses
          6 views
          0 likes
          Last Post samish18  
          Working...
          X