You declare max and min but don't define them (MQL4 will do this by default but it is bad practice to rely on this)
min need to be initialized to something big in order for the code to work.
You test the same bars every tick, which is wasteful. You would be better to test only once per bar.
You declare max and min but don't define them (MQL4 will do this by default but it is bad practice to rely on this)
min need to be initialized to something big in order for the code to work.
You test the same bars every tick, which is wasteful. You would be better to test only once per bar.
Thank you for giving me the solution. Now it is working correctly. When I initialised a big value to 4 it worked.
thank you
#define INF 0x6FFFFFFF // Not quite infinite, Jul 2029, or 1,879,048,191
0x6FFFFFFF
0x7FFFFFFF
which is the biggest positive 32 bit integer?
sunilkumarks46:
The integer k is defined earlier to start function.
Such loop variables should be defined local. Generally you should make everything always local unless you absolutely need it global and even then there often might be a solution to make many of these things local too.
Noted your advice, thank you
I could see the results of my EA only for one day even though I select 30 days date range in mt4 strategy tester. I have to select each date in mt4 and run this Ea by clicking the start button for seeing results for 30 days. I am getting the result only for the first day even if I select 30 days range. I have used STATIC variables in my EA. Any solution for this?
double bar3,bar2,bar1; double TH3,BL3,TL3,BH3; static int TL3bar,TH3bar; bool longone = True; bool shortone = True; int k; double poin; int PipFactor =1; int deinit() { //---- ObjectDelete("H3 Label"); ObjectDelete("H3 Line"); ObjectDelete("L3 Label"); ObjectDelete("L3 Line"); //---- return(0); } int Quant_Bars=25; //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { int l_hour_8 = Hour(); int l_minute_12 = Minute(); static double min=2; static double max; if (l_hour_8 >= starthour && l_hour_8 < TradingHour){ //l_minute_12>=TradingMinute){ for( k=0;k<= Quant_Bars-1;k++) {
why such an odd number, why not simply
which is the biggest positive 32 bit integer?
Hello, i have a problem with the for statement to. iv put it in a function before the start(), but id like to return every value of the iteration. it only returns the result of the entry in the iteration i.e, if i would like it to run 7 times, it only gives me the result of the 7th time it loops, yet id like to return a result for every time I loop. is there a way to get the result?
thank you
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
friends,
I am facing a problem with for statement in mq4 file. In my mq4 file under the start function, there are four numbers of FOR statements. When I put another FOR statement for picking maximum and minimum prices by counting 36 bars or any number of bars as count (say k =36) from 00hrs to 9 hrs in M15 chart, I am getting the result for the maximum price only and the minimum price is always zero. There is no error in the code for picking maximum and minimum values as the same is copied from another working program. The integer k is defined earlier to start function. Any solution for this?