I need the correction for this code as I am getting the error warning:
--------------------------------------------------------------------------------------
double GetPriceValue(string cPair, int nPeriod, int bar)
double price[1];
int priceHandle = iClose(cPair,nTimeFrame1,0);
if(priceHandle!=INVALID_HANDLE)
{
CopyBuffer(priceHandle,0,bar,1,price);
}
return(price[0]);
}
//+------------------------------------------------------------------+
string TestPrice_(int nPeriod string cPair)
{
double nResult1;
double nResult1a;
double nResult2;
double nResult3;
double nResultSUM;
nResult1 = GetPriceValue(cPair,PRICE_CLOSE,0);
nResult1a = GetPriceValue(cPair,PRICE_CLOSE,1);
nResult2 = GetPriceValue(cPair,PRICE_HIGH,0);
nResult3 = GetPriceValue(cPair,PRICE_LOW,0);
nResultSUM = nResult1 + nResult1a - nResult2 - nResult3;
if(nResultSUM < 0)
return("SELL");
if(nResultSUM > 0)
return("BUY");
return("");
}
You don't need the first function , iSeries are not like copy buffers
string TestPrice_(string cPair,ENUM_TIMEFRAMES tf) { double nResult1; double nResult1a; double nResult2; double nResult3; double nResultSUM; /* 0 is the live bar in iSeries 1 is the most recently closed bar in iSeries */ nResult1=iClose(cPair,tf,0); nResult1a =iClose(cPair,tf,1); nResult2 = iHigh(cPair,tf,0); nResult3 = iLow(cPair,tf,0); nResultSUM = nResult1 + nResult1a - nResult2 - nResult3; if(nResultSUM < 0) { return("SELL"); } if(nResultSUM > 0) { return("BUY"); } return(""); }
There is missing a , in the function head.
" string TestPrice_(int nPeriod string cPair)" -> " string TestPrice_(int nPeriod, string cPair)"
How Do you call it? should do it something like that
TestPrice_(varname_string, varname_enum) ;
The definintion should look like that
string TestPrice_(string varname_string, ENUM_TIMEFRAMES varname_enum)
There is missing a , in the function head.
" string TestPrice_(int nPeriod string cPair)" -> " string TestPrice_(int nPeriod, string cPair)"
How Do you call it? should do it something like that
TestPrice_(varname_string, varname_enum) ;
The definintion should look like that
string TestPrice_(string varname_string, ENUM_TIMEFRAMES varname_enum)
Thanks,
That was it, Great!
Thanks,
One more error problem:
double GetMAValue(string cPair,int nPeriod,ENUM_MA_METHOD method,ENUM_APPLIED_PRICE price, int bar)
{
double ma[1];
int maHandle = iMA(cPair,nTimeFrame1,nPeriod,1,method,price);
if(maHandle!=INVALID_HANDLE)
{
CopyBuffer(maHandle,0,bar,1,ma);
}
return(ma[0]);
}
string TestMA_(int nPeriod, string cPair)
{
double nResultMA1;
double nResultMA2;
nResultMA1 = GetMAValue(cPair,nTimeFrame1,MA1,MODE_EMA,PRICE_CLOSE,0);
nResultMA2 = GetMAValue(cPair,nTimeFrame1,MA2,MODE_EMA,PRICE_CLOSE,0);
if(nResultMA1 < nResultMA2 )
return("SELL");
if(nResultMA1 > nResultMA2 )
return("BUY");
return("");
}

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I need the correction for this code as I am getting the error warning:
--------------------------------------------------------------------------------------
double GetPriceValue(string cPair, int nPeriod, int bar)
double price[1];
int priceHandle = iClose(cPair,nTimeFrame1,0);
if(priceHandle!=INVALID_HANDLE)
{
CopyBuffer(priceHandle,0,bar,1,price);
}
return(price[0]);
}
//+------------------------------------------------------------------+
string TestPrice_(int nPeriod string cPair)
{
double nResult1;
double nResult1a;
double nResult2;
double nResult3;
double nResultSUM;
nResult1 = GetPriceValue(cPair,PRICE_CLOSE,0);
nResult1a = GetPriceValue(cPair,PRICE_CLOSE,1);
nResult2 = GetPriceValue(cPair,PRICE_HIGH,0);
nResult3 = GetPriceValue(cPair,PRICE_LOW,0);
nResultSUM = nResult1 + nResult1a - nResult2 - nResult3;
if(nResultSUM < 0)
return("SELL");
if(nResultSUM > 0)
return("BUY");
return("");
}