Backtesting Libraries in MQL5

 
Given OHLC price data and a trading strategy,  we can evaluate how profitable the strategy is. We could run a historical back test in MQL5 or if you have the data in CSV format you could use a library in Python or R to backtest your strategy. 

But how is this being done under the hood? 

I want to create an expert advisor that starts by looking back and assessing if it would've been profitable in the past under its curret settings (backtesting itself) before opening a single trade. If profitable in the past under its current settings it would tell the user "Everything is fine" and then begin trading, otherwise it will tell the user "The current settings probably aren't profitable" and call the expert remove function.

I'd like to know what's a smart way of approaching this problem, do you know any MQL5 backtesting libraries in the code base?
 

?

Indicators are looking back and previous quotes can be requested by e.g. CopyRates.