heiken ashi ea problem - page 2

 
   if((haHandle=iCustom(_Symbol, _Period, "::Indicators\\heiken_ashi.ex5")) == INVALID_HANDLE)
 
Andrea Di # :


You have an error in OnInit:

   if(haHandle=iCustom(_Symbol, _Period, "::Indicators\\heiken_ashi.ex5") == INVALID_HANDLE)
      return(INIT_FAILED);
   if(SMA10Handle=iCustom(_Symbol, _Period, "::Indicators\\Examples\\Custom Moving Average.ex5", 10, 0, MODE_SMA) == INVALID_HANDLE)
      return(INIT_FAILED);
   if(SMA30Handle=iCustom(_Symbol, _Period, "::Indicators\\Examples\\Custom Moving Average.ex5", 30, 0, MODE_SMA) == INVALID_HANDLE)
      return(INIT_FAILED);
 
thanks guys! it was a stupid error
 
BTW, you are using the currently running period to make decisions, this period will change its state while running. Depending on how the underlying period forms while open.

You will have inconsistent results.

Either wait for the last quarter or so of the current period, or use one before, since this will not change anymore.

For your info.
 
Dominik Egert #:
BTW, you are using the currently running period to make decisions, this period will change its state while running. Depending on how the underlying period forms while open.

You will have inconsistent results.

Either wait for the last quarter or so of the current period, or use one before, since this will not change anymore.

For your info.
thanks for your advice
 

I still need your help.
I would like to write a report on how many potential pips I could earn and how many pips I actually make or lose.
This piece of code should calculate me how many pips I have in profit or loss:

void updateMaxPipsPotentialGain(double actualPrice, double orderPriceOpen, string typeOfOperation){         
         
         int actualPips;
         double normalized; //normalized double number
         double r; //rounded number
         
         actualPrice = NormalizeDouble(actualPrice, Digits());
         orderPriceOpen = NormalizeDouble(orderPriceOpen, Digits());
         
         if( typeOfOperation == "BUY" ){
            normalized = NormalizeDouble( (actualPrice - orderPriceOpen), Digits());
            actualPips = round(normalized);
         }else if ( typeOfOperation == "SELL" ){
            normalized = NormalizeDouble( (orderPriceOpen - actualPrice), Digits());
            actualPips = round(normalized);
         }
         
         printf("orderPriceOpen=" + orderPriceOpen + 
            " actualPrice=" +  actualPrice + 
            " actualPrice - orderPriceOpen=" +  (actualPrice - orderPriceOpen) + 
            " actualPips=" + actualPips);
         
         if(potentialPipsGain < actualPips ){
            potentialPipsGain = actualPips;            
         }
         
}

even if the trade entry price (orderPriceOpen) and the current market price (actualPrice) are correct, the difference between them sometimes returns me 5.9, 2.0, 9.9 and sometimes 0.005900000-05, 0.002000000-05, 0.009900000-05.(sometimes i get a double and sometimes i get a scientific notation).
I don't understand why this happens, and it happens randomly without changing the code.

Furthermore the operation

double actualPips = (actualPrice - orderPriceOpen);

always return 0.0

if you wish, I add all the files of the project as attachments

thanks for your interest and for your help.

 
William Roeder #:
What do you think that line does?

It not seems correct, actualPrice should be double

the documentation says that NormalizeDouble () converts a float number to a double with decimals as for the second parameter

 
I've updated the #16 message
 

ok i solved the problem of message #16, a stupid problem, i solved it by multiplying it

actualPips = round(normalized * MathPow( 10, Digits() ) );
 

https://charts.mql5.com/31/88/eurusd-m1-metaquotes-software-corp.png

there were 2 weird operations tonight.

as you can see from the chart the ea opened 2 positions at prices that weren't even from the candle spikes.

i am testing the ea in real time and they are the only cases.

yesterday afternoon I downloaded the historical data, does it have something to do with it?

How could that happen?

Reason: