指定
The important part of the project is the auto-optimization of the entry conditions using the System Quality Number Score as the optimization criteria.
I am not concerned about the profitability because the rule below are bogus. The focus is on the auto-optimization.
You may use your own auto-optimization function or you can use the following link as an excellent starting point:
https://www.mql5.com/en/code/19392
I'd be grateful if the code can be sufficiently commented to allow me to navigate the code. Where possible can the code be structured as per entry conditions and orders below.
Strategy Pseudo Code
S&P 500
Spread: 40.0, Min distance of stop from price: 40.0
--------------------------------------------------------------------
====================================================================
== Entry conditions - a and b denote unique parameters
====================================================================
LongEntryCondition = (((High(3a) < High(5a)) And (High(19a) < EMA(29a))) And ((High(19a) Crosses Below EMA(26a)) And (High(11a) > High(16a))))
ShortEntryCondition = (((Low(3b) > Low(5b)) And (Low(19b) > EMA(29b))) And ((Low(19b) Crosses Above EMA(26b)) And (Low(11b) < Low(16b))))
====================================================================
== Entry orders
====================================================================
-- Long entry
if LongEntryCondition is true {
Reverse existing order (if any) and Buy on open at Market;
Stop Loss = (6.23 * ATR(57)) pips;
Profit Target = (20.280001 * ATR(46)) pips;
}
-- Short entry
if ShortEntryCondition is true {
Reverse existing order (if any) and Sell on open at Market;
Stop Loss = (6.23 * ATR(57)) pips;
Profit Target = (20.280001 * ATR(46)) pips;
}
Optimization Criteria
Tharp’s SQN Score (System Quality Number Score)
SQN (System Quality Number) performance metrics developed by Van Tharp, it is the measure of the quality of a trading system.
You can find more at: http://www.vantharp.com/tharp-concepts/sqn.asp
Standard interpretation of SQN is:
Score: 1.6 – 1.9 Below average, but trade-able
Score: 2.0 – 2.4
Average Score: 2.5 – 2.9
Good Score: 3.0 – 5.0
Excellent Score: 5.1 – 6.9
Superb Score: 7.0
SQN Score (System Quality Number Score) just like in case of R-Expectancy, SQN doesn't consider the length of testing period and number of trades produced.
In fact it is more favorable for systems that produce more trades, without considering the length of the testing period. It is computed as: SQN * (averageTradesPerYear / 100)