Custom Optimization Criteria (TakeProfit and StopLoss)

26 Feb 2015, 01:20Custom Optimization Criteria (TakeProfit and StopLoss)#1
Carlos Duarteposts: 38since: 16 Jan 2015
Know tell me that it is correct ?
I wish the takeprofit and the stoploss function as selection criteria

 

 protected override double GetFitness(GetFitnessArgs args)
        {
            //maximize count of winning trades and minimize count of losing trades
            return (args.NetProfit * args.WinningTrades * TakeProfit) / (args.MaxEquityDrawdownPercentages * StopLoss);
        }

 


Robots do not cry!
26 Feb 2015, 03:31#2
Carlos Duarteposts: 38since: 16 Jan 2015
I discovered how powerful custom criteria .
The example below was exactly what I was looking for optimization.
Test and tell me what you think ?

 

protected override double GetFitness(GetFitnessArgs args)
        {
            //maximize count of winning trades and minimize count of losing trades
            return (Math.Pow(args.NetProfit, 3) * Math.Pow(args.WinningTrades, 2) * TakeProfit) / (Math.Pow(args.MaxEquityDrawdownPercentages, 2) * Math.Pow(StopLoss, 2) * args.MaxEquityDrawdown);
            //return (args.NetProfit * args.WinningTrades) / (args.MaxEquityDrawdownPercentages * StopLoss);
        }

 


Robots do not cry!
26 Feb 2015, 13:30#3
Carlos Duarteposts: 38since: 16 Jan 2015

Always found problems in optimization keep Takprofit greater than the stoploss and still have a consistent gain. The modification below by dividing the (takeprofit / stoploss), he seeks the best results tend to keep esssa major / minor relationship. And put the end to keep both (if possible) lower, as in my case use in M15.

It Works ...


Robots do not cry!
26 Feb 2015, 13:30#4
Carlos Duarteposts: 38since: 16 Jan 2015
protected override double GetFitness(GetFitnessArgs args)
        {
            //maximize count of winning trades and minimize count of losing trades
            return (Math.Pow(args.NetProfit, 3) * Math.Pow(args.WinningTrades, 2) * (TakeProfit/StopLoss)) / (Math.Pow(args.MaxEquityDrawdownPercentages, 2) * TakeProfit * StopLoss * args.MaxEquityDrawdown);
            //return (args.NetProfit * args.WinningTrades) / (args.MaxEquityDrawdownPercentages * StopLoss);
        }

 


Robots do not cry!
27 Feb 2015, 15:10#5
modarkatposts: 47since: 25 Dec 2013

There are other interesting functions you can implement in GetFitness:

http://tradinggame.com.au/introduction-to-backtesting-metrics-part-2/

My favorite one is PROM.

 

28 Feb 2015, 05:16RE:#6
Carlos Duarteposts: 38since: 16 Jan 2015

Thanks for the info. Looking more about it, I found this code.
I will implement it as a test.

modarkat said:

There are other interesting functions you can implement in GetFitness:

http://tradinggame.com.au/introduction-to-backtesting-metrics-part-2/

My favorite one is PROM.

 

 


Robots do not cry!
28 Feb 2015, 05:16#7
Carlos Duarteposts: 38since: 16 Jan 2015
// MultiCharts Custom Criteria: Pessimistic Return on Margin (PROM) by Robert Pardo

// Change the value below to your account size
var AccountSize = 10000;

/* The code below can be left untouched  */

// check for errors / wrong values
if (AccountSize < 1 || StrategyPerformance.WinningTrades == 0 ||
    StrategyPerformance.LosingTrades == 0) {
    return 0;
}

var sqrtWins = Math.sqrt(StrategyPerformance.WinningTrades);
var sqrtLosses = Math.sqrt(StrategyPerformance.LosingTrades);

return ( ((StrategyPerformance.AvgWinningTrade * (StrategyPerformance.WinningTrades - sqrtWins) ) -
    ( -StrategyPerformance.AvgLosingTrade * (StrategyPerformance.LosingTrades + sqrtLosses) )) /
    AccountSize) * 100;

 


Robots do not cry!
25 Nov 2015, 20:56RE:#8
prof.edson.nascimentoposts: 1since: 25 Nov 2015

How I call this method and what arguments I will put to them?

protected override double GetFitness(GetFitnessArgs args)

cjdduarte said:

I discovered how powerful custom criteria .
The example below was exactly what I was looking for optimization.
Test and tell me what you think ?

 

protected override double GetFitness(GetFitnessArgs args)
        {
            //maximize count of winning trades and minimize count of losing trades
            return (Math.Pow(args.NetProfit, 3) * Math.Pow(args.WinningTrades, 2) * TakeProfit) / (Math.Pow(args.MaxEquityDrawdownPercentages, 2) * Math.Pow(StopLoss, 2) * args.MaxEquityDrawdown);
            //return (args.NetProfit * args.WinningTrades) / (args.MaxEquityDrawdownPercentages * StopLoss);
        }

 

 

25 Nov 2015, 23:26#9
cTrader Teamposts: 3396since: 23 Sep 2013

Dear Trader,

Please have a look at the Optimization Criteria section of cAlgo support site.


TRADERS FIRST™ Vote for your favorite features: http://vote.spotware.com/
02 Dec 2016, 10:56RE:#10
davidp13posts: 72since: 06 May 2014

Hi. How will you go about calculating the AvgWinning or AvgLosing trade?

cjdduarte said:

// MultiCharts Custom Criteria: Pessimistic Return on Margin (PROM) by Robert Pardo

// Change the value below to your account size
var AccountSize = 10000;

/* The code below can be left untouched  */

// check for errors / wrong values
if (AccountSize < 1 || StrategyPerformance.WinningTrades == 0 ||
    StrategyPerformance.LosingTrades == 0) {
    return 0;
}

var sqrtWins = Math.sqrt(StrategyPerformance.WinningTrades);
var sqrtLosses = Math.sqrt(StrategyPerformance.LosingTrades);

return ( ((StrategyPerformance.AvgWinningTrade * (StrategyPerformance.WinningTrades - sqrtWins) ) -
    ( -StrategyPerformance.AvgLosingTrade * (StrategyPerformance.LosingTrades + sqrtLosses) )) /
    AccountSize) * 100;