Extended Zigzag indicator into EA

 

Hey guys,


I've extended the basic Zigzag indicator as following:

- peaks on close values (not wicks)

- 4 additional arrays: valid highs & valid lows + associated wicks. They save the peaks as soon as they're not changeable anymore

- after new valid high it compares with previous high wick + 20 pips to detect bullish market structure break. new valid lows vice versa for bearish msb.

- after msb it calculates some fibonacci retracement levels (additional Fib Array)


The indicator prints those msb + fib levels into the journal. Now I want to get those fib levels into an EA where I can implement further confirmations to open trades but I don't get it... tried to implement the whole calculation into the EA, tried through iCustom and with global variables but nothing works like I want it.

Simply said I only need the EA to get the Fib Array and when price comes into thos fib levels i can imlement further code. 


The indicator code is attached. Hope you guys understand my concern and maybe someione can help...


Best regards

Dennis

Files:
 
dennislrnz:

Hey guys,


I've extended the basic Zigzag indicator as following:

- peaks on close values (not wicks)

- 4 additional arrays: valid highs & valid lows + associated wicks. They save the peaks as soon as they're not changeable anymore

- after new valid high it compares with previous high wick + 20 pips to detect bullish market structure break. new valid lows vice versa for bearish msb.

- after msb it calculates some fibonacci retracement levels (additional Fib Array)


The indicator prints those msb + fib levels into the journal. Now I want to get those fib levels into an EA where I can implement further confirmations to open trades but I don't get it... tried to implement the whole calculation into the EA, tried through iCustom and with global variables but nothing works like I want it.

Simply said I only need the EA to get the Fib Array and when price comes into thos fib levels i can imlement further code. 

The indicator code is attached. Hope you guys understand my concern and maybe someione can help...


Best regards

Dennis

Your indicator code is storing Fib values via GlobalVariableSet().

Just use GlobalVariableGet() to get them: Global Variables of the Terminal - MQL4 Reference

Global Variables of the Terminal - MQL4 Reference
Global Variables of the Terminal - MQL4 Reference
  • docs.mql4.com
Global Variables of the Terminal - MQL4 Reference
 
Ryan L Johnson #:

Your indicator code is storing Fib values via GlobalVariableSet().

Just use GlobalVariableGet() to get them: Global Variables of the Terminal - MQL4 Reference

Thanks for fast reply 🙏🏽
Tried this method but didn’t work correctly on strategy tester…

Does it make sense to get the global variable and delete after that until the indicator sets new ?
 
dennislrnz #:
Thanks for fast reply 🙏🏽
Tried this method but didn’t work correctly on strategy tester…

Does it make sense to get the global variable and delete after that until the indicator sets new ?

I am sure that Global variables are not meant to work in strategy tester. do a search of the site.

 
Michael Charles Schefe #:

I am sure that Global variables are not meant to work in strategy tester. do a search of the site.

ChatGPT says it works but I’ll search on the site 😬
 
dennislrnz #:
ChatGPT says it works but I’ll search on the site 😬

that is a word that "shant" be used in this forum. Moderators have been known to delete threads, messages, and comments that even mention that word just once (hahahahahahahaha) especially code that is clearly, NOT, coded by a live person.

EDIT: your code may work in live terminal, however, to use it on strategy tester, you will need to use other means to save your levels.
 
Michael Charles Schefe #:

that is a word that "shant" be used in this forum. Moderators have been known to delete threads, messages, and comments that even mention that word just once (hahahahahahahaha) especially code that is clearly, NOT, coded by a live person.

EDIT: your code may work in live terminal, however, to use it on strategy tester, you will need to use other means to save your levels.
Oh damn, didn’t know that haha…

What’s your suggestion to get this in strategy tester ?
 
dennislrnz #:
Oh damn, didn’t know that haha…

What’s your suggestion to get this in strategy tester ?

scrap it and source the default indicator from the terminal. I believe there is an "extended" version in examples folder with similar feature you want.

 
Michael Charles Schefe #:

I am sure that Global variables are not meant to work in strategy tester. do a search of the site.

"Basically, all works with global variables are performed programmatically. However, this window might be useful when testing EAs."

Articles

MQL5 Programming Basics: Global Variables of the MetaTrader 5 Terminal

Dmitry Fedoseev, 2016.11.25 13:11

Global variables of the terminal provide an indispensable tool for developing sophisticated and reliable Expert Advisors. If you master the global variables, you will no more be able to imagine developing EAs on MQL5 without them.

 
dennislrnz #:
Thanks for fast reply 🙏🏽
Tried this method but didn’t work correctly on strategy tester…

Does it make sense to get the global variable and delete after that until the indicator sets new ?

Yes.

Also, have a look at GlobalVariableCheck() for the purpose of first confirming that the preceding GV has been deleted.