Specification
Hi All,
I want to create an equity indicator similar to this one here : https://www.mql5.com/ru/code/8588
1--The indicator should have the correlation between the equity curve generated by a trading system and the "ideal" equity curve based on past N trades .The ideal
equity curve based on equity curve of non repaintinting zigzag the idea from here : http://www.breakoutfutures.com/Newsletters/Newsletter0605.htm
2- The indicator will have the Trade Equity Regression Trend Line Coefficient of Correlation for both past n trades AND open positions: see the article https://www.mql5.com/en/articles/1492 From the article ,I think below is the code of what I am looking for I am not too sure :
Sx=Summ{(X-M(X))^2}/N Sy=Summ{(Y-M(Y))^2}/N r=cov(X,Y)/(Sx* Sy)
where:
N - amount of trades (including the open trades);
X - Balance;
Y - linear regression;
M(X) - Balance mean value;
M(Y) - LR mean value.
The threshold of equity line deviation from a linear regression trend line should be >0,6 for example Bobsley LR correlation 0,44 https://championship.mql5.com/2010/ru/users/bobsley/reports
3-The indicator should have Profit Factor >2 threshold for both past N trades AND open positions.
4- The indicator should have the efficiency ratio of entry- exit see Bulashev stats https://www.mql5.com/en/articles/137 and here https://championship.mql5.com/2010/en/news/42?source=terminal03.11.10
I think code part is here :
//+------------------------------------------------------------------+
//| calculation of effectiveness |
//+------------------------------------------------------------------+
void C_Pos::efficiency()
{
for(int i=0;i<count_trades;i++)
{
m_trades_stats[i].max_price_trade=iHighest(symbol,PERIOD_M1,m_trades_stats[i].enter_date,m_trades_stats[i].exit_date); // maximal price of trade
m_trades_stats[i].min_price_trade=iLowest(symbol,PERIOD_M1,m_trades_stats[i].enter_date,m_trades_stats[i].exit_date); // minimal price of trade
double minimax=0;
minimax=m_trades_stats[i].max_price_trade-m_trades_stats[i].min_price_trade;// difference between maximum and minimum
if(minimax!=0)minimax=1.0/minimax;
if(m_trades_stats[i].trade_type==DEAL_TYPE_BUY)
{
//Effectiveness of entering a position
m_trades_stats[i].enter_efficiency=(m_trades_stats[i].max_price_trade-m_trades_stats[i].enter_price)*minimax;
//Effectiveness of exiting from a position
m_trades_stats[i].exit_efficiency=(m_trades_stats[i].exit_price-m_trades_stats[i].min_price_trade)*minimax;
//Effectiveness of trade
m_trades_stats[i].trade_efficiency=(m_trades_stats[i].exit_price-m_trades_stats[i].enter_price)*minimax;
}
else
{
if(m_trades_stats[i].trade_type==DEAL_TYPE_SELL)
{
//Effectiveness of entering a position
m_trades_stats[i].enter_efficiency=(m_trades_stats[i].enter_price-m_trades_stats[i].min_price_trade)*minimax;
//Effectiveness of exiting from a position
m_trades_stats[i].exit_efficiency=(m_trades_stats[i].max_price_trade-m_trades_stats[i].exit_price)*minimax;
//Effectiveness of trade
m_trades_stats[i].trade_efficiency=(m_trades_stats[i].enter_price-m_trades_stats[i].exit_price)*minimax;
}
}
}
}
Good clean fast code appriciated.Price negotiable