Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Minimum number of trades

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

    Minimum number of trades

    I'm seeking help in the appropriate place (Automated Trading- strategy development) about a suggestion make by another user here :


    Could you please tell me how to insert a code in the fitness test that sets a minimum number of trades?
    I would appreciate this because i have a parameter which is very sensitive and causes extreme curve fitness. Meaning that the percentage of profitable trades increases but the number of trades diminish to about 10%.

    I would like to have a condition that is above the optimization conducted:
    If number of trades is less than 100 then skip and remain optimizing only if tradecount is above 100.

    Has stated im using a custom fitness solution i found on the web so i would only need a line of code i guess to establish this condition.

    Thank You very much

    #2
    Hello hliboi,

    The only way I can see something like this being done is some manually coding and handling of this. So the way that I can think of that you could do this is having a user defined variable that you use for your Order quantity. Now that you have a user defined variable it is possible to optimize this variable.

    Then inside of the script you can use an offset based on your conditions or trade performance to increase or decrease the amount of contracts you are submitting an order for or to not submit an order.

    #Variables
    private int orderSize = 1;

    #Properties
    [Description("")]
    [GridCategory("Parameters")]
    public int OrderSize
    {
    get { return orderSize; }
    set { orderSize = Math.Max(1, value); }
    }

    protected override void OnBarUpdate()
    {
    // checks if OrderSize plus the offset is less than 100 if so do not trade.
    if ( OrderSize + offset < 100 )
    return;

    // Rest of code
    }
    JCNinjaTrader Customer Service

    Comment


      #3
      In the fitness function that you use change the return like this:
      instead of return ...
      put: if (systemPerformance.AllTrades.Count < 100) return 0;
      else return ...

      Comment


        #4
        JC, thanks for the input. Could you explain how that goes into the fitness test?
        Im not getting how that would force the fitness test to consider only optimizations above a certain number of trades.


        Thank You

        Comment


          #5
          Hello hliboi,

          You would still be limited to using the "Optimize on" variables like "max. profit factor" but you could control the contracts that your strategy submits and the offset so if the offset makes the number of contracts fall below your specified amount then you could tell your strategy to not submit an order.
          JCNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by GussJ, 03-04-2020, 03:11 PM
          11 responses
          3,229 views
          0 likes
          Last Post xiinteractive  
          Started by andrewtrades, Today, 04:57 PM
          1 response
          14 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by chbruno, Today, 04:10 PM
          0 responses
          7 views
          0 likes
          Last Post chbruno
          by chbruno
           
          Started by josh18955, 03-25-2023, 11:16 AM
          6 responses
          441 views
          0 likes
          Last Post Delerium  
          Started by FAQtrader, Today, 03:35 PM
          0 responses
          12 views
          0 likes
          Last Post FAQtrader  
          Working...
          X