You can use recursive functions in mql5. So I suppose you can implement your recursive algorithms.
In my opinion the only problem you must be aware is stack limits and speed, if your algorithms are complex.
For instance, I wrote a simple code to check the stack limits and speed of MT5 with a simple Fibonacci series generation with recursive algorithm:
int Fibonacci(int N) { if ((N==1) || (N==2)) return 1; else return Fibonacci(N-2) + Fibonacci(N-1); } void OnStart() { for (int N=1; N<=20; N++) { Print(N," --> ",Fibonacci(N)); } }
The result (note that, as expected, each step become a bit slower, mainly after step 23):
2014.01.16 04:21:26.715 Teste (EURUSD,H1) 40 --> 102334155 2014.01.16 04:21:25.293 Teste (EURUSD,H1) 39 --> 63245986 2014.01.16 04:21:24.426 Teste (EURUSD,H1) 38 --> 39088169 2014.01.16 04:21:23.892 Teste (EURUSD,H1) 37 --> 24157817 2014.01.16 04:21:23.563 Teste (EURUSD,H1) 36 --> 14930352 2014.01.16 04:21:23.360 Teste (EURUSD,H1) 35 --> 9227465 2014.01.16 04:21:23.233 Teste (EURUSD,H1) 34 --> 5702887 2014.01.16 04:21:23.153 Teste (EURUSD,H1) 33 --> 3524578 2014.01.16 04:21:23.104 Teste (EURUSD,H1) 32 --> 2178309 2014.01.16 04:21:23.075 Teste (EURUSD,H1) 31 --> 1346269 2014.01.16 04:21:23.056 Teste (EURUSD,H1) 30 --> 832040 2014.01.16 04:21:23.044 Teste (EURUSD,H1) 29 --> 514229 2014.01.16 04:21:23.037 Teste (EURUSD,H1) 28 --> 317811 2014.01.16 04:21:23.032 Teste (EURUSD,H1) 27 --> 196418 2014.01.16 04:21:23.029 Teste (EURUSD,H1) 26 --> 121393 2014.01.16 04:21:23.028 Teste (EURUSD,H1) 25 --> 75025 2014.01.16 04:21:23.027 Teste (EURUSD,H1) 24 --> 46368 2014.01.16 04:21:23.026 Teste (EURUSD,H1) 23 --> 28657 2014.01.16 04:21:23.025 Teste (EURUSD,H1) 22 --> 17711 2014.01.16 04:21:23.025 Teste (EURUSD,H1) 21 --> 10946 2014.01.16 04:21:23.025 Teste (EURUSD,H1) 20 --> 6765 2014.01.16 04:21:23.025 Teste (EURUSD,H1) 19 --> 4181 2014.01.16 04:21:23.025 Teste (EURUSD,H1) 18 --> 2584 2014.01.16 04:21:23.025 Teste (EURUSD,H1) 17 --> 1597 2014.01.16 04:21:23.025 Teste (EURUSD,H1) 16 --> 987 2014.01.16 04:21:23.025 Teste (EURUSD,H1) 15 --> 610 2014.01.16 04:21:23.025 Teste (EURUSD,H1) 14 --> 377 2014.01.16 04:21:23.025 Teste (EURUSD,H1) 13 --> 233 2014.01.16 04:21:23.025 Teste (EURUSD,H1) 12 --> 144 2014.01.16 04:21:23.025 Teste (EURUSD,H1) 11 --> 89 2014.01.16 04:21:23.025 Teste (EURUSD,H1) 10 --> 55 2014.01.16 04:21:23.025 Teste (EURUSD,H1) 9 --> 34 2014.01.16 04:21:23.025 Teste (EURUSD,H1) 8 --> 21 2014.01.16 04:21:23.025 Teste (EURUSD,H1) 7 --> 13 2014.01.16 04:21:23.025 Teste (EURUSD,H1) 6 --> 8 2014.01.16 04:21:23.025 Teste (EURUSD,H1) 5 --> 5 2014.01.16 04:21:23.025 Teste (EURUSD,H1) 4 --> 3 2014.01.16 04:21:23.025 Teste (EURUSD,H1) 3 --> 2 2014.01.16 04:21:23.025 Teste (EURUSD,H1) 2 --> 1 2014.01.16 04:21:23.025 Teste (EURUSD,H1) 1 --> 1
In my opinion the only problem you must be aware is stack limits and speed, if your algorithms are complex.
For instance, I wrote a simple code to check the stack limits and speed of MT5 with a simple Fibonacci series generation with recursive algorithm:
The result (note that, as expected, each step become a bit slower, mainly after step 23):
This is a common issue with recursive algorithm, nothing specific to mql5.
You can use the #property stacksize directive if needed for your algorithm.
This is a common issue with recursive algorithm, nothing specific to mql5.
You can use the #property stacksize directive if needed for your algorithm.
- 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. I have been writing scripts for years using thinkorswim's Thinkscript. There is an automated trading feature on thinkorswim, but as soon as you try to use the best trading indicators, which all seem to use recursive algorithms, you run into severe restrictions.
I have a technique which will work, but I need a platform which allows for recursion. Am I in the right place? Or should I try another platform? Thanks.