Getting nut

 

Hello!


I am starting to get nut here, my problem is the following:

void CalcolaMaxMinPrice(int numCandele)

  {

   int highestIndex = iHighest(Symbol(), PERIOD_CURRENT, MODE_HIGH, numCandele, 0);

   int lowestIndex = iLowest(Symbol(), PERIOD_CURRENT, MODE_LOW, numCandele, 0);

   maxPrice = iHigh(Symbol(), PERIOD_CURRENT, highestIndex);

   minPrice = iLow(Symbol(), PERIOD_CURRENT, lowestIndex);

  }

void OnTick()
  {
      candele = Candle_function(Symbol());
      CalcolaMaxMinPrice(candele);


So basically, 

when i manually put a number int inside the following line instead of numCandele, the EA works, it open positions but if I let a function to put the number instead, it wont work.

int highestIndex = iHighest(Symbol(), PERIOD_CURRENT, MODE_HIGH, numCandele, 0);

I Printed everywhere the value of numCandele before using it and it works great, but as soon as i put it inside:

iHighest(Symbol(), PERIOD_CURRENT, MODE_HIGH, numCandele, 0);

it stop working.

Here is another code who does the same thing with the same result...

void CalcolaMaxMinPrice(string symbol)

  {

  candele = Candle_function(Symbol());


   maxPrice = iHigh(Symbol(), PERIOD_CURRENT, iHighest(Symbol(), PERIOD_CURRENT, MODE_HIGH, candele, 0));

   minPrice = iLow(Symbol(), PERIOD_CURRENT, iLowest(Symbol(), PERIOD_CURRENT, MODE_LOW, candele, 0));


  }

I even tried this:

double maxPrice(string symbol)
{
   maxPrice = 0;
   for (int i = 0; i < candele; i++)
   {
      double AskPrice = iHigh(symbol, PERIOD_CURRENT, iHighest(symbol, PERIOD_CURRENT, MODE_HIGH, candele, i));
      if (AskPrice > maxPrice)
      {
         maxPrice = AskPrice;
      }
   }
   return maxPrice;
}

double minPrice(string symbol)
{
   minPrice = iLow(symbol, PERIOD_CURRENT, iLowest(symbol, PERIOD_CURRENT, MODE_LOW, candele, 0));
   for (int i = 0; i < candele; i++)
   {
      double BidPrice = iLow(symbol, PERIOD_CURRENT, iLowest(symbol, PERIOD_CURRENT, MODE_LOW, candele, i));
      if (BidPrice < minPrice)
      {
         minPrice = BidPrice;
      }
   }
   return minPrice;
}

void CalcolaMaxMinPrice(string symbol)
{
   maxPrice = maxPrice(symbol);
   minPrice = minPrice(symbol);
   Print("maxPrice ", maxPrice);
   Print("minPrice ", minPrice);
}