ZigZag semaphore (semafor) indicator - MetaTrader 4 script - MT4/MT5 resources


The indicator places a mark (semaphore, spelled semfor, retained in the original version) at each of the 4 zigzag evaluation lengths. This means that the zigzag does not draw a line on the chart, but simply marks the position of the zigzag. This algorithm is one of the simpler algorithms in Zig Zag and can be found in the post of "!!!-MT4 SEMAFOR" and implemented in the "DetectNewSwing", "LoadIndiBuffers" and "SetSwingBarValues" methods. The original algorithm does not run in the strategy tester (I believe it does not run in real time, it only generates markers correctly on the history at startup). This version works well in the strategy tester. I believe the algorithm implemented is faithful to the original, it seems to create markers that are faithful to the original locations, including flaws that I can see. More complex algorithms can be implemented in the above functions if desired.
These markers show the level of the mark, with a small white dot representing Level 1, a red circle surrounding the white dot representing Level 2, a yellow circle surrounding the white dot and red circle representing Level 3, and finally a green circle surrounding them representing Level 4.

The length can be entered by the user and set to a default value using the following entries:
external integer Level_1_Length = 21; // Zig Zag 1 detection length (21)
external integer Level_2_length = 40; // Zig Zag 2 detection length (40)
external integer Level_3_Length = 60; // Zig Zag 3 detection length (60)
external integer Level_4_Length = 72; // Zig Zag 4 detection length (72)
Two controls have been added, one for turning on and off the text label showing the mark's zigzag price value, and another for removing all indicator marks from the display, or turning them back on - just click on both text objects to toggle between on and off.

I believe I've structured and commented it well for those interested in the code.
Attachment download
📎zz_semafor_02.mq4 (120.16 KB)
Source: MQL5 #27426
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •