How to male the correction?

 

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("");

  }


 
Robert Milovic:

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("");
  }
 
Lorentzos Roussos #:

You don't need the first function , iSeries are not like copy buffers

Thanks,

 But I got this error message:

'cPair' cannot convert to ENUM

string TestPrice_(string, ENUM_TIMEFRAMES)

 

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)

 
RundesZweieck #:

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!

 
Robert Milovic #:

Thanks,

 But I got this error message:

'cPair' cannot convert to ENUM

string TestPrice_(string, ENUM_TIMEFRAMES)

flip the values around on your call , the pair first the timeframe second 

TestPrice_("EURUSD",PERIOD_D1);
 
Lorentzos Roussos #:

flip the values around on your call , the pair first the timeframe 

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("");

  }


 
which error? I need a little more information ^^