I am new to Mql5, so excuse me for being stupid, but i have written this code to draw multiple support, resistance lines and it is only drawing one line. The reason i have the code in two separate functions is because i was testing out if DeInit was called to remove the objects.
in your code N not change cause you set it on top of your code to zero at all
you have to make a for loop and use N++ to make new line with new name
in your code N not change cause you set it on top of your code to zero at all
you have to make a for loop and use N++ to make new line with new name
void GetSupRes(int FurthestBck) { int N = 0; int High = 10; int Low = 10; for (N; N<=FurthestBck; N++) { SetSupRes(High,Low, N); High += 10; Low += 10; } }
I am new to Mql5, so excuse me for being stupid, but i have written this code to draw multiple support, resistance lines and it is only drawing one line. The reason i have the code in two separate functions is because i was testing out if DeInit was called to remove the objects.
Hi Max Carrington, following Faeze Bakhshayesh, the "N" variable is passed into the "setsupres" function as a value-parameter, that is, "N" would be a local variable within "setsupres" and if you increment it, that new value from "N" won't return to the calling routine, hence next loop calling "setsupres" would go from "N=0" again. Another way to resolve it is to turn "N" a reference-variable so that whenever the "setsupres" changes "N", it's changing the same "N" variable you formerly started from zero.
For short, adding "&" upfront definition of "N" in the "setsupres" functions should address what Faeze correctly advised:
void SetSupRes(int High,int Low, int &N)
For more information, check MQL5 doco about "function" - "parameterpass"
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am new to Mql5, so excuse me for being stupid, but i have written this code to draw multiple support, resistance lines and it is only drawing one line. The reason i have the code in two separate functions is because i was testing out if DeInit was called to remove the objects.