Download MetaTrader 5
To add comments, please log in or register
The entire MQL5.community history on a single page!
Dan
31
Dan 2014.07.23 20:02 

Hey everybody,

I try to create a little output into the expert log on MT4.

What I do:

int start() {

int i;

for (i=0; i<=2; i++) {

double lB_EURJPY_D = iBands("EURJPY",PERIOD_D1,20,2,i,PRICE_CLOSE,MODE_LOWER,0);

double uB_EURJPY_D = iBands("EURJPY",PERIOD_D1,20,2,i,PRICE_CLOSE,MODE_UPPER,0); 

//Print

Print("$","EURJPY D","$",Time[i],"$",DoubleToString(lB_EURJPY_D,1),"$",DoubleToString(uB_EURJPY_D,1),

      "$",DoubleToString(Low[i],1)

      );

}; 

Print("EURJPY D ready");  

// EURUSD D

for (i=0; i<=2; i++) {

double lB_EURUSD_D = iBands("EURUSD",PERIOD_D1,20,2,i,PRICE_CLOSE,MODE_LOWER,0);

double uB_EURUSD_D = iBands("EURUSD",PERIOD_D1,20,2,i,PRICE_CLOSE,MODE_UPPER,0);

//Print

Print("$","EURUSD D","$",Time[i],"$",DoubleToString(lB_EURUSD_D,1),"$",DoubleToString(uB_EURUSD_D,1),

      "$",DoubleToString(Low[i],1)

      );

     };

Print("EURUSD D ready");                     

return(0);

 

What I get: 

22:00:45 Custom indicator _FULL_Output_Daily_2 GBPAUD,Daily: loaded successfully

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: initialized

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: $EURJPY D$2014.07.23 00:00:00$136.4$139.6$1.8

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: $EURJPY D$2014.07.22 00:00:00$136.6$139.6$1.8

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: $EURJPY D$2014.07.21 00:00:00$136.9$139.5$1.8

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: EURJPY D ready

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: $EURUSD D$2014.07.23 00:00:00$1.3$1.4$1.8

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: $EURUSD D$2014.07.22 00:00:00$1.3$1.4$1.8

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: $EURUSD D$2014.07.21 00:00:00$1.4$1.4$1.8

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: EURUSD D ready

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: $EURJPY D$2014.07.23 00:00:00$136.4$139.6$1.8

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: $EURJPY D$2014.07.22 00:00:00$136.6$139.6$1.8

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: $EURJPY D$2014.07.21 00:00:00$136.9$139.5$1.8

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: EURJPY D ready

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: $EURUSD D$2014.07.23 00:00:00$1.3$1.4$1.8

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: $EURUSD D$2014.07.22 00:00:00$1.3$1.4$1.8

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: $EURUSD D$2014.07.21 00:00:00$1.4$1.4$1.8

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: EURUSD D ready

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: $EURJPY D$2014.07.23 00:00:00$136.4$139.6$1.8

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: $EURJPY D$2014.07.22 00:00:00$136.6$139.6$1.8

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: $EURJPY D$2014.07.21 00:00:00$136.9$139.5$1.8

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: EURJPY D ready

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: $EURUSD D$2014.07.23 00:00:00$1.3$1.4$1.8

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: $EURUSD D$2014.07.22 00:00:00$1.3$1.4$1.8

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: $EURUSD D$2014.07.21 00:00:00$1.4$1.4$1.8

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: EURUSD D ready 

 Can anybody tell me why do I get the right output but 3 times? For me it looks strange ...

Thanks for any help

Hilfx 

Keith Watford
Moderator
7906
Keith Watford 2014.07.23 20:40  
hilfx:

Hey everybody,

I try to create a little output into the expert log on MT4.

 Can anybody tell me why do I get the right output but 3 times? For me it looks strange ...

Thanks for any help

Hilfx 

I'm not sure what your question is about

You get 3 prints because of

for (i=0; i<=2; i++)

 It looks strange because you are only printing 1 decimal place

DoubleToString(lB_EURJPY_D,1)

 Change to

DoubleToString(lB_EURJPY_D,3)

 and EURUSD to 5 decimal places

whroeder1
13610
whroeder1 2014.07.24 00:20  
GumRai:It looks strange because you are only printing 1 decimal place

 Change to

DoubleToString(lB_EURJPY_D,3)

 and EURUSD to 5 decimal places

Don't hard code numbers
string   PriceToStr(double p){   return( DoubleToStr(p, Digits) ); }
Keith Watford
Moderator
7906
Keith Watford 2014.07.24 02:33  
WHRoeder:
GumRai:It looks strange because you are only printing 1 decimal place

 Change to

DoubleToString(lB_EURJPY_D,3)

 and EURUSD to 5 decimal places

Don't hard code numbers
string   PriceToStr(double p){   return( DoubleToStr(p, Digits) ); }



My suggestion was a simple fix for the OP's code as I didn't want to complicate it with MarketInfo and Digits.

Your suggestion will simply Print using the Digits for the chart symbol that the EA/indicator is attached to 

Dan
31
Dan 2014.07.24 10:43  
GumRai:

I'm not sure what your question is about

You get 3 prints because of

 It looks strange because you are only printing 1 decimal place

 Change to

 and EURUSD to 5 decimal places

 

Thanks for your answers. I exprect to get this output

 

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: $EURJPY D$2014.07.23 00:00:00$136.4$139.6$1.8

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: $EURJPY D$2014.07.22 00:00:00$136.6$139.6$1.8

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: $EURJPY D$2014.07.21 00:00:00$136.9$139.5$1.8

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: EURJPY D ready

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: $EURUSD D$2014.07.23 00:00:00$1.3$1.4$1.8

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: $EURUSD D$2014.07.22 00:00:00$1.3$1.4$1.8

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: $EURUSD D$2014.07.21 00:00:00$1.4$1.4$1.8

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: EURUSD D ready

The numbers of decimals doesn't matter. But why do I get my exprected output 3 times?

Dan
31
Dan 2014.07.24 10:47  
GumRai:

I'm not sure what your question is about

You get 3 prints because of

 It looks strange because you are only printing 1 decimal place

 Change to

 and EURUSD to 5 decimal places

 

Thanks for your answer. The decimal places doesn't matter in this case. I exprect to get 3 prints but only one time. Why do I get 8 lines? Actually there must be 6 (3 for EURJPY and 3 for EURUSD).

I don't know, its a limple for-loop but the output is wrong ... 

Keith Watford
Moderator
7906
Keith Watford 2014.07.24 10:53  
hilfx:

Thanks for your answers. I exprect to get this output

 

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: $EURJPY D$2014.07.23 00:00:00$136.4$139.6$1.8

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: $EURJPY D$2014.07.22 00:00:00$136.6$139.6$1.8

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: $EURJPY D$2014.07.21 00:00:00$136.9$139.5$1.8

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: EURJPY D ready

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: $EURUSD D$2014.07.23 00:00:00$1.3$1.4$1.8

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: $EURUSD D$2014.07.22 00:00:00$1.3$1.4$1.8

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: $EURUSD D$2014.07.21 00:00:00$1.4$1.4$1.8

22:00:46 _FULL_Output_Daily_2 GBPAUD,Daily: EURUSD D ready

The numbers of decimals doesn't matter. But why do I get my exprected output 3 times?


Ah, I see, you mean why is your code repeated 3 times.

Maybe there were 3 ticks?

Is this a script? 

Dan
31
Dan 2014.07.24 10:57  
GumRai:


Ah, I see, you mean why is your code repeated 3 times.

Maybe there were 3 ticks?

Is this a script? 

 

No, its an indicator and I turned the chart offline, otherwise I'll get the output on every new tick. I simply wanna have some historic data for analysis.
Dan
31
Dan 2014.07.24 15:28  
I did it run as a script and its working :-) Thanks to you guys for help!
/
To add comments, please log in or register