To put it nicely... everything.
We all got to start somewhere, so it's cool, but not going to lie this looks like some AI generated BS.
Your GetSARValue() function is defined as: double GetSARValue(string cPair, int nPeriod, int bar)
But when you're calling it in TestSAR(): nResultSAR = GetSARValue(cPair, nTimeFrame1, Step, Maximum, 0);
GetSARValue is missing needed parameters:
double GetSARValue(string cPair, int timeframe, double step, double max, int bar) { double sar[1]; int sarHandle = iSAR(cPair, timeframe, step, max); if(sarHandle != INVALID_HANDLE) { if(CopyBuffer(sarHandle, 0, bar, 1, sar) != 1) return(EMPTY_VALUE); // handle error } else return(EMPTY_VALUE); // handle error return(sar[0]); }
You're passing nPeriod in both functions but never using it.
Global variables like nTimeFrame1, Step, Maximum must be defined.
TestSAR is incorrect.
string TestSAR(string cPair, int timeframe, double step, double max) { double nResultClose = iClose(cPair, timeframe, 0); double nResultSAR = GetSARValue(cPair, timeframe, step, max, 0); if(nResultSAR == EMPTY_VALUE) return("NO SIGNAL"); // error case if(nResultClose < nResultSAR) return("SELL"); if(nResultClose > nResultSAR) return("BUY"); return(""); }
The correct code should look like:
//+------------------------------------------------------------------+ //| GetSARValue: Returns SAR value for a given pair and bar | //+------------------------------------------------------------------+ double GetSARValue(string cPair, int timeframe, double step, double max, int bar) { double sar[1]; int sarHandle = iSAR(cPair, timeframe, step, max); if(sarHandle != INVALID_HANDLE) { if(CopyBuffer(sarHandle, 0, bar, 1, sar) == 1) return sar[0]; else Print("CopyBuffer failed for SAR."); } else { Print("Failed to create SAR handle."); } return EMPTY_VALUE; } //+------------------------------------------------------------------+ //| TestSAR: Compares current close with SAR and returns signal | //+------------------------------------------------------------------+ string TestSAR(string cPair, int timeframe, double step, double max) { double nResultClose = iClose(cPair, timeframe, 0); double nResultSAR = GetSARValue(cPair, timeframe, step, max, 0); if(nResultSAR == EMPTY_VALUE) return "NO SIGNAL"; if(nResultClose < nResultSAR) return "SELL"; if(nResultClose > nResultSAR) return "BUY"; return ""; } //+------------------------------------------------------------------+ //| Example usage | //+------------------------------------------------------------------+ void OnStart() // Use OnTick() if you're in an EA rather than indicator. { string signal = TestSAR("EURUSD", PERIOD_H1, 0.02, 0.2); Print("Signal: ", signal); }
As noted above, change OnStart to OnTick if you're coding an EA rather than indicator.
Bonjour. Svp je n'arrive pas à lier mon compte live (21285171) au serveur. Bien vouloir m'aider. Merci.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
for the ParSar: