Here is a way to get the value of another pair in order to compare it with the current pair during the backtesting.
Register the wanted pair and timeframe chart in tester/files with the .csv format (for example GBPUSD15.csv).
Then in the code, after the extern parameters, add :
In the start function, add :Code:datetime time0; datetime daterewritten; string date; string time; double open; double high; double low; double close; double volume;
Code:int handle; string filename="GBPUSD15.csv"; handle=FileOpen(filename,FILE_READ|FILE_CSV,","); if(handle==-1 || FileSize(handle)==0)return; if(handle<0){ if(GetLastError()==4103){ Alert("No file named ",filename); } else{ Alert("Error while opening file ",filename); return; } } if(time0!=Time[0]){ while(!FileIsEnding(handle)){ if(Time[1]==daterewritten)break; date=FileReadString(handle,10); time=FileReadString(handle,5); open=FileReadNumber(handle); high=FileReadNumber(handle); low=FileReadNumber(handle); close=FileReadNumber(handle); volume=FileReadNumber(handle); daterewritten=StrToTime(date+" "+time); } time0=Time[0]; } if(handle!=-1)FileClose(handle); Comment( "\ndate = "+date, "\ntime = "+time, "\nopen = "+DoubleToStr(open,5), "\nhigh = "+DoubleToStr(high,5), "\nlow = "+DoubleToStr(low,5), "\nclose = "+DoubleToStr(close,5), "\nvolume = "+DoubleToStr(volume,0), "\ndaterewritten = "+DoubleToStr(daterewritten,0), "\ncurrenttime = "+DoubleToStr(Time[1],0));



Reply With Quote
