How to check a converted strategy behaves like the original
A repeatable bar-by-bar method: log signals on both platforms, export them, and compare dates and values instead of trusting net profit.
Compare signals, not profit
Two strategies can show similar net profit with completely different trades, and identical logic can show different profit because of costs. The reliable check is to compare the indicator values and the signal bars directly.
Step 1: expose values in Pine
Plot the key values so they appear in the Data Window, then export chart data (available on TradingView paid plans) or read the values for a sample of dates by hand.
Pine Script
//@version=5
indicator("Debug values")
fast = ta.ema(close, 9)
slow = ta.ema(close, 21)
plot(fast, "fast")
plot(slow, "slow")
plotshape(ta.crossover(fast, slow), "buy", shape.triangleup, location.bottom)Step 2: log the same values in MQL5
Write one CSV line per closed bar from the Strategy Tester. Files written in the tester go to the agent folder under Tester/Agent-.../MQL5/Files.
MQL5
int fh = INVALID_HANDLE;
int OnInit(){
fh = FileOpen("signals.csv", FILE_WRITE | FILE_CSV | FILE_ANSI, ',');
if(fh != INVALID_HANDLE) FileWrite(fh, "time", "fast", "slow", "signal");
return INIT_SUCCEEDED;
}
void OnDeinit(const int r){ if(fh != INVALID_HANDLE) FileClose(fh); }
// call once per new bar with values from the last closed bar
void LogBar(datetime t, double fast, double slow, string signal){
if(fh == INVALID_HANDLE) return;
FileWrite(fh, TimeToString(t, TIME_DATE | TIME_MINUTES),
DoubleToString(fast, _Digits), DoubleToString(slow, _Digits), signal);
}Step 3: compare
Line up both files by bar time in a spreadsheet. Align time zones first: TradingView shows the exchange or your chosen zone, MetaTrader shows broker server time. Small value differences (a few points) come from different data feeds; recursive indicators like EMA also need enough history to converge, so skip the first few hundred bars.
A signal that appears one bar late almost always means the MQL code reads the current forming bar or the wrong shift. A signal that never appears usually means a condition was translated with the wrong comparison or missing state. Fix, re-run, and only then move on to costs and forward testing on a demo account.