You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Here's my code! Sometimes it takes time to show the direction of the "trend" even though it has already found new tops and bottoms in the chart. Any improvement will be welcome. Thanks
The OP's thread has nothing to do with optimisation or defining support and resistance. It is a code related query by the OP. Please don't interject.
Learn optimising meanwhile you are learning coding.
Thanks for the answer! Note that the code says "Zig Zag trend" and not "Price trend"
The following is sample code for Fractals, but it can easily be adapted for zigzag. Instead of using the upper and lower fractals, just look for swing points and detect if it is an upper or lower by simply comparing to the high or low price of that bar. If the swing point is the same as the high, then it is the upper, and if it is the same as the low, it is the lower.
EDIT: Please note that it is MQL4 code and not MQL5, but it just serves as a sample for you to adapt the logic for the zigzag.
The OP's thread has nothing to do with optimisation or defining support and resistance. It is a code related query by the OP. Please don't interject.
I've just checked his code, and suggested him to focus on optimising while learning coding. Also once a trend reach a certain support or resistance level, it is no longer a trend. Since Zigzag will signal if a new higher or a new lower appears. So that might be the end of the trend ...
Thanks for the answer. I will take your suggestion into consideration.