Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
Download MetaTrader 5
METATRADER 5 EXAMPLES
16
23 019
ROMAN MARTYNYUK
Introduction
OneofthemostpopularmethodsofmarketanalysisistheElliottWavePrinciple.However,thisprocessisquitecomplicated,whichleadsusto
theuseofadditionalinstruments.Oneofsuchinstrumentsistheautomaticmarker.
This article describes the creation of an automatic analyzer of Elliott Waves in the MQL5 language. It is assumed that the reader is already
familiarwiththewavetheory,ifnot,youneedtorefertotheappropriatesources.
1.Elliott'sWavePrinciple
Elliott'sWavesisatheoreticalmodelofmarketbehavior,developedbyRalphNelsonElliott,accordingtowhichallofthepricemovementson
themarketaresubjecttohumanpsychologyandareacyclicprocessofchangesofimpulsewaves,tothecorrectionalandviceversa.
Impulsewavesareasequenceoffivepricefluctuations,correctivewavesasequenceofthreeorfivepricefluctuations.Impulsewavesin
theirform,structure,andtherulesapplicabletothem,areofthefollowingtypes:
1.Impulses:
https://www.mql5.com/en/articles/260
1/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
Theendofthesecondwavenevercomesoverthebeginningofthefirstwave
Thethirdwavealwaysextendsbeyondthetopofthefirstwave
Theendofthefourthwavenevercomesoverthetopofthefirstwave
Thethirdwaveisnevertheshortestofalltheactingwaves
Thethirdwaveisalwaysanimpulse
Thefirstwavemaybeeitheranimpulseoraleadingdiagonal
Thefifthwavecanbeeitheranimpulseoradiagonal
Thesecondwavecouldtaketheformofanycorrectivewaveexceptatriangle
Thefourthwavecouldtaketheformofanycorrectionalwave
Figure1.Impulse
2.Leadingdiagonals:
Theendofthesecondwavenevercomesoverthebeginningofthefirstwave
Thethirdwavealwaysextendsbeyondthetopofthefirstwave
The end of the fourth wave always comes over the top of the first wave, but it never goes
overthebeginningofthethirdwave
Thethirdwaveisnevertheshortestofalltheactingwaves
Thethirdwaveisalwaysanimpulse
Thefirstwavemaybeeitheranimpulseoraleadingdiagonal
Thefifthwavecanbeeitheranimpulseoradiagonal
Thesecondwavecouldtaketheformofanycorrectivewaveexceptatriangle
Thefourthwavecouldtaketheformofanycorrectionalwave
Figure2.Leadingdiagonal
3.Diagonals:
https://www.mql5.com/en/articles/260
2/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
Theendofthesecondwavenevercomesoverthebeginningofthefirstwave
Thethirdwavealwaysextendsbeyondthetopofthefirstwave
The end of the fourth wave usually comes over the top of the first wave, but it never goes
overthetopofthethirdwave
Thethirdwaveisnevertheshortestofalltheactingwaves
The first, second, and third waves could take the form of any corrective wave except a
triangle
Thefourthandfifthwavecouldtaketheformofanycorrectivewaves
Figure3.Diagonal
Correctivewavesareclassifiedinto:
4.Zigzags:
WaveAmaytaketheformofanimpulseoraleadingdiagonal
WaveCmaytaketheformofanimpulseoradiagonal
WaveBcantaketheformofanycorrectivewave
WaveCextendsbeyondthetopofwaveA
TheendofwaveBdoesnotgooverthebeginningofwaveA
Figure4.Zigzag
5.Flats:
https://www.mql5.com/en/articles/260
3/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
WaveAcouldtaketheformofanycorrectivewaveexceptatriangle
WaveBcantaketheformofanycorrectivewave
WaveCmaytaketheformofanimpulseoradiagonal
Figure5.Flat
6.DoubleZigzags:
WaveWandWaveYtaketheformofazigzag
WaveXmaytaketheformofanycorrectivewave
WaveYextendsbeyondthetopofwaveW
TheendofwaveXdoesnotgooverthebeginningofwaveW
Figure6.DoubleZigzag
7.TripleZigzags:
https://www.mql5.com/en/articles/260
4/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
WaveW,waveY,andwaveZtaketheformofazigzag
WaveXmaytaketheformofanycorrectivewaveexceptatriangle
WaveXXmaytaketheformofanycorrectivewave
WaveYextendsbeyondthetopofwaveW
WaveZextendsbeyondthetopofwaveY
TheendofwaveXdoesnotgooverthebeginningofwaveW
TheendofwaveXXdoesnotgooverthebeginningofwaveY
Figure7.TripleZigzag
8.DoubleThrees:
WaveWtakestheformofanycorrectivewaveexceptatriangle
WaveXandwaveYtaketheformofanycorrectivewave
Figure8.DoubleThree
9.TripleThrees:
WaveW,waveX,andwaveYcantakeanyformofacorrectivewaveexceptatriangle
WaveXXandWaveZmaytaketheformofanycorrectivewave
Figure9.TripleThree
10.ContractingTriangle:
https://www.mql5.com/en/articles/260
5/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
WaveCnevergoesbeyondthepricelimitsofwaveB
WaveDnevergoesbeyondthepricelimitswaveC
WaveEnevergoesbeyondthepricelimitsofwaveD
WaveA,waveB,andwaveCmaytaketheformofanycorrectivewaveexceptatriangle
WaveDandwaveEmaytaketheformofanycorrectivewave
Figure10.ContractingTriangle
11.ExpandingTriangles:
WaveCisalwaysgreaterinlengthsthanwaveB
WaveDisalwaysgreaterinlengththanwaveC
Wave A, wave B, and wave C may take the form of any corrective wave except for the
triangle
WaveDandwaveEmaytaketheformofanycorrectivewave
Figure11.ExpandingTriangle
Thewavemodelsandrules,presentedabove,correspondonlytothetheclassicalnotionofthewaveanalysis.
Thereisalsoitsmodernconception,formedduringthestudyoftheForexmarket.Forexample,anewmodelofoblique(sliding)triangleis
found,impulseswiththetriangleinthesecondwaveareidentified,etc.
As can be seen from the figures 111, each impulse or corrective wave consists of the same impulse and corrective waves (shown by the
dashedline),butinalesserdegree.Thisisthesocalledfractal(nesting)ofElliott'swaves:wavesofalargedegreeconsistofwavesoflesser
degrees,whichinturn,arecomposedofwavesofmuchless,andsoon.
OnthisnotewecancompletetheshortintroductiontotheElliottWavePrincipleandgoontothetopicofautomaticmarkupofwaves.
2.AlgorithmoftheautomaticmarkupoftheElliottWaves
Asyouhaveprobablyalreadyrealized,theElliottWaveAnalysisisacomplexandmultifacetedprocess.Therefore,peoplebeganfromthevery
starttosearchforandapplyinstrumentsthathelptoeaseit.
https://www.mql5.com/en/articles/260
6/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
OnesuchtoolbecamethemechanismforautomaticmarkupoftheElliottWaves.
Wecandistinguishtwoprinciplesofautomarkups:
1.Accordingtothefractalityofwaves,theanalysisiscarriedoutfromtopdown,fromthelargertothesmallerwaves
2.Theanalysisiscarriedoutbyadirectenumerationofallofthepossibleoptions.
AblockdiagramoftheautomaticanalysisoftheElliottWavesisdemonstratedinFigure12.
https://www.mql5.com/en/articles/260
7/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
Figure12.AblockdiagramoftheautomaticanalysisofElliottWaves
Considerthealgorithminmoredetail,basedontheexampleoftheautomaticmarkupoftheimpulse(seeFigure13).
https://www.mql5.com/en/articles/260
8/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
Onthefirststage,attherequiredintervaloftimeofthepricechart,usingthe"Zigzag",theamountofpoints,necessaryformakingthemark
up,arehighlighted.Thenumberofpointsdependsonwhichkindofwavewewanttoanalyze.So,fortheanalysisoftheImpulse,thereare
requiredsixpoints5vertexesandonepointofbeginning.IfwewereanalyzingtheZigzag,thenthenumberofrequiredpointswouldhave
been43vertexesandonepointofbeginning.
Ifthe"Zigzag"hasidentifiedsixpointsonthepricechart,thenwecanimmediatelygenerateamarkupoftheImpulse:thefirstpointthe
startingpointofthefirstwave,thesecondpointthevertexofthefirstwave,thethirdpointthevertexofthesecondwave,thefourthpoint
thevertexofthethirdwave,thefifthpointthevertexofthefourthwave,andthesixthpointthevertexofthefifthwave.
However,onFigure13,the"Zigzag"hasidentified8points.Inthiscase,itwillbenecessarytoenumeratebythesepoints,allofthepossible
optionsandmarkupsofthewave.Andtherewillbefiveofthem(markedwithdifferentcolors).Andeachversionofthemarkupwillhaveto
becheckedaccordingtotherules.
Figure13.Optionsformarkingthemarkupofanimpulse
https://www.mql5.com/en/articles/260
9/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
Aftercheckingagainsttherules,incasethemarkupofthewaveisanImpulsebyalloftheparameters,allofitssubwavesareanalyzedinthe
samemanner.
Thesameappliestotheanalysisofalloftheotherimpulseandcorrectivewaves.
3.Thetypesofwavesfortheautomaticmarkup
Aspreviouslystated,theanalysiswillbeconductedfromthetoptobottom,bygivingtheprograminstructionstofindsomewaveonagiven
interval.However,onthelargestinterval,itisimpossibletodeterminethestateofthewave,itsbeginningandend.Wewillcallsuchawave
unbegunandunfinished.
Allwavescanbedividedintothefollowinggroups:
1.Unbegunwaves:
1.Waveswithanunbegunfirstwave12345(forexample,anImpulsewithanunbegunwave1,therequirednumberofpoints
5),and123(forexample,aZigzagwithanunbegunwaveAtherequirednumberofpoints3)
2.Waveswithanunbegunsecondwave2345(forexample,aDiagonalwithanunbegunwave2,therequirednumberofpoints
4),and23(forexample,aflatwithanunbegunwaveBtherequirednumberofpoints2)
3.Waveswithanunbegunthirdwave345(forexample,aTripleZigzagwithanunbegunwaveYtherequirednumberofpoints
3)
4.Waveswithanunbegunfourthwave45(forexample,aTrianglewithanunbegunwaveDtherequirednumberofpoints2)
5.Waveswithanunbegunfifthwave5(forexample,anIpulsewithanunbegunwave5,therequirednumberofpoints1)
6.Waveswithanunbegunthirdwave3(forexample,adoublethreewithanunbegunwaveZtherequirednumberofpoints1)
2.Unfinishedwaves:
1.Waveswithanunfinishedfifthwave12345(forexample,anImpulsewithanunfinishedwave5therequirednumberof
points5)
2.Waves with an unfinished fourth wave 1234> (for example, a Triple zigzag with an unfinished wave XX the required
numberofpoints4)
3.Waveswithanunfinishedthirdwave123>(forexample,aleadingdiagonalfromtheunfinishedwave3,therequirednumber
ofpoints3)
4.Waveswithanunfinishedsecondwave12>(forexample,aZigzagwithanunfinishedwaveBtherequirednumberofpoints
2)
5.Waveswithanunfinishedfirstwave1>(forexample,aflatwithanunfinishedwaveAtherequirednumberofpoints1)
3.Unbegunandunfinishedwaves:
1.Waveswithanunbegunfirstwaveandanunfinishedsecondwave12>(forexample,aZigzagwithanunbegunwaveAandan
unfinishedwaveBtherequirednumberofpoints1)
2.Waveswithanunbegunsecondwaveandanunfinishedthirdwave23>(forexample,aZigzagwithanunbegunwaveBandan
unfinishedwaveCtherequirednumberofpoints1)
3.Waveswithanunbegunthirdwaveandanunfinishedfourthwave34><(forexample,anImpulsewithanunbegunwave3
andanunfinishedwave4,therequirednumberofpoints1)
4.Waveswithanunbegunfourthwaveandanunfinishedfifthwave45>(forexample,anImpulsewithanunbegunwave4and
anunfinishedwave5,therequirednumberofpoints1)
5.Waveswithanunbegunfirstandanunfinishedthirdwave123>(forexample,thetriplethreewithanunbegunwaveWand
anunfinishedwaveYtherequirednumberofpoints2)
https://www.mql5.com/en/articles/260
10/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
6.Waveswithanunbegunsecondwaveandanunfinishedfourthwave234>(forexample,aleadingdiagonalwithanunbegun
wave2andanunfinishedwave4,therequirednumberofpoints2)
7.Waveswithanunbegunthirdwaveandanunfinishedfifthwave345>(forexample,aDiagonalwithanunbegunwave3and
anunfinishedwave5,therequirednumberofpoints2)
8.Waveswithanunbegunfirstwasteandwithanunfinishedfourthwave1234>(forexample,atriplethreewithanunbegun
waveWandanunfinishedwaveXXtherequirednumberofpoints3)
9.Waveswithanunbegunsecondwaveandanunfinishedfifthwave2345(forexample,anImpulsewithanunbegunwave2
andanunfinishedwave5therequirednumberofpoints3)
10.Waveswithanunbegunfirstwaveandanunfinishedfifthwave12345>(forexample,aTriplezigzagwithanunbegunwave
WandanunfinishedwaveZtherequirednumberofpoints4)
4.Completedwaves12345(therequirednumberofpoints6)and123(therequirednumberofpoints4).
Thesign"<"afterthenumberofthewave,indicatesthatithasnotbegun.Thesign">"afterthenumberofawave,indicatesthatitis
incomplete.
OntheFigure14wecanseethefollowingwaves:
1.AwavewithafirstunbegunwaveAABC
2.AwavewithanunbegunfirstWandanunfinishedsecondXwaveW<X>
3.CompletedwavesBandC
https://www.mql5.com/en/articles/260
11/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
Figure14.Unbegunandunfinishedwaves
4.ThedescriptionthedatastructuresoftheautomaticanalyzerofElliottWaves
TowritetheautomaticanalyzeroftheElliottWaves,wewillneedthefollowingdatastructures:
4.1.Thestructureofthedescriptionoftheanalyzedwavesintheprogram:
//Thestructureofthedescriptionoftheanalyzedwavesintheprogram
structTWaveDescription
{
stringNameWave//nameofthewave
intNumWave//numberofsubwavesinawave
https://www.mql5.com/en/articles/260
12/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
stringSubwaves[6]//thenamesofthepossiblesubwavesinthewave
}
4.2.Aclassforstoringtheparametersofaspecificwave:
//Aclassforstoringtheparametersofawave
classTWave
{
public:
stringName//nameofthewave
stringFormula//theformulaofthewave(12345,<123etc.)
intLevel//thelevelofthewave
doubleValueVertex[6]//thevalueofthetopofthewave
intIndexVertex[6]//theindexesofthetopofthewaves
}
4.3.AclassforstoringthevaluesofthevertexesandtheindexesofthevertexoftheZigzag:
//Aclassforstoringthevaluesofvertexesandindexesofthezigzag
classTZigzag:publicCObject
{
public:
CArrayInt*IndexVertex//indexesofthevertexesofthezigzag
CArrayDouble*ValueVertex//valueofthevertexesofthezigzags
}
4.4.Classtorepresentthetreeofwaves:
//Aclassforthepresentationofthetreeofthewaves
classTNode:publicCObject
{
public:
CArrayObj*Child//thechildofthegiventreenode
TWave*Wave//thewave,storedinthegiventreenode
stringText//textofthetreenode
TNode*Add(stringText,TWave*Wave=NULL)//thefunctionofaddingthenodetothetree
{
TNode*Node=newTNode
Node.Child=newCArrayObj
Node.Text=Text
Node.Wave=Wave
Child.Add(Node)
return(Node)
}
}
https://www.mql5.com/en/articles/260
13/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
4.5.Thestructureforstoringthepoints,foundbytheZigzag:
//Thestructureforstoringthepoints,foundbythezigzag
structTPoints
{
doubleValuePoints[]//thevaluesofthefoundpoints
intIndexPoints[]//theindexesofthefoundpoints
intNumPoints//thenumberoffoundpoints
}
4.6.Aclassforstoringtheparametersofthealreadyanalyzedsectionofthechart:
//Aclassforstoringtheparametersofthealreadyanalyzedsection,correspondingtothewavetreenode
classTNodeInfo:CObject
{
public:
intIndexStart,IndexFinish//therangeofthealreadyanalyzedsection
doubleValueStart,ValueFinish//theedgevalueofthealreadyanalyzedsection
stringSubwaves//thenameofthewaveandthegroupofthewaves
TNode*Node//thenode,pointingtothealreadyanalyzedrangeofthechart
}
4.7.Aclassforstoringofthemarkingofwavesbeforeplacingitonthechart:
//Aclassforstoringthemarkingofwavesbeforeplacingthemonthechart
classTLabel:publicCObject
{
public:
doubleValue//thevalueofthevertex
intLevel//thelevelofthewave
stringText//themarkingofthewave
}
5.ThedescriptionofthefunctionoftheautomaticanalyzeroftheElliottWaves
TowritetheautomaticanalyzeroftheElliottWaves,wewillneedthefollowingfunctions:
5.1.Zigzag
Thesearchfunctionoftheextremumsofthe"Zigzags":
intZigzag(intH,intStart,intFinish,CArrayInt*IndexVertex,CArrayDouble*ValueVertex)
https://www.mql5.com/en/articles/260
14/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
AkeyelementintheautomaticanalyzeroftheElliottWavesisthe"Zigzag",bywhichthewaveswillbebuilt.Thecalculationofthe"Zigzag"by
anyparametermustbedoneveryquickly.
Inouranalyzer,wewillbeusingthe"Zigzag",takenfromthearticle"HowtoWriteFastNonRedrawingZigZags".
TheZigzagfunctioncalculatestheZigzag,withtheparameterHintheintervalfromStarttoFinish,andthenrecordsthefoundindexesofthe
vertexesandthevaluesofthevertexes,respectively,intothearraysIndexVertexandValueVertex,theaddressesofwhicharepassedintothis
function.
TheZigzagfunctionreturnsthenumberoffoundvertexesofthe"Zigzag".
5.2.FillZigZagArray
Functionofthefillingof"Zigzag"andthestorageofitsparameters:
voidFillZigzagArray(intStart,intFinish)
Aswasshownbefore,wewillneedtofindthenecessarynumberofpointsonthepricechartforthemarkupofthewave.Andthereforewe
willneedtohaveanarrayofvertexesofthe"Zigzag",withdifferentparameters,whichwethenwilliteratetofindthesepoints.
The FillZigzagArray function calculates the "Zigzag" on the interval of the chart from Start to Finish, with all of the possible values of the
parameterH(untilthenumberofvertexesofthe"Zigzag"willnotbecomeequaltoorlessthantwo),storestheinformationaboutthefound
vertexesintheobjectsofclassTZigzag,andrecordstheseobjectsintotheglobalarrayZigzagArray,theannouncingofwhichisasfollows:
CArrayObj*ZigzagArray
5.3.FindPoints
Thesearchfunctiononthegivenintervalrequiresthenumberofpointsonthepricechart:
boolFindPoints(intNumPoints,intIndexStart,intIndexFinish,doubleValueStart,doubleValueFinish,TPoints&Points)
ThefunctionFindPointssearchesforatleastthreeNumPointspointsonthepricechart,ontherequiredrange,fromIndexStarttoIndexFinish,
withtherequiredvaluesofthefirstandlastpointsValueStartandValueFinish,andsavesthem(ie,points)intothestructureofPoints,thelink
ofwhichispassedtothisfunction.
ThefunctionFindPointsreturnstrue,iftherequirednumberofpointsisfound,otherwise,itreturnsfalse.
5.4.NotStartedAndNotFinishedWaves
Thefunctionofanalysisoftheunbegunandunfinishedwaves:
voidNotStartedAndNotFinishedWaves(TWave*ParentWave,intNumWave,TNode*Node,stringSubwaves,intLevel)
https://www.mql5.com/en/articles/260
15/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
The function NotStartedAndNotFinishedWaves analyzes all of the waves of the third group of waves unbegun and unfinished. The function
analyzestheNumWavewave(withawavelevelLevel),waveswiththenameParentWave.Name,whichmaytaketheformofsubwavewaves
(aformofaZigzag,flats,Doublezigzag,and(or),etc.).TheanalyzedwaveNumWavewillbestoredinthenodeofthetreeofwaves,thechild
nodeNode.
Forexample,iftheParentWave.Name="Impulse",NumWave=5,Subwaves="Impulse,Diagonal,andLevel=2,thenwecansaythatthe
NotStartedAndNotFinishedWavesfunctionwillanalyzethefifthwaveoftheImpulse,whichhasawaveleveloftwo,andcantaketheformofan
ImpulseoraDiagonal.
As an example, we use a blockdiagram of the algorithm analysis of the unbegun and unfinished waves 1<23> in the
NotStartedAndNotFinishedWavesfunction:
<imgalt="Figure15.TheBlockdiagramofwaveanalysiswiththeformula"1""title="Figure15.TheBlockdiagramofwaveanalysiswiththe
formula"1""src="http://p.mql5.com/data/2/260/fig15.gif"style="verticalalign:middle"height="1746"width="750">
Figure15.TheBlockdiagramofwaveanalysiswiththeformula"1<23>"
When using the NotStartedAndNotFinishedWaves function, the following functions are called: NotStartedWaves, NotFinishedWaves and
FinishedWaves.
5.5.NotStartedWaves
Thefunctionforanalysisofunbegunwaves:
voidNotStartedWaves(TWave*ParentWave,intNumWave,TNode*Node,stringSubwaves,intLevel)
TheNotStartedWavesfunctionanalyzesallofthewavesofthefirstgroupofwavestheunbegunwaves.ThefunctionanalyzestheNumWave
wave (with the wave level Level) of the wave called ParentWave.Name, which may take the form of subwaves waves. The analyzed wave
NumWavewillbestoredinthenodeofthetreeofwaves,thechildnodeNode.
WhentheNotStartedWavesfunctionisatwork,thefollowingfunctionsarecalled:NotStartedWavesandFinishedWaves.
AllwavesareanalyzedsimilarlytotheblockdiagramintheFigure15.
5.6.NotFinishedWaves
Thefunctionanalysisofunfinishedwaves:
voidNotFinishedWaves(TWave*ParentWave,intNumWave,TNode*Node,stringSubwaves,intLevel)
The NotFinishedWaves function analyzes all of the waves of the second group of waves unfinished waves. The function analyzes the
NumWavewave(withthewavelevelLevel)ofthewavecalledParentWave.Name,whichcantaketheformofsubwavewaves.Theanalyzed
waveNumWavewillbestoredinthenodeofthetreeofwaves,thechildnodeNode.
WhentheNotFinishedWavesfunctionisatwork,thefollowingfunctionsarecalled:NotFinishedWavesandFinishedWaves.
AllwavesareanalyzedsimilarlytotheblockdiagramintheFigure15.
https://www.mql5.com/en/articles/260
16/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
5.7.FinishedWaves
Thefunctionanalysisofcompleted(finished)waves:
voidFinishedWaves(TWave*ParentWave,intNumWave,TNode*Node,stringSubwaves,intLevel)
TheFinishedWavesfunctionanalyzesallofthewavesofthefourthgroupthecompletedwaves.ThefunctionanalyzestheNumWavewave
(withawavelevelLevel)ofthewavecalledParentWave.Name,whichmaytaketheformofasubwaveswaves.TheanalyzedwaveNumWave
willbestoredinthenodeofthetreeofwaves,thechildnodeNode.
WhentheFinishedWavesfunctionisatwork,thefunctionFinishedWavesiscalled.
AllwavesareanalyzedsimilarlytotheblockdiagramintheFigure15.
5.8.FindWaveInWaveDescription
ThefunctionofwavesearchinthedatastructureWaveDescription:
intFindWaveInWaveDescription(stringNameWave)
The FindWaveInWaveDescription function, by the name of the wave NameWave, passed as a parameter, searches for it in the array of
structuresWaveDescription,andreturnstheindexnumber,correspondingtothiswave.
ThearrayofWaveDescriptionstructureslooksthefollowingway:
TWaveDescriptionWaveDescription[]=
{
{
"Impulse",5,
{
"",
"Impulse,LeadingDiagonal,",
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,",
"Impulse,",
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,ContractingTriangle,ExpandingTriangle,"
"Impulse,Diagonal,"
}
}
,
{
"LeadingDiagonal",5,
{
"",
"Impulse,LeadingDiagonal,",
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,",
"Impulse,",
https://www.mql5.com/en/articles/260
17/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,ContractingTriangle,ExpandingTriangle,"
"Impulse,Diagonal,"
}
}
,
{
"Diagonal",5,
{
"",
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,",
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,",
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,",
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,ContractingTriangle,ExpandingTriangle,"
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,ContractingTriangle,ExpandingTriangle,"
}
}
,
{
"Zigzag",3,
{
"",
"Impulse,LeadingDiagonal,",
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,ContractingTriangle,ExpandingTriangle,"
"Impulse,Diagonal,",
"",
""
}
}
,
{
"Flat",3,
{
"",
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,",
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,ContractingTriangle,ExpandingTriangle,"
"Impulse,Diagonal,",
"",
""
}
}
,
{
"DoubleZigzag",3,
{
"",
"Zigzag,",
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,ContractingTriangle,ExpandingTriangle,"
https://www.mql5.com/en/articles/260
18/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
"Zigzag,",
"",
""
}
}
,
{
"TripleZigzag",5,
{
"",
"Zigzag,",
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,",
"Zigzag,",
"Zigzag,Flat,DoubleZigzag,TripleZigzag,TripleThree,ContractingTriangle,ExpandingTriangle,",
"Zigzag,"
}
}
,
{
"DoubleThree",3,
{
"",
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,",
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,ContractingTriangle,ExpandingTriangle,"
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,ContractingTriangle,ExpandingTriangle,"
"",
""
}
}
,
{
"TripleThree",5,
{
"",
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,",
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,",
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,",
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,ContractingTriangle,ExpandingTriangle,"
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,ContractingTriangle,ExpandingTriangle,"
}
}
,
{
"ContractingTriangle",5,
{
"",
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,",
https://www.mql5.com/en/articles/260
19/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,",
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,",
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,ContractingTriangle,ExpandingTriangle,"
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,ContractingTriangle,ExpandingTriangle,"
}
}
,
{
"ExpandingTriangle",5,
{
"",
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,",
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,",
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,",
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,ContractingTriangle,ExpandingTriangle,"
"Zigzag,Flat,DoubleZigzag,TripleZigzag,DoubleThree,TripleThree,ContractingTriangle,ExpandingTriangle,"
}
}
}
The FindWaveInWaveDescription function is used in the function analysis of the following waves: NotStartedAndNotFinishedWaves,
NotStartedWaves,NotFinishedWaves,andFinishedWaves.
5.9.Already
Thefunctionwhichcheckswhetherthegivensectionofthecharthasalreadybeenanalyzed:
boolAlready(TWave*Wave,intNumWave,TNode*Node,stringSubwaves)
SincetheautomaticanalysisoftheElliottWavesoccursbythemethodofenumeration,asituationmayarisewhenthegivensectionofthechart
hasalreadybeenanalyzedforthepresenceofawaveorawavegroup.Toknowthis,youneedtosavethelinktothenodeinthetreeofthe
wavesofthealreadyanalyzedwave,andonlythenputoutthelink.AllthishappensinthefunctionAlready.
The Already function looks for a global array NodeInfoArray, which stores the objects of TNodeInfo class, the interval of the chart,
correspondingtothewaveNumWave,ofthewavenamedWave.Name,whichhastheshapeofsubwaveswaves,andrecordsintotheNode
theaddressofthenodeofthealreadymarkedupsectionofthechart.Ifthissectiondoesn'texist,thenanewobjectofTNodeInfoclassis
createdandfilled,andisrecordedintotheNodeInfoArrayarray.
Thefunctionreturnstrueiftheintervalofthecharthasalreadybeenanalyzed,otherwiseitreturnsfalse.
TheNodeInfoArrayarrayisdeclaredinthefollowingway:
CArrayObjNodeInfoArray
https://www.mql5.com/en/articles/260
20/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
5.10.Thefunctionsofcheckingthewavesfortherules
It includes the functions VertexAAboveB, WaveAMoreWaveB and WaveRules, from which the first two functions are called. When testing,
remember that the waves can be unbegun and (or) incomplete, and, for example, for the wave with the formula "1<23>", it can not be
determinedwhetherthefourthwavehasgonebeyondtheterritoryofthefirstwavebecausethereisnofourthwaveyet.
5.10.1.WaveRules
Functionofcheckingthewavesfortherules:
boolWaveRules(TWave*Wave)
TheWaveRulesfunctionreturnstrueifawave,withthenameWave.Name,is"correct",otherwise,itreturnsfalse.Initswork,thefunction
WaveRulesiscalledbythefunctionVertexAAboveVertexBandWaveAMoreWaveB.
5.10.2.VertexAAboveVertexB
Thefunctionofcheckingtheexcessofonevertexoveranothervertex:
intVertexAAboveVertexB(intA,intB,boolInternalPoints)
TheVertexAAboveVertexBfunctionreturnsthenumber>=0,ifthetopoftheAwaveexceededthetopoftheBwave,otherwiseitreturns1.
IftheInternalPoints=true,thentheinternalpointsofwaves(maximumand(or)minimum)valuesofthewaves)aretakenintoconsideration.
5.10.3.WaveAMoreWaveB
Thefunctionofcheckingtheexcessofthelengthofonewaveoverthelengthofanother:
intWaveAMoreWaveB(intA,intB)
TheWaveAMoreWaveBfunctionreturnsanumber>=0ifwaveAislargerthanwaveB,otherwiseitreturns1.
11.Thefunctionofclearingthememory
5.11.1.ClearTree
ThefunctionofclearingthetreeofwaveswiththetopnodeNode:
voidClearTree(TNode*Node)
5.11.2.ClearNodeInfoArray
ThefunctionclearsthearrayClearNodeInfoArray:
voidClearNodeInfoArray()
https://www.mql5.com/en/articles/260
21/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
5.11.3.ClearZigzagArray
ThefunctionforclearingthearrayZigzagArray:
voidClearZigzagArray()
5.12.Thefunctionofbypassingthetreewavesandissuingoftheanalysisresultstothechart
AfterthecompletionoftheautomaticanalysisoftheElliottWaves,wehaveatreeofwaves.
Itsexamplecanbepresentedasonthefigurebelow:
https://www.mql5.com/en/articles/260
22/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
https://www.mql5.com/en/articles/260
23/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
Figure16.Anexampleofatreeofwaves
Now,todisplaytheresultsoftheanalysisonthechart,weneedtogetaroundthegiventree.AsshowninFigure16,therearequietafew
options(sincethereareseveraloptionsofwaves),andeachoptionofabypassleadstoadifferentmarkups.
Wecandistinguishtwotypesoftreenodes.
Thefirsttypenodeswiththewavenames("Impulse","Zigzag"etc.).Thesecondtypenodeswithwavenumber("1","1<","etc.).Allofthe
informationabouttheparametersofthewaveisstoredinthefirsttypeofthenodes.Therefore,whenvisitingthesenodes,wewillretrieveand
recordinformationaboutthewave,inordertothendisplayitonthechart.
Forsimplicity,wewillbypassthetree,visitingonlythefirstversionsofthewaves.
AnexampleofabypassisshowninFigure17andishighlightedinred.
https://www.mql5.com/en/articles/260
24/87
05/01/2017
https://www.mql5.com/en/articles/260
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
25/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
Figure17.Exampleofbypassingawavetree
5.12.1.FillLabelArray
Thefunctionofbypassingawavetree:
voidFillLabelArray(TNode*Node)
The FillLabelArray function bypasses the wave tree with the root Node, attending only the first versions of the waves in the tree, and fills a
globalarrayLabelArray,theindexesofwhich,storealinktothearrayofvertexes(arrayofobjectsofclassTLabel),withhasthegivenindexon
thechart.
TheLabelArrayarrayisdefinedasfollows:
CArrayObj*LabelArray[]
5.12.2.CreateLabels
Thefunctionofdisplayingtheanalysisresultsonthechart:
voidCreateLabels()
https://www.mql5.com/en/articles/260
26/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
TheCreateLabelsfunctioncreatesthegraphicalobjects"Text",correspondingtothewavetagsonthechart.Thetagsofthewavesarecreated
basedonthearrayLabelArray.
5.12.3.CorrectLabel
Theupdatingfunctionof(correcting)thetopsofwavesonthechart:
voidCorrectLabel()
TheCorrectLabelfunctioncorrectsthewavetagsonthechartwhenitisscrolledand(or)duringitsrestriction.
6.TheimplementingoftheautomaticpartitioningofElliottWaves
6.1.TheZigzagfunction:
//++
//|TheZigzagfunction|
//++
intZigzag(intH,intStart,intFinish,CArrayInt*IndexVertex,CArrayDouble*ValueVertex)
{
boolUp=true
doubledH=H*Point()
intj=0
intTempMaxBar=Start
intTempMinBar=Start
doubleTempMax=rates[Start].high
doubleTempMin=rates[Start].low
for(inti=Start+1i<=Finishi++)
{
//processingthecaseofarisingsegment
if(Up==true)
{
//checkthatthecurrentmaximumhasnotchanged
if(rates[i].high>TempMax)
{
//ifithas,correctthecorrespondingvariables
TempMax=rates[i].high
TempMaxBar=i
}
elseif(rates[i].low<TempMaxdH)
{
//otherwise,ifthelaggedlevelisbroken,fixatethemaximum
ValueVertex.Add(TempMax)
https://www.mql5.com/en/articles/260
27/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
IndexVertex.Add(TempMaxBar)
j++
//correctthecorrespondingvariables
Up=false
TempMin=rates[i].low
TempMinBar=i
}
}
else
{
//processingthecaseofthedescendingsegment
//checkthatthecurrentminimumhasn'tchanged
if(rates[i].low<TempMin)
{
//ifithas,correctthecorrespondingvariables
TempMin=rates[i].low
TempMinBar=i
}
elseif(rates[i].high>TempMin+dH)
{
//otherwise,ifthelaggedlevelisbroken,fixtheminimum
ValueVertex.Add(TempMin)
IndexVertex.Add(TempMinBar)
j++
//correctthecorrespondingvariables
Up=true
TempMax=rates[i].high
TempMaxBar=i
}
}
}
//returnthenumberofzigzagtops
return(j)
}
6.2.TheFillZigzagArrayfunction:
CArrayObj*ZigzagArray//declaretheZigzagArrayglobaldynamicarray
//++
//|TheFillZigzagArrayfunction|
//|searchthroughthevaluesoftheparameterHzigzag|
//|andfillthearrayZigzagArray|
//++
voidFillZigzagArray(intStart,intFinish)
{
ZigzagArray=newCArrayObj//createthedynamicarrayofzigzags
https://www.mql5.com/en/articles/260
28/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
CArrayInt*IndexVertex=newCArrayInt//createthedynamicarrayofindexesofzigzagtops
CArrayDouble*ValueVertex=newCArrayDouble//createthedynamicarrayofvaluesofthezigzagtops
TZigzag*Zigzag//declaretheclassforstoringtheindexesandvaluesofthezigzag
intH=1
intj=0
intn=Zigzag(H,Start,Finish,IndexVertex,ValueVertex)//findthetopsofthezigzagwiththeparameterH=1
if(n>0)
{
//storethetopsofthezigzaginthearrayZigzagArray
Zigzag=newTZigzag//createtheobjectforstoringthefoundindexesandthezigzagtops,
//fillitandstoreinthearrayZigzagArray
Zigzag.IndexVertex=IndexVertex
Zigzag.ValueVertex=ValueVertex
ZigzagArray.Add(Zigzag)
j++
}
H++
//loopoftheHofthezigzag
while(true)
{
IndexVertex=newCArrayInt//createadynamicarrayofindexesofzigzagtops
ValueVertex=newCArrayDouble//createadynamicarrayofvaluesofthezigzagtops
n=Zigzag(H,Start,Finish,IndexVertex,ValueVertex)//findthetopsofthezigzag
if(n>0)
{
Zigzag=ZigzagArray.At(j1)
CArrayInt*PrevIndexVertex=Zigzag.IndexVertex//getthearrayofindexesofthepreviouszigzag
boolb=false
//checkifthereisadifferencebetweenthecurrentzigzagandthepreviouszigzag
for(inti=0i<=n1i++)
{
if(PrevIndexVertex.At(i)!=IndexVertex.At(i))
{
//ifthereisadifference,storethetopsofazigzaginthearrayZigzagArray
Zigzag=newTZigzag
Zigzag.IndexVertex=IndexVertex
Zigzag.ValueVertex=ValueVertex
ZigzagArray.Add(Zigzag)
j++
b=true
break
}
}
if(b==false)
{
//otherwise,ifthereisnodifference,releasethememory
deleteIndexVertex
https://www.mql5.com/en/articles/260
29/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
deleteValueVertex
}
}
//searchforthetopsofthezigzaguntilthereistwoorlessofthem
if(n<=2)
break
H++
}
}
6.3.TheFindPointsfunction:
//++
//|TheFindPointsfunction|
//|FilltheValuePointsandIndexPointsarrays|
//|ofthePointsstructure|
//++
boolFindPoints(intNumPoints,intIndexStart,intIndexFinish,doubleValueStart,doubleValueFinish,TPoints&Points)
{
intn=0
//fillthearrayZigzagArray
for(inti=ZigzagArray.Total()1i>=0i)
{
TZigzag*Zigzag=ZigzagArray.At(i)//theobtainedizigzagintheZigzagArray
CArrayInt*IndexVertex=Zigzag.IndexVertex//getthearrayoftheindexesofthetopsoftheizigzags
CArrayDouble*ValueVertex=Zigzag.ValueVertex//getthearrayofvaluesofthetopsoftheizigzag
intIndex1=1,Index2=1
//searchtheindexoftheIndexVertexarray,correspondingtothefirstpoint
for(intj=0j<IndexVertex.Total()j++)
{
if(IndexVertex.At(j)>=IndexStart)
{
Index1=j
break
}
}
//searchtheindexoftheIndexVertexarray,correspondingtothelastpoint
for(intj=IndexVertex.Total()1j>=0j)
{
if(IndexVertex.At(j)<=IndexFinish)
{
Index2=j
break
}
}
https://www.mql5.com/en/articles/260
30/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
//ifthefirstandlastpointswerefound
if((Index1!=1)&&(Index2!=1))
{
n=Index2Index1+1//findouthowmanypointswerefound
}
//iftherequirednumberofpointswasfound(equalorgreater)
if(n>=NumPoints)
{
//checkthatthefirstandlasttopscorrespondwiththerequiredtopvalues
if(((ValueStart!=0)&&(ValueVertex.At(Index1)!=ValueStart))||
((ValueFinish!=0)&&(ValueVertex.At(Index1+n1)!=ValueFinish)))continue
//fillthePointsstructure,passedasaparameter
Points.NumPoints=n
ArrayResize(Points.ValuePoints,n)
ArrayResize(Points.IndexPoints,n)
intk=0
//filltheValuePointsandIndexPointsarraysofPointsstructure
for(intj=Index1j<Index1+nj++)
{
Points.ValuePoints[k]=ValueVertex.At(j)
Points.IndexPoints[k]=IndexVertex.At(j)
k++
}
return(true)
}
}
return(false)
}
6.4.TheNotStartedAndNotFinishedWavesfunction:
//++
//|TheNotStartedAndNotFinishedWavesfunction|
//++
voidNotStartedAndNotFinishedWaves(TWave*ParentWave,intNumWave,TNode*Node,stringSubwaves,intLevel)
{
intv1,v2,v3,v4,I
TPointsPoints
TNode*ParentNode,*ChildNode
intIndexWave
stringNameWave
TWave*Wave
inti=0,pos=0,start=0
//Putthewaves,whichwewillbeanalyzingtotheListNameWavearray
stringListNameWave[]
https://www.mql5.com/en/articles/260
31/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
ArrayResize(ListNameWave,ArrayRange(WaveDescription,0))
while(pos!=StringLen(Subwaves)1)
{
pos=StringFind(Subwaves,",",start)
NameWave=StringSubstr(Subwaves,start,posstart)
ListNameWave[i++]=NameWave
start=pos+1
}
intIndexStart=ParentWave.IndexVertex[NumWave1]
intIndexFinish=ParentWave.IndexVertex[NumWave]
doubleValueStart=ParentWave.ValueVertex[NumWave1]
doubleValueFinish=ParentWave.ValueVertex[NumWave]
//findnolessthantwopointsonthepricechartandputthemintothestructurePoints
//iftheyarenotfound,thenexitthefunction
if(FindPoints(2,IndexStart,IndexFinish,ValueStart,ValueFinish,Points)==false)return
//theloopofunbegunandincompletewaveswiththeformula"1<23>"
v1=0
while(v1<=Points.NumPoints2)
{
v2=v1+1
while(v2<=Points.NumPoints1)
{
intj=0
while(j<=i1)
{
//getthenameofthewaveforanalysisfromtheListNameWave
NameWave=ListNameWave[j++]
//findtheindexofthewaveinthestructureWaveDescriptioninorderto
//findoutthenumberofitssubwavesandtheirnames
IndexWave=FindWaveInWaveDescription(NameWave)
if((WaveDescription[IndexWave].NumWave==5)||(WaveDescription[IndexWave].NumWave==3))
{
//createtheobjectofTWaveclassandfillitsfieldsparametersoftheanalyzedwaves
Wave=newTWave
Wave.Name=NameWave
Wave.Level=Level
Wave.Formula="1<23>"
Wave.ValueVertex[0]=0
Wave.ValueVertex[1]=Points.ValuePoints[v1]
Wave.ValueVertex[2]=Points.ValuePoints[v2]
Wave.ValueVertex[3]=0
Wave.ValueVertex[4]=0
Wave.ValueVertex[5]=0
Wave.IndexVertex[0]=IndexStart
Wave.IndexVertex[1]=Points.IndexPoints[v1]
Wave.IndexVertex[2]=Points.IndexPoints[v2]
Wave.IndexVertex[3]=IndexFinish
https://www.mql5.com/en/articles/260
32/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
Wave.IndexVertex[4]=0
Wave.IndexVertex[5]=0
//checkthewavebytherules
if(WaveRules(Wave)==true)
{
//ifawavepassedthecheckbyrules,additintothewavetree
ParentNode=Node.Add(NameWave,Wave)
I=1
//createthefirstsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefirstsubwave,hasnotbeenanalyzed,thenanalyz
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
NotStartedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthesecondsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothesecondsubwave,hasnotbeenanalyzed,thenanaly
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createathirdsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothethirdsubwave,hasnotbeenanalyzed,thenanalyz
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
NotFinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
}
//otherwise,ifthewavedidnotpassbytherules,releasememory
elsedeleteWave
}
}
v2=v2+2
}
v1=v1+2
}
//theloopofunbegunandunfinishedwaveswiththeformula"2<34>"
v2=0
while(v2<=Points.NumPoints2)
{
v3=v2+1
while(v3<=Points.NumPoints1)
{
intj=0
while(j<=i1)
{
//getthenameofthewaveforanalysisfromtheListNameWave
NameWave=ListNameWave[j++]
//findtheindexofthewaveintheWaveDescriptionstructureinordertoknowthenumberofitssymbolsand
https://www.mql5.com/en/articles/260
33/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
IndexWave=FindWaveInWaveDescription(NameWave)
if(WaveDescription[IndexWave].NumWave==5)
{
//createtheobjectofTWaveclassandfillitsfieldsparametersoftheanalyzedwave
Wave=newTWave
Wave.Name=NameWave
Wave.Level=Level
Wave.Formula="2<34>"
Wave.ValueVertex[0]=0
Wave.ValueVertex[1]=0
Wave.ValueVertex[2]=Points.ValuePoints[v2]
Wave.ValueVertex[3]=Points.ValuePoints[v3]
Wave.ValueVertex[4]=0
Wave.ValueVertex[5]=0
Wave.IndexVertex[0]=0
Wave.IndexVertex[1]=IndexStart
Wave.IndexVertex[2]=Points.IndexPoints[v2]
Wave.IndexVertex[3]=Points.IndexPoints[v3]
Wave.IndexVertex[4]=IndexFinish
Wave.IndexVertex[5]=0
//checkthewavebytherules
if(WaveRules(Wave)==true)
{
//ifthewavepassedthecheckforrules,addittothewavestree
ParentNode=Node.Add(NameWave,Wave)
I=2
//createthesecondsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothesecondsubwave,hasnotbeenanalyzed,thenanaly
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
NotStartedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthethirdsubwaveinthwavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothethirdsubwave,hasnotbeenanalyzed,thenanalyz
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthefourthsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefourthsubwave,hasnotbeenanalyzed,thenanaly
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
NotFinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
}
//otherwise,ifthewavedidnotpassthecheckbyrules,releasememory
elsedeleteWave
}
https://www.mql5.com/en/articles/260
34/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
}
v3=v3+2
}
v2=v2+2
}
//theloopoftheunbegunandtheincompletewaveswiththeformula"3<45>"
v3=0
while(v3<=Points.NumPoints2)
{
v4=v3+1
while(v4<=Points.NumPoints1)
{
intj=0
while(j<=i1)
{
//getthenameofthewaveforanalysisfromtheListNameWave
NameWave=ListNameWave[j++]
//findtheindexofthewaveintheWaveDescriptionstructureinorderto
//findoutthenumberofitssymbolsandtheirnames
IndexWave=FindWaveInWaveDescription(NameWave)
if(WaveDescription[IndexWave].NumWave==5)
{
//createtheobjectofTWaveclassandfillitsfieldsparametersoftheanalyzedwave
Wave=newTWave
Wave.Name=NameWave
Wave.Level=Level
Wave.Formula="3<45>"
Wave.ValueVertex[0]=0
Wave.ValueVertex[1]=0
Wave.ValueVertex[2]=0
Wave.ValueVertex[3]=Points.ValuePoints[v3]
Wave.ValueVertex[4]=Points.ValuePoints[v4]
Wave.ValueVertex[5]=0
Wave.IndexVertex[0]=0
Wave.IndexVertex[1]=0
Wave.IndexVertex[2]=IndexStart
Wave.IndexVertex[3]=Points.IndexPoints[v3]
Wave.IndexVertex[4]=Points.IndexPoints[v4]
Wave.IndexVertex[5]=IndexFinish
//checkthewavefortherules
if(WaveRules(Wave)==true)
{
//ifthewavepassedthecheckbytherules,addittothewavestree
ParentNode=Node.Add(NameWave,Wave)
I=3
//createthethirdsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
https://www.mql5.com/en/articles/260
35/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
//iftheintervalofthechart,correspondingtothethirdsubwavehasnotbeenanalyzed,thenanalyze
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
NotStartedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthefourthsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefourthsubwave,hasnotbeenanalyzed,thenanaly
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthefifthsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefifthwave,hasnotbeenanalyzed,thenanalyzeit
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
NotFinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
}
//otherwise,ifthewavehasnotpassedthecheckbytherules,releasethememory
elsedeleteWave
}
}
v4=v4+2
}
v3=v3+2
}
//findnolessthanthreepointsonthepricechartandputtheminthePointsstructure
//iftheywerenotfound,thenexitthefunction
if(FindPoints(3,IndexStart,IndexFinish,ValueStart,ValueFinish,Points)==false)return
//theloopofunbegunandunfinishedwavedwiththeformula"1<234>"
v1=0
while(v1<=Points.NumPoints3)
{
v2=v1+1
while(v2<=Points.NumPoints2)
{
v3=v2+1
while(v3<=Points.NumPoints1)
{
intj=0
while(j<=i1)
{
//getthenameofthewaveforanalysisfromtheListNameWave
NameWave=ListNameWave[j++]
//findtheindexofthewaveintheWaveDescriptionstructureinordertoknowthenumberofitssubwaves
IndexWave=FindWaveInWaveDescription(NameWave)
if(WaveDescription[IndexWave].NumWave==5)
{
//createanobjectofTWaveclassandfillitsfieldsparametersoftheanalyzedwave
https://www.mql5.com/en/articles/260
36/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
Wave=newTWave
Wave.Name=NameWave
Wave.Level=Level
Wave.Formula="1<234>"
Wave.ValueVertex[0]=0
Wave.ValueVertex[1]=Points.ValuePoints[v1]
Wave.ValueVertex[2]=Points.ValuePoints[v2]
Wave.ValueVertex[3]=Points.ValuePoints[v3]
Wave.ValueVertex[4]=0
Wave.ValueVertex[5]=0
Wave.IndexVertex[0]=IndexStart
Wave.IndexVertex[1]=Points.IndexPoints[v1]
Wave.IndexVertex[2]=Points.IndexPoints[v2]
Wave.IndexVertex[3]=Points.IndexPoints[v3]
Wave.IndexVertex[4]=IndexFinish
Wave.IndexVertex[5]=0
//checkthewavebytherules
if(WaveRules(Wave)==true)
{
//ifthewavepassedthecheckbytherules,addittothewavestree
ParentNode=Node.Add(NameWave,Wave)
I=1
//createthefirstsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefirstsubwave,hasnotbeenanalyzed,thenana
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
NotStartedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthesecondsubwaveinthewavedtree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothesecondsubwave,hasnotbeenanalyzed,thenan
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthethirdsubwaveinthewaves
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothethirdsubwave,hasnotbeenanalyzed,thenana
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthefourthsubwaveofthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefourthsubwave,hasnotbeenanalyzed,thenan
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
NotFinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
}
//otherwise,ifthewavedidnotpassbytherules,releasethememory
https://www.mql5.com/en/articles/260
37/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
elsedeleteWave
}
}
v3=v3+2
}
v2=v2+2
}
v1=v1+2
}
//theloopofunbegunandunfinishedwaveswiththeformula"2<345>"
v2=0
while(v2<=Points.NumPoints3)
{
v3=v2+1
while(v3<=Points.NumPoints2)
{
v4=v3+1
while(v4<=Points.NumPoints1)
{
intj=0
while(j<=i1)
{
//getthenameofthewaveforanalysisfromtheListNameWave
NameWave=ListNameWave[j++]
//findtheindexofthewaveintheWaveDescriptionstructureinordertoknowthenumberofthesymbolsa
IndexWave=FindWaveInWaveDescription(NameWave)
if(WaveDescription[IndexWave].NumWave==5)
{
//createtheobjectofTWaveclassandfillitsfieldsparametersoftheanalyzedwave
Wave=newTWave
Wave.Name=NameWave
Wave.Level=Level
Wave.Formula="2<345>"
Wave.ValueVertex[0]=0
Wave.ValueVertex[1]=0
Wave.ValueVertex[2]=Points.ValuePoints[v2]
Wave.ValueVertex[3]=Points.ValuePoints[v3]
Wave.ValueVertex[4]=Points.ValuePoints[v4]
Wave.ValueVertex[5]=0
Wave.IndexVertex[0]=0
Wave.IndexVertex[1]=IndexStart
Wave.IndexVertex[2]=Points.IndexPoints[v2]
Wave.IndexVertex[3]=Points.IndexPoints[v3]
Wave.IndexVertex[4]=Points.IndexPoints[v4]
Wave.IndexVertex[5]=IndexFinish
//checkthewavebytherules
if(WaveRules(Wave)==true)
https://www.mql5.com/en/articles/260
38/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
{
//ifthewavepassedthecheckbytherules,addittothewavestree
ParentNode=Node.Add(NameWave,Wave)
I=2
//createthesecondsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothesecondsubwave,hasnotbeenanalyzed,thenan
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
NotStartedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthethirdsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothethirdsubwave,hasnotbeenanalyzed,thenana
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthefourthsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefourthsubwave,hasnotbeenanalyzed,thenan
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthefifthsubwaveinthewavedtree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefifthsubwave,hasnotbeenanalyzed,thenana
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
NotFinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
}
//otherwise,ifthewavehasnotpassedbytherules,releasethememory
elsedeleteWave
}
}
v4=v4+2
}
v3=v3+2
}
v2=v2+2
}
//findnolessthanfourpointonthepricechartandputthemintothestructurePoints
//ifwedidn'tfindany,thenexitthefunction
if(FindPoints(4,IndexStart,IndexFinish,ValueStart,ValueFinish,Points)==false)return
//theloopofunbegunandunfinishedwaveswiththeformula"1<2345>"
v1=0
while(v1<=Points.NumPoints4)
{
v2=v1+1
while(v2<=Points.NumPoints3)
https://www.mql5.com/en/articles/260
39/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
{
v3=v2+1
while(v3<=Points.NumPoints2)
{
v4=v3+1
while(v4<=Points.NumPoints1)
{
intj=0
while(j<=i1)
{
//getthenameofthewaveforanalysisfromtheListNameWave
NameWave=ListNameWave[j++]
//findtheindexofthewaveintheWaveDescriptionstructureinordertoknowthenumberofsubwaves
IndexWave=FindWaveInWaveDescription(NameWave)
if(WaveDescription[IndexWave].NumWave==5)
{
//createtheobjectTWaveclassandfillitsfieldsparametersoftheanalyzedwave
Wave=newTWave
Wave.Name=NameWave
Wave.Level=Level
Wave.Formula="1<2345>"
Wave.ValueVertex[0]=0
Wave.ValueVertex[1]=Points.ValuePoints[v1]
Wave.ValueVertex[2]=Points.ValuePoints[v2]
Wave.ValueVertex[3]=Points.ValuePoints[v3]
Wave.ValueVertex[4]=Points.ValuePoints[v4]
Wave.ValueVertex[5]=0
Wave.IndexVertex[0]=IndexStart
Wave.IndexVertex[1]=Points.IndexPoints[v1]
Wave.IndexVertex[2]=Points.IndexPoints[v2]
Wave.IndexVertex[3]=Points.IndexPoints[v3]
Wave.IndexVertex[4]=Points.IndexPoints[v4]
Wave.IndexVertex[5]=IndexFinish
//checkthewavebytherules
if(WaveRules(Wave)==true)
{
//ifthewavepassedthecheckbytherules,addittothewavestree
ParentNode=Node.Add(NameWave,Wave)
I=1
//createthefirstsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefirstsubwavehasnotbeenanalyzed,thena
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
NotStartedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthesecondsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
https://www.mql5.com/en/articles/260
40/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
//iftheintervalofthechart,correspondingtothesecondsubwave,hasnotbeenanalyzed,then
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthethirdsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothethirdsubwave,hasnotbeenanalyzed,then
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthefourthsubwaveinthewavedtree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefourthsubwave,hasnotbeenanalyzed,then
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthe5thsubwaveinthewavetree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefourthsubwave,hasnotbeenanalyzed,then
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
NotFinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
}
//otherwise,ifthewavedidnotpassthecheckbytherules,releasethememory
elsedeleteWave
}
}
v4=v4+2
}
v3=v3+2
}
v2=v2+2
}
v1=v1+2
}
//findnolessthanonepointonthepricechartandrecorditintothestructurePoints
//ifwedidn'tfindany,thenexitthefunction
if(FindPoints(1,IndexStart,IndexFinish,ValueStart,ValueFinish,Points)==false)return
//theloopofunbegunandunfinishedwaveswiththeformula"1<2>"
v1=0
while(v1<=Points.NumPoints1)
{
intj=0
while(j<=i1)
{
//getthenameofthewaveforanalysisfromListNameWave
NameWave=ListNameWave[j++]
//findtheindexofthewaveintheWaveDescriptionstructureinordertoknowthenumberofsubwavesandtheir
https://www.mql5.com/en/articles/260
41/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
IndexWave=FindWaveInWaveDescription(NameWave)
if(WaveDescription[IndexWave].NumWave==5||WaveDescription[IndexWave].NumWave==3)
{
//createtheobjectofTWaveclassandfillitsfieldsparametersoftheanalyzedwave
Wave=newTWave
Wave.Name=NameWave
Wave.Level=Level
Wave.Formula="1<2>"
Wave.ValueVertex[0]=0
Wave.ValueVertex[1]=Points.ValuePoints[v1]
Wave.ValueVertex[2]=0
Wave.ValueVertex[3]=0
Wave.ValueVertex[4]=0
Wave.ValueVertex[5]=0
Wave.IndexVertex[0]=IndexStart
Wave.IndexVertex[1]=Points.IndexPoints[v1]
Wave.IndexVertex[2]=IndexFinish
Wave.IndexVertex[3]=0
Wave.IndexVertex[4]=0
Wave.IndexVertex[5]=0
//checkthewavebytherules
if(WaveRules(Wave)==true)
{
//ifthewavepassedthecheckbytherules,addittothewavestree
ParentNode=Node.Add(NameWave,Wave)
I=1
//createthefirstsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefirstsubwave,hasnotbeenanalyzed,thenanalyzei
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
NotStartedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthesecondsubwaveinthewavedtree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothesecondsubwave,hasnotbeenanalyzed,thenanalyze
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
NotFinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
}
//otherwise,ifthewavedidnotpassthecheckbytherules,releasethememory
elsedeleteWave
}
}
v1=v1+1
}
//looptheunbegunandunfinishedwaveswiththeformula"2<3>"
v2=0
while(v2<=Points.NumPoints1)
https://www.mql5.com/en/articles/260
42/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
{
intj=0
while(j<=i1)
{
//getthenameofthewaveforanalysisfromListNameWave
NameWave=ListNameWave[j++]
//findtheindexofthewaveinthestructureWaveDescription,inordertoknowthenumberofitssubwavesand
IndexWave=FindWaveInWaveDescription(NameWave)
if(WaveDescription[IndexWave].NumWave==5||WaveDescription[IndexWave].NumWave==3)
{
//createtheobjectofTWaveclassandfillitsfieldsparametersoftheanalyzedwave
Wave=newTWave
Wave.Name=NameWave
Wave.Level=Level
Wave.Formula="2<3>"
Wave.ValueVertex[0]=0
Wave.ValueVertex[1]=0
Wave.ValueVertex[2]=Points.ValuePoints[v2]
Wave.ValueVertex[3]=0
Wave.ValueVertex[4]=0
Wave.ValueVertex[5]=0
Wave.IndexVertex[0]=0
Wave.IndexVertex[1]=IndexStart
Wave.IndexVertex[2]=Points.IndexPoints[v2]
Wave.IndexVertex[3]=IndexFinish
Wave.IndexVertex[4]=0
Wave.IndexVertex[5]=0
//checkthewavebytherules
if(WaveRules(Wave)==true)
{
//ifthewavepassedthecheckbytherules,addittothewavestree
ParentNode=Node.Add(NameWave,Wave)
I=2
//createthesecondsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothesecondsubwave,hasnotbeenanalyzed,thenanalyze
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
NotStartedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthethirdsubwaveinthewavedtree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothethirdsubwave,hasnotbeenanalyzed,thenanalyzei
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
NotFinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
}
//otherwise,ifthewavedidnotpassbytherules,releasethememory
elsedeleteWave
https://www.mql5.com/en/articles/260
43/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
}
}
v2=v2+1
}
//theloopofunbegunandunfinishedwaveswiththeformula"3<4>"
v3=0
while(v3<=Points.NumPoints1)
{
intj=0
while(j<=i1)
{
//getthenameofthewaveforanalysisfromListNameWave
NameWave=ListNameWave[j++]
//findtheindexofthewaveintheWaveDescriptionstructureonordertoknowthenumberofsubwavedandtheir
IndexWave=FindWaveInWaveDescription(NameWave)
if(WaveDescription[IndexWave].NumWave==5)
{
//createtheobjectofTWaveclassandfillitsfieldsparametersoftheanalyzedwave
Wave=newTWave
Wave.Name=NameWave
Wave.Level=Level
Wave.Formula="3<4>"
Wave.ValueVertex[0]=0
Wave.ValueVertex[1]=0
Wave.ValueVertex[2]=0
Wave.ValueVertex[3]=Points.ValuePoints[v3]
Wave.ValueVertex[4]=0
Wave.ValueVertex[5]=0
Wave.IndexVertex[0]=0
Wave.IndexVertex[1]=0
Wave.IndexVertex[2]=IndexStart
Wave.IndexVertex[3]=Points.IndexPoints[v3]
Wave.IndexVertex[4]=IndexFinish
Wave.IndexVertex[5]=0
//checkthewavebytherules
if(WaveRules(Wave)==true)
{
//ifthewavepassedthecheckbytherules,addittothewavestree
ParentNode=Node.Add(NameWave,Wave)
I=3
//createthethirdsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothethirdsubwave,hasnotbeenanalyzed,thenanalyzei
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
NotStartedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthefourthsubwaveinthewavestree
https://www.mql5.com/en/articles/260
44/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefourthsubwave,hasnotbeenanalyzed,thenanalyze
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
NotFinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
}
//otherwise,ifthewavedidnotpassbytherules,releasethememory
elsedeleteWave
}
}
v3=v3+1
}
//theloopofunbegunandunfinishedwaveswiththeformula"4<5>"
v4=0
while(v4<=Points.NumPoints1)
{
intj=0
while(j<=i1)
{
//getthenameofthewaveforanalysisfromListNameWave
NameWave=ListNameWave[j++]
//findtheindexofthewaveintheWaveDescriptionstructureinordertoknowthenumberofsymbolsandtheirn
IndexWave=FindWaveInWaveDescription(NameWave)
if(WaveDescription[IndexWave].NumWave==5)
{
//createtheobjectofTWaveclassandfillitsfieldsparametersoftheanalyzedwave
Wave=newTWave
Wave.Name=NameWave
Wave.Level=Level
Wave.Formula="4<5>"
Wave.ValueVertex[0]=0
Wave.ValueVertex[1]=0
Wave.ValueVertex[2]=0
Wave.ValueVertex[3]=0
Wave.ValueVertex[4]=Points.ValuePoints[v4]
Wave.ValueVertex[5]=0
Wave.IndexVertex[0]=0
Wave.IndexVertex[1]=0
Wave.IndexVertex[2]=0
Wave.IndexVertex[3]=IndexStart
Wave.IndexVertex[4]=Points.IndexPoints[v4]
Wave.IndexVertex[5]=IndexFinish
//checkthewavebytherules
if(WaveRules(Wave)==true)
{
//ifthewavepassedthecheckbytherules,addittothewavestree
ParentNode=Node.Add(NameWave,Wave)
I=4
https://www.mql5.com/en/articles/260
45/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
//createthefourthsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefourthsubwave,hasnotbeenanalyzed,thenanalyze
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
NotStartedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthefifthsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefifthsubwave,hasnotbeenanalyzed,thenanalyzei
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
NotFinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
}
//otherwise,ifthewavedidnotpassbytherules,releasethememory
elsedeleteWave
}
}
v4=v4+1
}
}
6.5.TheNotStartedWavesfunction:
//++
//|ThefunctionNotStartedWaves|
//++
voidNotStartedWaves(TWave*ParentWave,intNumWave,TNode*Node,stringSubwaves,intLevel)
{
intv1,v2,v3,v4,v5,I
TPointsPoints
TNode*ParentNode,*ChildNode
intIndexWave
stringNameWave
TWave*Wave
inti=0,Pos=0,Start=0
//Putthewaves,whichwewillbeanalyzingtotheListNameWavearray
stringListNameWave[]
ArrayResize(ListNameWave,ArrayRange(WaveDescription,0))
while(Pos!=StringLen(Subwaves)1)
{
Pos=StringFind(Subwaves,",",Start)
NameWave=StringSubstr(Subwaves,Start,PosStart)
ListNameWave[i++]=NameWave
Start=Pos+1
}
intIndexStart=ParentWave.IndexVertex[NumWave1]
https://www.mql5.com/en/articles/260
46/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
intIndexFinish=ParentWave.IndexVertex[NumWave]
doubleValueStart=ParentWave.ValueVertex[NumWave1]
doubleValueFinish=ParentWave.ValueVertex[NumWave]
//findnolessthantwopointsonthepricechartandputthemintothestructurePoints
//ifwedidn'tfindany,thenexitthefunction
if(FindPoints(2,IndexStart,IndexFinish,ValueStart,ValueFinish,Points)==false)return
//looptheunbegunwaveswiththeformula"4<5"
v5=Points.NumPoints1
v4=v51
while(v4>=0)
{
intj=0
while(j<=i1)
{
//getthenameofthewaveforanalysisfromListNameWave
NameWave=ListNameWave[j++]
//findtheindexofthewaveintheWaveDescriptionstructureinordertoknowthenumberofitssubwavesandt
IndexWave=FindWaveInWaveDescription(NameWave)
if(WaveDescription[IndexWave].NumWave==5)
{
//createtheobjectofclassTWaveandfillitsfieldsparametersoftheanalyzedwave
Wave=newTWave
Wave.Name=NameWave
Wave.Level=Level
Wave.Formula="4<5"
Wave.ValueVertex[0]=0
Wave.ValueVertex[1]=0
Wave.ValueVertex[2]=0
Wave.ValueVertex[3]=0
Wave.ValueVertex[4]=Points.ValuePoints[v4]
Wave.ValueVertex[5]=Points.ValuePoints[v5]
Wave.IndexVertex[0]=0
Wave.IndexVertex[1]=0
Wave.IndexVertex[2]=0
Wave.IndexVertex[3]=IndexStart
Wave.IndexVertex[4]=Points.IndexPoints[v4]
Wave.IndexVertex[5]=Points.IndexPoints[v5]
//checkthewavebytherules
if(WaveRules(Wave)==true)
{
//ifthewavepassedthecheckbytherules,addittothewavestree
ParentNode=Node.Add(NameWave,Wave)
I=4
//createthefourthsubwaveinthewavetree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefourthsubwave,hasnotbeenanalyzed,thenanalyze
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
https://www.mql5.com/en/articles/260
47/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
NotStartedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//create5thsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefifthsubwave,hasnotbeenanalyzed,thenanalyzei
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
}
//otherwise,ifthewavedidnotpassthecheckbytherules,releasethememory
elsedeleteWave
}
}
v4=v42
}
//looptheunbegunwaveswiththeformula"2<3"
v3=Points.NumPoints1
v2=v31
while(v2>=0)
{
intj=0
while(j<=i1)
{
//inturn,fromtheListNameWave,drawthenameofthewaveforanalysis
NameWave=ListNameWave[j++]
//findtheindexofthewaveintheWaveDescriptionstructureinordertoknowthenumberofsubwavesandtheir
IndexWave=FindWaveInWaveDescription(NameWave)
if(WaveDescription[IndexWave].NumWave==3)
{
//createtheobjectofclassTWaveandfillitsfieldsparametersoftheanalyzedwave
Wave=newTWave
Wave.Name=NameWave
Wave.Level=Level
Wave.Formula="2<3"
Wave.ValueVertex[0]=0
Wave.ValueVertex[1]=0
Wave.ValueVertex[2]=Points.ValuePoints[v2]
Wave.ValueVertex[3]=Points.ValuePoints[v3]
Wave.ValueVertex[4]=0
Wave.ValueVertex[5]=0
Wave.IndexVertex[0]=0
Wave.IndexVertex[1]=IndexStart
Wave.IndexVertex[2]=Points.IndexPoints[v2]
Wave.IndexVertex[3]=Points.IndexPoints[v3]
Wave.IndexVertex[4]=0
Wave.IndexVertex[5]=0
//checkthewavebytherules
if(WaveRules(Wave)==true)
https://www.mql5.com/en/articles/260
48/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
{
//ifthewavepassedthecheckbytherules,addittothewavestree
ParentNode=Node.Add(NameWave,Wave)
I=2
//createthesecondsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothesecondsubwave,hasnotbeenanalyzed,thenanalyze
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
NotStartedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthethirdsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothethirdsubwave,hasnotbeenanalyzed,thenanalyzei
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
}
//otherwise,ifthewavedidnotpassbytherules,releasethememory
elsedeleteWave
}
}
v2=v22
}
//findnotlessthanthreepointsonthepricechartandputthemintothestructurePoints
//ifwedidn'tfindany,thenexitthefunction
if(FindPoints(3,IndexStart,IndexFinish,ValueStart,ValueFinish,Points)==false)return
//looptheunbegunwaveswiththeformula"3<45"
v5=Points.NumPoints1
v4=v51
while(v4>=1)
{
v3=v41
while(v3>=0)
{
intj=0
while(j<=i1)
{
//getthenameofthewaveforanalysisfromListNameWave
NameWave=ListNameWave[j++]
//findtheindexofthewaveintheWaveDescriptionstructureinordertoknowthenumberofsubwavesandth
IndexWave=FindWaveInWaveDescription(NameWave)
if(WaveDescription[IndexWave].NumWave==5)
{
//createtheobjectofclassTWaveandfillitsfieldsparametersoftheanalyzedwave
Wave=newTWave
Wave.Name=NameWave
Wave.Level=Level
Wave.Formula="3<45"
https://www.mql5.com/en/articles/260
49/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
Wave.ValueVertex[0]=0
Wave.ValueVertex[1]=0
Wave.ValueVertex[2]=0
Wave.ValueVertex[3]=Points.ValuePoints[v3]
Wave.ValueVertex[4]=Points.ValuePoints[v4]
Wave.ValueVertex[5]=Points.ValuePoints[v5]
Wave.IndexVertex[0]=0
Wave.IndexVertex[1]=0
Wave.IndexVertex[2]=IndexStart
Wave.IndexVertex[3]=Points.IndexPoints[v3]
Wave.IndexVertex[4]=Points.IndexPoints[v4]
Wave.IndexVertex[5]=Points.IndexPoints[v5]
//checkthewavebytherules
if(WaveRules(Wave)==true)
{
//ifthewavepassedthecheckbytherules,addittothewavestree
ParentNode=Node.Add(NameWave,Wave)
I=3
//createthethreesubwavesinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothethirdsubwave,hasnotbeenanalyzed,thenanalyz
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
NotStartedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthefourthsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefourthsubwave,hasnotbeenanalyzed,thenanaly
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthefifthsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefifthsubwave,hasnotbeenanalyzed,thenanalyz
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
}
//otherwise,ifthewavedidnotpassbytherules,releasethememory
elsedeleteWave
}
}
v3=v32
}
v4=v42
}
//theloopoftheunbegunwaveswiththeformula"1<23"
v3=Points.NumPoints1
v2=v31
https://www.mql5.com/en/articles/260
50/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
while(v2>=1)
{
v1=v21
while(v1>=0)
{
intj=0
while(j<=i1)
{
//getthenameofthewaveforanalysisfromListNameWave
NameWave=ListNameWave[j++]
//findtheindexofthewaveintheWaveDescriptionstructureinordertoknowthenumberofsubwavesandth
IndexWave=FindWaveInWaveDescription(NameWave)
if(WaveDescription[IndexWave].NumWave==3)
{
//createtheobjectofclassTWaveandfillitsfieldsparametersoftheanalyzedwave
Wave=newTWave
Wave.Name=NameWave
Wave.Level=Level
Wave.Formula="1<23"
Wave.ValueVertex[0]=0
Wave.ValueVertex[1]=Points.ValuePoints[v1]
Wave.ValueVertex[2]=Points.ValuePoints[v2]
Wave.ValueVertex[3]=Points.ValuePoints[v3]
Wave.ValueVertex[4]=0
Wave.ValueVertex[5]=0
Wave.IndexVertex[0]=IndexStart
Wave.IndexVertex[1]=Points.IndexPoints[v1]
Wave.IndexVertex[2]=Points.IndexPoints[v2]
Wave.IndexVertex[3]=Points.IndexPoints[v3]
Wave.IndexVertex[4]=0
Wave.IndexVertex[5]=0
//checkthewavebytherules
if(WaveRules(Wave)==true)
{
//ifthewavepassedthecheckbytherules,addittothewavestree
ParentNode=Node.Add(NameWave,Wave)
I=1
//createthefirstsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefirstsubwave,hasnotbeenanalyzed,thenanalyze
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
NotStartedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthesecondsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothesecondsubwave,hasnotbeenanalyzed,thenanalyz
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
https://www.mql5.com/en/articles/260
51/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthethirdsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothethirdsubwave,hasnotbeenanalyzed,thenanalyz
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
}
//otherwise,ifthewavedidnotpassbytherules,releasethememory
elsedeleteWave
}
}
v1=v12
}
v2=v22
}
//findnolessthanfourpointsonthepricechartandputthemintothestructurePoints
//ifwedidn'tfindany,thenexitthefunction
if(FindPoints(4,IndexStart,IndexFinish,ValueStart,ValueFinish,Points)==false)return
//theloopofunbegunwaveswiththeformula"2<345"
v5=Points.NumPoints1
v4=v51
while(v4>=2)
{
v3=v41
while(v3>=1)
{
v2=v31
while(v2>=0)
{
intj=0
while(j<=i1)
{
//inturn,fromtheListNameWave,drawthenameofthewaveforanalysis
NameWave=ListNameWave[j++]
//findtheindexofthewaveintheWaveDescriptionstructureinordertoknowthenumberofitssubwaves
IndexWave=FindWaveInWaveDescription(NameWave)
if(WaveDescription[IndexWave].NumWave==5)
{
//createtheobjectofclassTWaveandfillitsfieldsparametersoftheanalyzedwave
Wave=newTWave
Wave.Name=NameWave
Wave.Level=Level
Wave.Formula="2<345"
Wave.ValueVertex[0]=0
Wave.ValueVertex[1]=0
Wave.ValueVertex[2]=Points.ValuePoints[v2]
https://www.mql5.com/en/articles/260
52/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
Wave.ValueVertex[3]=Points.ValuePoints[v3]
Wave.ValueVertex[4]=Points.ValuePoints[v4]
Wave.ValueVertex[5]=Points.ValuePoints[v5]
Wave.IndexVertex[0]=0
Wave.IndexVertex[1]=IndexStart
Wave.IndexVertex[2]=Points.IndexPoints[v2]
Wave.IndexVertex[3]=Points.IndexPoints[v3]
Wave.IndexVertex[4]=Points.IndexPoints[v4]
Wave.IndexVertex[5]=Points.IndexPoints[v5]
//checkthewavebytherules
if(WaveRules(Wave)==true)
{
//ifthewavepassedthecheckbytherules,addittothewavestree
ParentNode=Node.Add(NameWave,Wave)
I=2
//createthesecondsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothesecondsubwave,hasnotbeenanalyzed,thenan
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
NotStartedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthethirdsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothethirdsubwave,hasnotbeenanalyzed,thenana
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthefourthsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefourthsubwave,hasnotbeenanalyzed,thenan
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthefifthsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefifthsubwave,hasnotbeenanalyzed,thenana
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
}
//otherwise,ifthewavehasnotpassedtherules,releasethememory
elsedeleteWave
}
}
v2=v22
}
v3=v32
}
https://www.mql5.com/en/articles/260
53/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
v4=v42
}
//findnolessthanfivepointsonthepricechartandrecorditintothestructurePoints
//ifwedidn'tfindany,thenexitthefunction
if(FindPoints(5,IndexStart,IndexFinish,ValueStart,ValueFinish,Points)==false)return
//theloopofunbegunwaveswiththeformula"1<2345"
v5=Points.NumPoints1
v4=v51
while(v4>=3)
{
v3=v41
while(v3>=2)
{
v2=v31
while(v2>=1)
{
v1=v21
while(v1>=0)
{
intj=0
while(j<=i1)
{
//inturn,fromtheListNameWave,drawthenameofthewaveforanalysis
NameWave=ListNameWave[j++]
//findtheindexofthewaveintheWaveDescriptionstructureinordertoknowthenumberofsubwaves
IndexWave=FindWaveInWaveDescription(NameWave)
if(WaveDescription[IndexWave].NumWave==5)
{
//createtheobjectofclassTWaveandfillitsfieldsparametersoftheanalyzedwave
Wave=newTWave
Wave.Name=NameWave
Wave.Level=Level
Wave.Formula="1<2345"
Wave.ValueVertex[0]=0
Wave.ValueVertex[1]=Points.ValuePoints[v1]
Wave.ValueVertex[2]=Points.ValuePoints[v2]
Wave.ValueVertex[3]=Points.ValuePoints[v3]
Wave.ValueVertex[4]=Points.ValuePoints[v4]
Wave.ValueVertex[5]=Points.ValuePoints[v5]
Wave.IndexVertex[0]=IndexStart
Wave.IndexVertex[1]=Points.IndexPoints[v1]
Wave.IndexVertex[2]=Points.IndexPoints[v2]
Wave.IndexVertex[3]=Points.IndexPoints[v3]
Wave.IndexVertex[4]=Points.IndexPoints[v4]
Wave.IndexVertex[5]=Points.IndexPoints[v5]
//checkthewavebytherules
if(WaveRules(Wave)==true)
https://www.mql5.com/en/articles/260
54/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
{
//ifthewavepassedthecheckbytherules,addittothewavestree
ParentNode=Node.Add(NameWave,Wave)
I=1
//createthefirstsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefirstsubwave,hasnotbeenanalyzed,then
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
NotStartedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthesecondsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothesecondsubwave,hasnotbeenanalyzed,then
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthethirdsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothethirdsubwave,hasnotbeenanalyzed,then
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthefourthsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefourthsubwave,hasnotbeenanalyzed,then
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthefifthsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothechart,hasnotbeenanalyzed,thenanalyzei
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
}
//otherwise,ifthewavedidnotpassbytherules,releasethememory
elsedeleteWave
}
}
v1=v12
}
v2=v22
}
v3=v32
}
v4=v42
}
}
https://www.mql5.com/en/articles/260
55/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
6.6.TheNotFinishedWavesfunction:
//++
//|ThefunctionFinishedWaves|
//++
voidNotFinishedWaves(TWave*ParentWave,intNumWave,TNode*Node,stringSubwaves,intLevel)
{
intv0,v1,v2,v3,v4,I
TPointsPoints
TNode*ParentNode,*ChildNode
intIndexWave
stringNameWave
TWave*Wave
inti=0,Pos=0,Start=0
//weputthewaves,whichwewillbeanalyzinginthearrayListNameWaveg
stringListNameWave[]
ArrayResize(ListNameWave,ArrayRange(WaveDescription,0))
while(Pos!=StringLen(Subwaves)1)
{
Pos=StringFind(Subwaves,",",Start)
NameWave=StringSubstr(Subwaves,Start,PosStart)
ListNameWave[i++]=NameWave
Start=Pos+1
}
intIndexStart=ParentWave.IndexVertex[NumWave1]
intIndexFinish=ParentWave.IndexVertex[NumWave]
doubleValueStart=ParentWave.ValueVertex[NumWave1]
doubleValueFinish=ParentWave.ValueVertex[NumWave]
//findnotlessthantwopointsonthepricechartandrecorditintothestructurePoints
//ifwedidn'tfindany,thenexitthefunction
if(FindPoints(2,IndexStart,IndexFinish,ValueStart,ValueFinish,Points)==false)return
//theloopofunfinishedwaveswiththeformula"12>"
v0=0
v1=v0+1
while(v1<=Points.NumPoints1)
{
intj=0
while(j<=i1)
{
//getthenameofthewaveforanalysisfromtheListNameWave
NameWave=ListNameWave[j++]
//findtheindexofthewaveintheWaveDescriptionstructureinordertoknowthenumberofsubwavesandtheir
IndexWave=FindWaveInWaveDescription(NameWave)
if((WaveDescription[IndexWave].NumWave==5)||(WaveDescription[IndexWave].NumWave==3))
{
https://www.mql5.com/en/articles/260
56/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
//createtheobjectofTWaveclassandfillitsfieldsparametersoftheanalyzedwave
Wave=newTWave
Wave.Name=NameWave
Wave.Level=Level
Wave.Formula="12>"
Wave.ValueVertex[0]=Points.ValuePoints[v0]
Wave.ValueVertex[1]=Points.ValuePoints[v1]
Wave.ValueVertex[2]=0
Wave.ValueVertex[3]=0
Wave.ValueVertex[4]=0
Wave.ValueVertex[5]=0
Wave.IndexVertex[0]=Points.IndexPoints[v0]
Wave.IndexVertex[1]=Points.IndexPoints[v1]
Wave.IndexVertex[2]=IndexFinish
Wave.IndexVertex[3]=0
Wave.IndexVertex[4]=0
Wave.IndexVertex[5]=0
//checkthewavebytherules
if(WaveRules(Wave)==true)
{
//ifthewavepassedthecheckbytherules,addittothewavestree
ParentNode=Node.Add(NameWave,Wave)
I=1
//createthefirstsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefirstsubwave,hasnotbeenanalyzed,thenanalyzei
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthesecondsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothesecondsubwave,hasnotbeenanalyzed,thenanalyze
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
NotFinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
}
//otherwise,ifthewavedidnotpassbytherules,releasethememory
elsedeleteWave
}
}
v1=v1+2
}
//findnolessthanthreepointsonthepricechartandputitintothePointsstructure
//ifnonewerefound,thenexitthefunction
if(FindPoints(3,IndexStart,IndexFinish,ValueStart,ValueFinish,Points)==false)return
//theloopofunfinishedwaveswiththeformula"123>"
v0=0
v1=v0+1
https://www.mql5.com/en/articles/260
57/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
while(v1<=Points.NumPoints2)
{
v2=v1+1
while(v2<=Points.NumPoints1)
{
intj=0
while(j<=i1)
{
//getthenameofthewaveforanalysisfromListNameWave
NameWave=ListNameWave[j++]
//findtheindexofthewaveintheWaveDescriptionstructureinordertoknowthenumberofsubwavesandth
IndexWave=FindWaveInWaveDescription(NameWave)
if((WaveDescription[IndexWave].NumWave==5)||(WaveDescription[IndexWave].NumWave==3))
{
//createtheobjectofTWaveclassandfillitsfieldsparametersoftheanalyzedwave
Wave=newTWave
Wave.Name=NameWave
Wave.Level=Level
Wave.Formula="123>"
Wave.ValueVertex[0]=Points.ValuePoints[v0]
Wave.ValueVertex[1]=Points.ValuePoints[v1]
Wave.ValueVertex[2]=Points.ValuePoints[v2]
Wave.ValueVertex[3]=0
Wave.ValueVertex[4]=0
Wave.ValueVertex[5]=0
Wave.IndexVertex[0]=Points.IndexPoints[v0]
Wave.IndexVertex[1]=Points.IndexPoints[v1]
Wave.IndexVertex[2]=Points.IndexPoints[v2]
Wave.IndexVertex[3]=IndexFinish
Wave.IndexVertex[4]=0
Wave.IndexVertex[5]=0
//checkthewavebytherules
if(WaveRules(Wave)==true)
{
//ifthewavepassedthecheckbytherules,addittothewavestree
ParentNode=Node.Add(NameWave,Wave)
I=1
//createthefirstsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefirstsubwave,hasnotbeenanalyzed,thenanalyz
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthesecondsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothesecondsubwave,hasnotbeenanalyzed,thenanaly
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
https://www.mql5.com/en/articles/260
58/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthethirdsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,ofthecorrespondingthirdsubwave,hasnotbeenanalyzed,thenanalyz
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
NotFinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
}
//otherwise,ifthewavedidnotpassbytherules,releasethememory
elsedeleteWave
}
}
v2=v2+2
}
v1=v1+2
}
//findnolessthanfourpointsonthepricechartandrecorditintothePointsstructure
//ifnonewerefound,thenexitthefunction
if(FindPoints(4,IndexStart,IndexFinish,ValueStart,ValueFinish,Points)==false)return
//theloopofunfinishedwaveswiththeformula"1234>"
v0=0
v1=v0+1
while(v1<=Points.NumPoints3)
{
v2=v1+1
while(v2<=Points.NumPoints2)
{
v3=v2+1
while(v3<=Points.NumPoints1)
{
intj=0
while(j<=i1)
{
//getthenameofthewaveforanalysisfromListNameWave
NameWave=ListNameWave[j++]
//findtheindexofthewaveinWaveDescriptionstructureinordertoknowthenumberofsubwavesandthe
IndexWave=FindWaveInWaveDescription(NameWave)
if(WaveDescription[IndexWave].NumWave==5)
{
//createtheobjectofTWaveclassandfillitsfieldsparametersoftheanalyzedwave
Wave=newTWave
Wave.Name=NameWave
Wave.Level=Level
Wave.Formula="1234>"
Wave.ValueVertex[0]=Points.ValuePoints[v0]
Wave.ValueVertex[1]=Points.ValuePoints[v1]
Wave.ValueVertex[2]=Points.ValuePoints[v2]
https://www.mql5.com/en/articles/260
59/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
Wave.ValueVertex[3]=Points.ValuePoints[v3]
Wave.ValueVertex[4]=0
Wave.ValueVertex[5]=0
Wave.IndexVertex[0]=Points.IndexPoints[v0]
Wave.IndexVertex[1]=Points.IndexPoints[v1]
Wave.IndexVertex[2]=Points.IndexPoints[v2]
Wave.IndexVertex[3]=Points.IndexPoints[v3]
Wave.IndexVertex[4]=IndexFinish
Wave.IndexVertex[5]=0
//checkthewavebytherules
if(WaveRules(Wave)==true)
{
//ifthewavepassedthecheckfortherules,addittothewavestree
ParentNode=Node.Add(NameWave,Wave)
I=1
//createthefirstsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefirstsubwave,hasnotbeenanalyzed,thenana
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthesecondsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothesecondsubwave,hasnotbeenanalyzed,thenan
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthethirdsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothethirdsubwave,hasnotbeenanalyzed,thenana
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthefourthsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefourthsubwave,hasnotbeenanalyzed,thenan
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
NotFinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
}
//otherwise,ifthewavedidn'tpassbytherules,releasethememory
elsedeleteWave
}
}
v3=v3+2
}
v2=v2+2
}
https://www.mql5.com/en/articles/260
60/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
v1=v1+2
}
//findnolessthanfivepointsonthepricechartandputthemintothestructurePoints
//ifnonewerefound,exitthefunction
if(FindPoints(5,IndexStart,IndexFinish,ValueStart,ValueFinish,Points)==false)return
//theloopofunfinishedwaveswiththeformula"12345>"
v0=0
v1=v0+1
while(v1<=Points.NumPoints4)
{
v2=v1+1
while(v2<=Points.NumPoints3)
{
v3=v2+1
while(v3<=Points.NumPoints2)
{
v4=v3+1
while(v4<=Points.NumPoints1)
{
intj=0
while(j<=i1)
{
//getthenameofthewaveforanalysisfromListNameWave
NameWave=ListNameWave[j++]
//findtheindexofthewaveintheWaveDescriptionstructureinordertoknowthenumberofitssubwa
IndexWave=FindWaveInWaveDescription(NameWave)
if(WaveDescription[IndexWave].NumWave==5)
{
//createtheobjectofTWaveclassandfillitsfieldsparametersoftheanalyzedwave
Wave=newTWave
Wave.Name=NameWave
Wave.Level=Level
Wave.Formula="12345>"
Wave.ValueVertex[0]=Points.ValuePoints[v0]
Wave.ValueVertex[1]=Points.ValuePoints[v1]
Wave.ValueVertex[2]=Points.ValuePoints[v2]
Wave.ValueVertex[3]=Points.ValuePoints[v3]
Wave.ValueVertex[4]=Points.ValuePoints[v4]
Wave.ValueVertex[5]=0
Wave.IndexVertex[0]=Points.IndexPoints[v0]
Wave.IndexVertex[1]=Points.IndexPoints[v1]
Wave.IndexVertex[2]=Points.IndexPoints[v2]
Wave.IndexVertex[3]=Points.IndexPoints[v3]
Wave.IndexVertex[4]=Points.IndexPoints[v4]
Wave.IndexVertex[5]=IndexFinish
//checkthewavebytherules
if(WaveRules(Wave)==true)
https://www.mql5.com/en/articles/260
61/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
{
//ifthewavepassedthecheckbytherules,addittothewavestree
ParentNode=Node.Add(NameWave,Wave)
I=1
//createthefirstsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefirstsubwave,hasnotbeenanalyzed,then
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthesecondsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothesecondsubwave,hasnotbeenanalyzed,then
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthethirdsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothethirdsubwave,hasnotbeenanalyzed,then
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthefourthsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefourthsubwave,hasnotbeenanalyzed,then
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthefifthsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefifthsubwave,hasnotbeenanalyzed,then
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
NotFinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
}
//otherwise,ifthewavedidnotpassbytherules,releasethememory
elsedeleteWave
}
}
v4=v4+2
}
v3=v3+2
}
v2=v2+2
}
v1=v1+2
}
}
https://www.mql5.com/en/articles/260
62/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
6.7.TheFinishedWavesfunction:
//++
//|TheFinishedWavesfunction|
//++
voidFinishedWaves(TWave*ParentWave,intNumWave,TNode*Node,stringSubwaves,intLevel)
{
intv0,v1,v2,v3,v4,v5,I
TPointsPoints
TNode*ParentNode,*ChildNode
intIndexWave
stringNameWave
TWave*Wave
inti=0,Pos=0,Start=0
//Putthewaves,whichwewillbeanalyzingtotheListNameWavearray
stringListNameWave[]
ArrayResize(ListNameWave,ArrayRange(WaveDescription,0))
while(Pos!=StringLen(Subwaves)1)
{
Pos=StringFind(Subwaves,",",Start)
NameWave=StringSubstr(Subwaves,Start,PosStart)
ListNameWave[i++]=NameWave
Start=Pos+1
}
intIndexStart=ParentWave.IndexVertex[NumWave1]
intIndexFinish=ParentWave.IndexVertex[NumWave]
doubleValueStart=ParentWave.ValueVertex[NumWave1]
doubleValueFinish=ParentWave.ValueVertex[NumWave]
//findnolessthanfourpointsonthepricechartandputthemintothestructurePoints
//ifnonewerefound,thenexitthefunction
if(FindPoints(4,IndexStart,IndexFinish,ValueStart,ValueFinish,Points)==false)return
//theloopofcompletewaveswiththeformula"123"
v0=0
v1=1
v3=Points.NumPoints1
while(v1<=v32)
{
v2=v1+1
while(v2<=v31)
{
intj=0
while(j<=i1)
{
//intuen,fromListNameWave,drawthenameofthewaveforanalysis
NameWave=ListNameWave[j++]
https://www.mql5.com/en/articles/260
63/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
//findtheindexofthewaveinthestructureWaveDescriptioninordertoknowthenumberofsubwavesandit
IndexWave=FindWaveInWaveDescription(NameWave)
if(WaveDescription[IndexWave].NumWave==3)
{
//createtheobjectofclassTWaveandfillitsfieldsparametersoftheanalyzedwave
Wave=newTWave
Wave.Name=NameWave
Wave.Formula="123"
Wave.Level=Level
Wave.ValueVertex[0]=Points.ValuePoints[v0]
Wave.ValueVertex[1]=Points.ValuePoints[v1]
Wave.ValueVertex[2]=Points.ValuePoints[v2]
Wave.ValueVertex[3]=Points.ValuePoints[v3]
Wave.ValueVertex[4]=0
Wave.ValueVertex[5]=0
Wave.IndexVertex[0]=Points.IndexPoints[v0]
Wave.IndexVertex[1]=Points.IndexPoints[v1]
Wave.IndexVertex[2]=Points.IndexPoints[v2]
Wave.IndexVertex[3]=Points.IndexPoints[v3]
Wave.IndexVertex[4]=0
Wave.IndexVertex[5]=0
//checkthewavebytherules
if(WaveRules(Wave)==true)
{
//ifthewavepassedthecheckbytherules,addittothewavestree
ParentNode=Node.Add(NameWave,Wave)
I=1
//createthefirstsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(i))
//iftheintervalofthechart,correspondingtothefirstsubwave,hasnotbeenanalyzed,thenanalyz
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthesecondsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(i))
//iftheintervalofthechart,correspondingtothesecondsubwave,hasnotbeenanalyzed,thenanaly
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthethirdsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothethirdsubwave,hasnotbeenanalyzed,thenanalyz
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
}
//otherwise,ifthewavedidnotpassthecheckbytherules,releasethememory
elsedeleteWave
https://www.mql5.com/en/articles/260
64/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
}
}
v2=v2+2
}
v1=v1+2
}
//findnolessthansixpointsonthepricechartandputthemintothestructurePoints
//ifnonewerefound,thenexitthefunction
if(FindPoints(6,IndexStart,IndexFinish,ValueStart,ValueFinish,Points)==false)return
//theloopofcompletewaveswiththeformula"12345"
v0=0
v1=1
v5=Points.NumPoints1
while(v1<=v54)
{
v2=v1+1
while(v2<=v53)
{
v3=v2+1
while(v3<=v52)
{
v4=v3+1
while(v4<=v51)
{
intj=0
while(j<=i1)
{
//getthenameofthewaveforanalysisfromListNameWave
NameWave=ListNameWave[j++]
//findtheindexofthewaveintheWaveDescriptionstructureinordertoknowthenumberofitssubwa
IndexWave=FindWaveInWaveDescription(NameWave)
if(WaveDescription[IndexWave].NumWave==5)
{
//createtheobjectofclassTWaveandfillitsfieldsparametersoftheanalyzedwave
Wave=newTWave
Wave.Name=NameWave
Wave.Level=Level
Wave.Formula="12345"
Wave.ValueVertex[0]=Points.ValuePoints[v0]
Wave.ValueVertex[1]=Points.ValuePoints[v1]
Wave.ValueVertex[2]=Points.ValuePoints[v2]
Wave.ValueVertex[3]=Points.ValuePoints[v3]
Wave.ValueVertex[4]=Points.ValuePoints[v4]
Wave.ValueVertex[5]=Points.ValuePoints[v5]
Wave.IndexVertex[0]=Points.IndexPoints[v0]
Wave.IndexVertex[1]=Points.IndexPoints[v1]
Wave.IndexVertex[2]=Points.IndexPoints[v2]
https://www.mql5.com/en/articles/260
65/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
Wave.IndexVertex[3]=Points.IndexPoints[v3]
Wave.IndexVertex[4]=Points.IndexPoints[v4]
Wave.IndexVertex[5]=Points.IndexPoints[v5]
//checkthewavebytherules
if(WaveRules(Wave)==true)
{
//ifthewavepassedthecheckbytherules,addittothewavestree
ParentNode=Node.Add(NameWave,Wave)
I=1
//createthefirstsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefirstsubwave,hasnotbeenanalyzed,then
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthesecondsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothesecondsubwave,hasnotbeenanalyzed,then
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthethirdsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothethirdsubwave,hasnotbeenanalyzed,then
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthefourthsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefourthsubwave,hasnotbeenanalyzed,then
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
I++
//createthefifthsubwaveinthewavestree
ChildNode=ParentNode.Add(IntegerToString(I))
//iftheintervalofthechart,correspondingtothefifthsubwave,hasnotbeenanalyzed,then
if(Already(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I])==false)
FinishedWaves(Wave,I,ChildNode,WaveDescription[IndexWave].Subwaves[I],Level+1)
}
//otherwise,ifthewavedidnotpassthecheckbytherules,releasethememory
elsedeleteWave
}
}
v4=v4+2
}
v3=v3+2
}
https://www.mql5.com/en/articles/260
66/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
v2=v2+2
}
v1=v1+2
}
}
6.8.TheFindWaveInWaveDescriptionfunction:
//++
//|TheFindWaveInWaveDescriptionfunction|
//++
intFindWaveInWaveDescription(stringNameWave)
{
for(inti=0i<ArrayRange(WaveDescription,0)i++)
if(WaveDescription[i].NameWave==NameWave)return(i)
return(1)
}
6.9.TheAlreadyfunction:
//++
//|TheAlreadyfunction|
//++
boolAlready(TWave*Wave,intNumWave,TNode*Node,stringSubwaves)
{
//obtainthenecessaryparametersofthewaveorthegroupofwaves
intIndexStart=Wave.IndexVertex[NumWave1]
intIndexFinish=Wave.IndexVertex[NumWave]
doubleValueStart=Wave.ValueVertex[NumWave1]
doubleValueFinish=Wave.ValueVertex[NumWave]
//intheloop,proceedthearrayNodeInfoArrayforthesearchofthemarkedupsectionofthechart
for(inti=NodeInfoArray.Total()1i>=0i)
{
TNodeInfo*NodeInfo=NodeInfoArray.At(i)
//iftherequiredsectionhasalreadybeenmarkedup
if(NodeInfo.Subwaves==Subwaves&&(NodeInfo.ValueStart==ValueStart)&&
(NodeInfo.ValueFinish==ValueFinish)&&(NodeInfo.IndexStart==IndexStart)&&
(NodeInfo.IndexFinish==IndexFinish))
{
//addthechildnodesofthefoundnodeintothechildnodesofthenewnode
for(intj=0j<NodeInfo.Node.Child.Total()j++)
Node.Child.Add(NodeInfo.Node.Child.At(j))
return(true)//exitthefunction
}
https://www.mql5.com/en/articles/260
67/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
}
//iftheintervalhasnotbeenmarkedupearlier,thenrecorditsdataintothearrayNodeInfoArray
TNodeInfo*NodeInfo=newTNodeInfo
NodeInfo.IndexStart=IndexStart
NodeInfo.IndexFinish=IndexFinish
NodeInfo.ValueStart=ValueStart
NodeInfo.ValueFinish=ValueFinish
NodeInfo.Subwaves=Subwaves
NodeInfo.Node=Node
NodeInfoArray.Add(NodeInfo)
return(false)
}
6.10.TheWaveRulesfunction:
intIndexVertex[6]//theindexesofthetopsofthewave
doubleValueVertex[6],Maximum[6],Minimum[6]//thebaluesofthetopsofthewave,aswellasthemaximumandminimumval
stringTrend//directionofthetrend"Up"or"Down"
stringFormula//theformulaofthewave"1<23>"or"123>"etc.
intFixedVertex[6]//informationaboutthetopsofthewave,whetherornottheyhavebeenf
//++
//|ThefunctionWaveRules|
//++
boolWaveRules(TWave*Wave)
{
Formula=Wave.Formula
boolResult=false
//fillthearrayIndexVertexandValueVertexindexesofthetopsandvaluesofthetopsofthewave
for(inti=0i<=5i++)
{
IndexVertex[i]=Wave.IndexVertex[i]
ValueVertex[i]=Wave.ValueVertex[i]
FixedVertex[i]=1
}
//fillthearrayFixedVertex,thebaluesofwhichindicatewhetherornotthetopofthewaveisfixed
intPos1=StringFind(Formula,"<")
stringStr
if(Pos1>0)
{
Str=ShortToString(StringGetCharacter(Formula,Pos11))
FixedVertex[StringToInteger(Str)]=1
FixedVertex[StringToInteger(Str)1]=0
Pos1=StringToInteger(Str)+1
}
elsePos1=0
https://www.mql5.com/en/articles/260
68/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
intPos2=StringFind(Formula,">")
if(Pos2>0)
{
Str=ShortToString(StringGetCharacter(Formula,Pos21))
FixedVertex[StringToInteger(Str)]=0
Pos2=StringToInteger(Str)1
}
else
{
Pos2=StringLen(Formula)
Str=ShortToString(StringGetCharacter(Formula,Pos21))
Pos2=StringToInteger(Str)
}
for(inti=Pos1i<=Pos2i++)
FixedVertex[i]=1
doubleHigh[],Low[]
ArrayResize(High,ArrayRange(rates,0))
ArrayResize(Low,ArrayRange(rates,0))
//findthemaximumsandminimumsofthewaves
for(inti=1i<=5i++)
{
Maximum[i]=rates[IndexVertex[i]].high
Minimum[i]=rates[IndexVertex[i1]].low
for(intj=IndexVertex[i1]j<=IndexVertex[i]j++)
{
if(rates[j].high>Maximum[i])Maximum[i]=rates[j].high
if(rates[j].low<Minimum[i])Minimum[i]=rates[j].low
}
}
//findoutthetrend
if((FixedVertex[0]==1&&ValueVertex[0]==rates[IndexVertex[0]].low)||
(FixedVertex[1]==1&&ValueVertex[1]==rates[IndexVertex[1]].high)||
(FixedVertex[2]==1&&ValueVertex[2]==rates[IndexVertex[2]].low)||
(FixedVertex[3]==1&&ValueVertex[3]==rates[IndexVertex[3]].high)||
(FixedVertex[4]==1&&ValueVertex[4]==rates[IndexVertex[4]].low)||
(FixedVertex[5]==1&&ValueVertex[5]==rates[IndexVertex[5]].high))
Trend="Up"
elseTrend="Down"
//checktherequiredwavebytherules
if(Wave.Name=="Impulse")
{
if(VertexAAboveVertexB(1,0,true)>=0&&VertexAAboveVertexB(2,0,true)>=0&&
VertexAAboveVertexB(1,2,false)>=0&&VertexAAboveVertexB(3,2,true)>=0&&
VertexAAboveVertexB(3,1,false)>=0&&VertexAAboveVertexB(4,1,true)>=0&&
VertexAAboveVertexB(3,4,false)>=0&&VertexAAboveVertexB(5,4,true)>=0&&
(WaveAMoreWaveB(3,1)>=0||WaveAMoreWaveB(3,5)>=0))
Result=true
https://www.mql5.com/en/articles/260
69/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
}
elseif(Wave.Name=="LeadingDiagonal")
{
if(VertexAAboveVertexB(1,0,true)>=0&&VertexAAboveVertexB(2,0,true)>=0&&
VertexAAboveVertexB(1,2,false)>=0&&VertexAAboveVertexB(3,2,true)>=0&&
VertexAAboveVertexB(3,1,false)>=0&&VertexAAboveVertexB(4,2,true)>=0&&
VertexAAboveVertexB(1,4,false)>=0&&
VertexAAboveVertexB(3,4,false)>=0&&VertexAAboveVertexB(5,4,true)>=0&&
(WaveAMoreWaveB(3,1)>=0||WaveAMoreWaveB(3,5)>=0))
Result=true
}
elseif(Wave.Name=="Diagonal")
{
if(VertexAAboveVertexB(1,0,true)>=0&&VertexAAboveVertexB(2,0,true)>=0&&
VertexAAboveVertexB(1,2,false)>=0&&VertexAAboveVertexB(3,2,true)>=0&&
VertexAAboveVertexB(3,1,false)>=0&&VertexAAboveVertexB(4,2,true)>=0&&
VertexAAboveVertexB(3,4,false)>=0&&VertexAAboveVertexB(5,4,true)>=0&&
(WaveAMoreWaveB(3,1)>=0||WaveAMoreWaveB(3,5)>=0))
Result=true
}
elseif(Wave.Name=="Zigzag")
{
if(VertexAAboveVertexB(1,0,true)>=0&&VertexAAboveVertexB(2,0,true)>=0&&
VertexAAboveVertexB(1,2,false)>=0&&VertexAAboveVertexB(3,2,true)>=0&&
VertexAAboveVertexB(3,1,false)>=0)
Result=true
}
elseif(Wave.Name=="Flat")
{
if(VertexAAboveVertexB(1,0,false)>=0&&
VertexAAboveVertexB(1,2,false)>=0&&VertexAAboveVertexB(3,2,true)>=0)
Result=true
}
elseif(Wave.Name=="DoubleZigzag")
{
if(VertexAAboveVertexB(1,0,true)>=0&&VertexAAboveVertexB(2,0,true)>=0&&
VertexAAboveVertexB(1,2,false)>=0&&VertexAAboveVertexB(3,2,true)>=0&&
VertexAAboveVertexB(3,1,false)>=0)
Result=true
}
elseif(Wave.Name=="DoubleThree")
{
if(VertexAAboveVertexB(1,0,true)>=0&&
VertexAAboveVertexB(1,2,false)>=0&&VertexAAboveVertexB(3,2,false)>=0)
Result=true
}
elseif(Wave.Name=="TripleZigzag")
https://www.mql5.com/en/articles/260
70/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
{
if(VertexAAboveVertexB(1,0,true)>=0&&VertexAAboveVertexB(2,0,true)>=0&&
VertexAAboveVertexB(1,2,false)>=0&&VertexAAboveVertexB(3,2,true)>=0&&
VertexAAboveVertexB(3,1,false)>=0&&VertexAAboveVertexB(5,3,false)&&
VertexAAboveVertexB(3,4,false)>=0&&VertexAAboveVertexB(5,4,true)>=0)
Result=true
}
elseif(Wave.Name=="TripleThree")
{
if(VertexAAboveVertexB(1,0,true)>=0&&
VertexAAboveVertexB(1,2,false)>=0&&VertexAAboveVertexB(3,2,false)>=0&&
VertexAAboveVertexB(3,4,false)>=0&&VertexAAboveVertexB(5,4,false)>=0)
Result=true
}
elseif(Wave.Name=="ContractingTriangle")
{
if(VertexAAboveVertexB(1,0,false)>=0&&VertexAAboveVertexB(1,2,false)>=0&&VertexAAboveVertexB(3,2,false)>=
VertexAAboveVertexB(3,4,false)>=0&&VertexAAboveVertexB(5,4,false)>=0&&
WaveAMoreWaveB(2,3)>=0&&WaveAMoreWaveB(3,4)>=0&&WaveAMoreWaveB(4,5)>=0)
Result=true
}
elseif(Wave.Name=="ExpandingTriangle")
{
if(VertexAAboveVertexB(1,0,false)>=0&&VertexAAboveVertexB(1,2,false)>=0&&VertexAAboveVertexB(3,2,false)>=
VertexAAboveVertexB(3,4,false)>=0&&VertexAAboveVertexB(5,4,false)>=0&&
WaveAMoreWaveB(3,2)>=0&&WaveAMoreWaveB(3,2)>=0)
Result=true
}
return(Result)
}
6.11.TheVertexAAboveVertexBfunction:
//++
//|ThefunctionVertexAAboveVertexBcheckswhetherornotthetopAishigherthantopB,|
//|transferredastheparametersofthegivenfunction|
//|thischeckcanbeperformedonlyifthetopsAandBarefixed,|
//|orthetopAisnotfixedandprime,whilethetopBisfixed,|
//|orthetopAisfixed,whilethetopBisnotfixedandodd,|
//|orthetopAisnotfixedandprime,andthetopBisnotfixedandodd|
//++
intVertexAAboveVertexB(intA,intB,boolInternalPoints)
{
doubleVA=0,VB=0,VC=0
intIA=0,IB=0
https://www.mql5.com/en/articles/260
71/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
intResult=0
if(A>=B)
{
IA=A
IB=B
}
elseif(A<B)
{
IA=B
IB=A
}
//iftheinternalpointsofthewavemustbetakenintoconsideration
if(InternalPoints==true)
{
if((Trend=="Up")&&((IA%2==0)||((IAIB==1)&&(IB%2==0))))
{
VA=Minimum[IA]
IA=IAIA%2
}
elseif((Trend=="Down")&&((IA%2==0)||((IAIB==1)&&(IB%2==0))))
{
VA=Maximum[IA]
IA=IAIA%2
}
elseif((Trend=="Up")&&((IA%2==1)||((IAIB==1)&&(IB%2==1))))
{
VA=Maximum[IA]
IA=IA(1IA%2)
}
elseif((Trend=="Down")&&(IA%2==1)||((IAIB==1)&&(IB%2==1)))
{
VA=Minimum[IA]
IA=IA(1IA%2)
}
VB=ValueVertex[IB]
}
else
{
VA=ValueVertex[IA]
VB=ValueVertex[IB]
}
if(A>B)
{
A=IA
B=IB
}
elseif(A<B)
https://www.mql5.com/en/articles/260
72/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
{
A=IB
B=IA
VC=VA
VA=VB
VB=VC
}
if(((FixedVertex[A]==1)&&(FixedVertex[B]==1))||
((FixedVertex[A]==0)&&(A%2==0)&&(FixedVertex[B]==1))||
((FixedVertex[A]==1)&&(FixedVertex[B]==0)&&(B%2==1))||
((FixedVertex[A]==0)&(A%2==0)&&(FixedVertex[B]==0)&&(B%2==1)))
{
if(((Trend=="Up")&&(VA>=VB))||((Trend=="Down")&&(VA<=VB)))
Result=1
else
Result=1
}
return(Result)
}
6.12.TheWaveAMoreWaveBfunction:
//++
//|ThefunctionWaveAMoreWaveBcheckswhetherornotthewaveAislargerthanthewaveB,|
//|transferredastheparametersofthegivenfunction|
//|thischeckcanbeperformedonlyifwaveAiscomplete,|
//|andwaveBisincompleteorincompleteandunbegun|
//++
intWaveAMoreWaveB(intA,intB)
{
intResult=0
doubleLengthWaveA=0,LengthWaveB=0
if(FixedVertex[A]==1&&FixedVertex[A1]==1&&(FixedVertex[B]==1||FixedVertex[B1]==1))
{
LengthWaveA=MathAbs(ValueVertex[A]ValueVertex[A1])
if(FixedVertex[B]==1&&FixedVertex[B1]==1)LengthWaveB=MathAbs(ValueVertex[B]ValueVertex[B1])
elseif(FixedVertex[B]==1&&FixedVertex[B1]==0)
{
if(Trend=="Up")LengthWaveB=MathAbs(ValueVertex[B]Minimum[B])
elseLengthWaveB=MathAbs(ValueVertex[B]Maximum[B])
}
elseif(FixedVertex[B]==0&&FixedVertex[B1]==1)
{
if(Trend=="Up")LengthWaveB=MathAbs(ValueVertex[B1]Minimum[B1])
elseLengthWaveB=MathAbs(ValueVertex[B1]Maximum[B1])
}
https://www.mql5.com/en/articles/260
73/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
if(LengthWaveA>LengthWaveB)Result=1
elseResult=1
}
return(Result)
}
6.13.TheClearTreefunction:
//++
//|ThefunctionofclearingthewavestreewiththetopnodeNode|
//++
voidClearTree(TNode*Node)
{
if(CheckPointer(Node)!=POINTER_INVALID)
{
for(inti=0i<Node.Child.Total()i++)
ClearTree(Node.Child.At(i))
deleteNode.Child
if(CheckPointer(Node.Wave)!=POINTER_INVALID)deleteNode.Wave
deleteNode
}
}
6.14.TheClearNodeInfoArrayfunction:
//++
//|ThefunctionofclearingtheNodeInfoArrayarray|
//++
voidClearNodeInfoArray()
{
for(inti=NodeInfoArray.Total()1i>=0i)
{
TNodeInfo*NodeInfo=NodeInfoArray.At(i)
if(CheckPointer(NodeInfo.Node)!=POINTER_INVALID)deleteNodeInfo.Node
deleteNodeInfo
}
NodeInfoArray.Clear()
}
6.15.TheClearZigzagArrayfunction:
//++
//|ThefunctionofclearingtheZigzagArrayarray|
//++
voidClearZigzagArray()
https://www.mql5.com/en/articles/260
74/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
{
for(inti=0i<ZigzagArray.Total()i++)
{
TZigzag*Zigzag=ZigzagArray.At(i)
deleteZigzag.IndexVertex
deleteZigzag.ValueVertex
deleteZigzag
}
ZigzagArray.Clear()
}
6.16.TheFillLabelArrayfunction:
CArrayObj*LabelArray[]
intLevelMax=0
//++
//|TheFillLabelArrayfunction|
//++
voidFillLabelArray(TNode*Node)
{
if(Node.Child.Total()>0)
{
//obtainthefirstnode
TNode*ChildNode=Node.Child.At(0)
//obtainthestructure,inwhichtheinformationaboutthewaveisstored
TWave*Wave=ChildNode.Wave
stringText
//ifthereisafirsttop
if(Wave.ValueVertex[1]>0)
{
//markthetopaccordingtothewave
if(Wave.Name=="Impulse"||Wave.Name=="LeadingDiagonal"||Wave.Name=="Diagonal")
Text="1"
elseif(Wave.Name=="Zigzag"||Wave.Name=="Flat"||Wave.Name=="ExpandingTriangle"||
Wave.Name=="ContractingTriangle")
Text="A"
elseif(Wave.Name=="DoubleZigzag"||Wave.Name=="DoubleThree"||
Wave.Name=="TripleZigzag"||Wave.Name=="TripleThree")
Text="W"
//obtainthearrayoftheArrayObjtops,whichhavetheindexWave.IndexVertex[1]onthepricechart
CArrayObj*ArrayObj=LabelArray[Wave.IndexVertex[1]]
if(CheckPointer(ArrayObj)==POINTER_INVALID)
{
ArrayObj=newCArrayObj
LabelArray[Wave.IndexVertex[1]]=ArrayObj
}
https://www.mql5.com/en/articles/260
75/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
//puttheinformationaboutthetopwiththeindexWave.IndexVertex[1]intothearrayArrayObj
TLabel*Label=newTLabel
Label.Text=Text
Label.Level=Wave.Level
if(Wave.Level>LevelMax)LevelMax=Wave.Level
Label.Value=Wave.ValueVertex[1]
ArrayObj.Add(Label)
}
if(Wave.ValueVertex[2]>0)
{
if(Wave.Name=="Impulse"||Wave.Name=="LeadingDiagonal"||Wave.Name=="Diagonal")
Text="2"
elseif(Wave.Name=="Zigzag"||Wave.Name=="Flat"||Wave.Name=="ExpandingTriangle"||
Wave.Name=="ContractingTriangle")
Text="B"
elseif(Wave.Name=="DoubleZigzag"||Wave.Name=="DoubleThree"||
Wave.Name=="TripleZigzag"||Wave.Name=="TripleThree")
Text="X"
CArrayObj*ArrayObj=LabelArray[Wave.IndexVertex[2]]
if(CheckPointer(ArrayObj)==POINTER_INVALID)
{
ArrayObj=newCArrayObj
LabelArray[Wave.IndexVertex[2]]=ArrayObj
}
TLabel*Label=newTLabel
Label.Text=Text
Label.Level=Wave.Level
if(Wave.Level>LevelMax)LevelMax=Wave.Level
Label.Value=Wave.ValueVertex[2]
ArrayObj.Add(Label)
}
if(Wave.ValueVertex[3]>0)
{
if(Wave.Name=="Impulse"||Wave.Name=="LeadingDiagonal"||Wave.Name=="Diagonal")
Text="3"
elseif(Wave.Name=="Zigzag"||Wave.Name=="Flat"||
Wave.Name=="ExpandingTriangle"||Wave.Name=="ContractingTriangle")
Text="C"
elseif(Wave.Name=="DoubleZigzag"||Wave.Name=="DoubleThree"||
Wave.Name=="TripleZigzag"||Wave.Name=="TripleThree")
Text="Y"
CArrayObj*ArrayObj=LabelArray[Wave.IndexVertex[3]]
if(CheckPointer(ArrayObj)==POINTER_INVALID)
{
ArrayObj=newCArrayObj
LabelArray[Wave.IndexVertex[3]]=ArrayObj
}
https://www.mql5.com/en/articles/260
76/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
TLabel*Label=newTLabel
Label.Text=Text
Label.Level=Wave.Level
if(Wave.Level>LevelMax)LevelMax=Wave.Level
Label.Value=Wave.ValueVertex[3]
ArrayObj.Add(Label)
}
if(Wave.ValueVertex[4]>0)
{
if(Wave.Name=="Impulse"||Wave.Name=="LeadingDiagonal"||Wave.Name=="Diagonal")
Text="4"
elseif(Wave.Name=="ExpandingTriangle"||Wave.Name=="ContractingTriangle")
Text="D"
elseif(Wave.Name=="Triplezigzag"||Wave.Name=="TripleThree")
Text="XX"
CArrayObj*ArrayObj=LabelArray[Wave.IndexVertex[4]]
if(CheckPointer(ArrayObj)==POINTER_INVALID)
{
ArrayObj=newCArrayObj
LabelArray[Wave.IndexVertex[4]]=ArrayObj
}
TLabel*Label=newTLabel
Label.Text=Text
Label.Level=Wave.Level
if(Wave.Level>LevelMax)LevelMax=Wave.Level
Label.Value=Wave.ValueVertex[4]
ArrayObj.Add(Label)
}
if(Wave.ValueVertex[5]>0)
{
if(Wave.Name=="Impulse"||Wave.Name=="LeadingDiagonal"||Wave.Name=="Diagonal")
Text="5"
elseif(Wave.Name=="ExpandingTriangle"||Wave.Name=="ContractingTriangle")
Text="E"
elseif(Wave.Name=="TripleZigzag"||Wave.Name=="TripleThree")
Text="Z"
CArrayObj*ArrayObj=LabelArray[Wave.IndexVertex[5]]
if(CheckPointer(ArrayObj)==POINTER_INVALID)
{
ArrayObj=newCArrayObj
LabelArray[Wave.IndexVertex[5]]=ArrayObj
}
TLabel*Label=newTLabel
Label.Text=Text
Label.Level=Wave.Level
if(Wave.Level>LevelMax)LevelMax=Wave.Level
Label.Value=Wave.ValueVertex[5]
https://www.mql5.com/en/articles/260
77/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
ArrayObj.Add(Label)
}
//proceedthechildnodesofthecurrentnode
for(intj=0j<ChildNode.Child.Total()j++)
FillLabelArray(ChildNode.Child.At(j))
}
}
6.17.TheCreateLabelsfunction:
doublePriceInPixels
CArrayObjObjTextArray//declarethearray,whichwillstorethegraphicalobjectsof"Text"type
//++
//|ThefunctionCreateLabels|
//++
voidCreateLabels()
{
doublePriceMax=ChartGetDouble(0,CHART_PRICE_MAX,0)
doublePriceMin=ChartGetDouble(0,CHART_PRICE_MIN)
intWindowHeight=ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS)
PriceInPixels=(PriceMaxPriceMin)/WindowHeight
intn=0
//looptheLabelArrayarray
for(inti=0i<ArrayRange(LabelArray,0)i++)
{
//iftherearetopswiththesameindexi
if(CheckPointer(LabelArray[i])!=POINTER_INVALID)
{
//obtainthetopswiththesameindexesi
CArrayObj*ArrayObj=LabelArray[i]
//loopthetopsanddisplaythemonthechart
for(intj=ArrayObj.Total()1j>=0j)
{
TLabel*Label=ArrayObj.At(j)
intLevel=LevelMaxLabel.Level
stringText=Label.Text
doubleValue=Label.Value
colorColor
intSize=8
if((Level/3)%2==0)
{
if(Text=="1")Text="i"
elseif(Text=="2")Text="ii"
elseif(Text=="3")Text="iii"
elseif(Text=="4")Text="iv"
elseif(Text=="5")Text="v"
https://www.mql5.com/en/articles/260
78/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
elseif(Text=="A")Text="a"
elseif(Text=="B")Text="b"
elseif(Text=="C")Text="c"
elseif(Text=="D")Text="d"
elseif(Text=="E")Text="e"
elseif(Text=="W")Text="w"
elseif(Text=="X")Text="x"
elseif(Text=="XX")Text="xx"
elseif(Text=="Y")Text="y"
elseif(Text=="Z")Text="z"
}
if(Level%3==2)
{
Color=Green
Text="["+Text+"]"
}
if(Level%3==1)
{
Color=Blue
Text="("+Text+")"
}
if(Level%3==0)
Color=Red
intAnchor
if(Value==rates[i].high)
{
for(intk=ArrayObj.Total()j1k>=0k)
Value=Value+15*PriceInPixels
Anchor=ANCHOR_UPPER
}
elseif(Value==rates[i].low)
{
for(intk=ArrayObj.Total()j1k>=0k)
Value=Value15*PriceInPixels
Anchor=ANCHOR_LOWER
}
CChartObjectText*ObjText=newCChartObjectText
ObjText.Create(0,"wave"+IntegerToString(n),0,rates[i].time,Value)
ObjText.Description(Text)
ObjText.Color(Color)
ObjText.SetInteger(OBJPROP_ANCHOR,Anchor)
ObjText.FontSize(8)
ObjText.Selectable(true)
ObjTextArray.Add(ObjText)
n++
}
}
https://www.mql5.com/en/articles/260
79/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
}
ChartRedraw()
}
6.18.TheCorrectLabelfunction:
//++
//|TheCorrectLabelfunction|
//++
voidCorrectLabel()
{
doublePriceMax=ChartGetDouble(0,CHART_PRICE_MAX,0)
doublePriceMin=ChartGetDouble(0,CHART_PRICE_MIN)
intWindowHeight=ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS)
doubleCurrentPriceInPixels=(PriceMaxPriceMin)/WindowHeight
//loopallofthetextobjects(wavetops)andchangetheirpricesize
for(inti=0i<ObjTextArray.Total()i++)
{
CChartObjectText*ObjText=ObjTextArray.At(i)
doublePriceValue=ObjText.Price(0)
datetimePriceTime=ObjText.Time(0)
intj
for(j=0j<ArrayRange(rates,0)j++)
{
if(rates[j].time==PriceTime)
break
}
doubleOffsetInPixels
if(rates[j].low>=PriceValue)
{
OffsetInPixels=(rates[j].lowPriceValue)/PriceInPixels
ObjText.Price(0,rates[j].lowOffsetInPixels*CurrentPriceInPixels)
}
elseif(rates[j].high<=PriceValue)
{
OffsetInPixels=(PriceValuerates[j].high)/PriceInPixels
ObjText.Price(0,rates[j].high+OffsetInPixels*CurrentPriceInPixels)
}
}
PriceInPixels=CurrentPriceInPixels
}
7.Thefunctionofinitialization,deprovisioning,andeventprocessing
IntheOnInitfunction,thecontrolbuttonsoftheautomaticElliottWaveanalyzerarecreated.
https://www.mql5.com/en/articles/260
80/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
Thefollowingbuttonsarecreated:
1."BeginAnalysis"anautomaticanalysisofthewavesoccurs
2."Showresults"thedisplayofthewavemarksonthechartoccurs,
3."Clearchart"aclearingofthememoryandthedeletionofwavemarksfromthechartoccurs,
4."Correctthemarks"correctsthemarksofwavesonthechart.
TheprocessingofpressingthesebuttonstakesplaceinthefunctionofeventprocessingOnChartEvent.
InthefunctionOnDeinit,allgraphicalobjectsareremovedfromthechart,includingthecontrolbuttons.
#include<Object.mqh>
#include<Arrays\List.mqh>
#include<Arrays\ArrayObj.mqh>
#include<Arrays\ArrayInt.mqh>
#include<Arrays\ArrayDouble.mqh>
#include<Arrays\ArrayString.mqh>
#include<ChartObjects\ChartObjectsTxtControls.mqh>
#include<Elliottwave\Datastructures.mqh>
#include<Elliottwave\Analysisfunctions.mqh>
#include<Elliottwave\Rulesfunctions.mqh>
CChartObjectButton*ButtonStart,*ButtonShow,*ButtonClear,*ButtonCorrect
intState
//++
//|Expertinitializationfunction|
//++
intOnInit()
{
State=0
//createcontrolbuttons
ButtonStart=newCChartObjectButton
ButtonStart.Create(0,"Beginanalysis",0,0,0,150,20)
ButtonStart.Description("Beginanalysis")
ButtonShow=newCChartObjectButton
ButtonShow.Create(0,"Showresults",0,150,0,150,20)
ButtonShow.Description("Showresults")
ButtonClear=newCChartObjectButton
ButtonClear.Create(0,"Clearchart",0,300,0,150,20)
ButtonClear.Description("Clearchart")
ButtonCorrect=newCChartObjectButton
ButtonCorrect.Create(0,"Correctthemarks",0,450,0,150,20)
ButtonCorrect.Description("Correctthemarks")
ChartRedraw()
return(0)
}
//++
//|Expertdeinitializationfunction|
https://www.mql5.com/en/articles/260
81/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
//++
voidOnDeinit(constintreason)
{
//clearwavestree
ClearTree(FirstNode)
//clearNodeInfoArray
ClearNodeInfoArray()
//clearZigzagArray
ClearZigzagArray()
//clearLabelArray
for(inti=0i<ArrayRange(LabelArray,0)i++)
{
CArrayObj*ArrayObj=LabelArray[i]
if(CheckPointer(ArrayObj)!=POINTER_INVALID)
{
for(intj=0j<ArrayObj.Total()j++)
{
TLabel*Label=ArrayObj.At(j)
deleteLabel
}
ArrayObj.Clear()
deleteArrayObj
}
}
//deleteallofthegraphicalelementsfromthechart
for(inti=ObjTextArray.Total()1i>=0i)
{
CChartObjectText*ObjText=ObjTextArray.At(i)
deleteObjText
}
ObjTextArray.Clear()
deleteButtonStart
deleteButtonShow
deleteButtonClear
deleteButtonCorrect
ChartRedraw()
}
MqlRatesrates[]
TNode*FirstNode
//++
//|ChartEventfunction|
//++
voidOnChartEvent(constintid,
constlong&lparam,
constdouble&dparam,
conststring&sparam)
{
https://www.mql5.com/en/articles/260
82/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
if(id==CHARTEVENT_OBJECT_CLICK&&sparam=="Beginanalysis"&&State!=0)
MessageBox("Firstpressthebutton\"Clearchar\"")
if(id==CHARTEVENT_OBJECT_CLICK&&sparam=="Showresults"&&State!=1)
MessageBox("Firstpressthebutton\"Beginanalysis\"")
if(id==CHARTEVENT_OBJECT_CLICK&&sparam=="Clearchart"&&State!=2)
MessageBox("Firstpressthebutton\"Showresults\"")
if(id==CHARTEVENT_OBJECT_CLICK&&sparam=="Correctthemark"&&State!=2)
MessageBox("Firstpressthebutton\"Showresults\"")
//ifthe"Beginanalysis"ispressed
if(id==CHARTEVENT_OBJECT_CLICK&&sparam=="Beginanalysis"&&State==0)
{
//filltheratesarray
CopyRates(NULL,0,0,Bars(_Symbol,_Period),rates)
//fillthearrayZigzagArray
FillZigzagArray(0,Bars(_Symbol,_Period)1)
//createthefirstnode
TWave*Wave=newTWave
Wave.IndexVertex[0]=0
Wave.IndexVertex[1]=Bars(_Symbol,_Period)1
Wave.ValueVertex[0]=0
Wave.ValueVertex[1]=0
FirstNode=newTNode
FirstNode.Child=newCArrayObj
FirstNode.Wave=Wave
FirstNode.Text="Firstnode"
stringNameWaves="Impulse,LeadingDiagonal,Diagonal,Zigzag,Flat,DoubleZigzag,TripleZigzag,
DoubleThree,TripleThree,ContractingTriangle,Expandingtriangle"
//callthesearchforunbegunandincompletewavesfunction
NotStartedAndNotFinishedWaves(Wave,1,FirstNode,NameWaves,0)
MessageBox("Analysisiscomplete")
State=1
ButtonStart.State(false)
ChartRedraw()
}
//if"Showresults"ispressed
if(id==CHARTEVENT_OBJECT_CLICK&&sparam=="Showresults"&&State==1)
{
ArrayResize(LabelArray,ArrayRange(rates,0))
//filltheLabelArrayarray
FillLabelArray(FirstNode)
//showthemarkupofthewavesonthechart
CreateLabels()
State=2
ButtonShow.State(false)
ChartRedraw()
}
https://www.mql5.com/en/articles/260
83/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
//if"Clearchart"ispressed"
if(id==CHARTEVENT_OBJECT_CLICK&&sparam=="Clearchart"&&State==2)
{
//clearthewavestree
ClearTree(FirstNode)
//cleartheNodeInfoArrayarray
ClearNodeInfoArray()
//cleartheZigzagArrayarray
ClearZigzagArray()
//clearLabelArray
for(inti=0i<ArrayRange(LabelArray,0)i++)
{
CArrayObj*ArrayObj=LabelArray[i]
if(CheckPointer(ArrayObj)!=POINTER_INVALID)
{
for(intj=0j<ArrayObj.Total()j++)
{
TLabel*Label=ArrayObj.At(j)
deleteLabel
}
ArrayObj.Clear()
deleteArrayObj
}
}
//deletemarkupfromthechart
for(inti=ObjTextArray.Total()1i>=0i)
{
CChartObjectText*ObjText=ObjTextArray.At(i)
ObjText.Delete()
}
ObjTextArray.Clear()
State=0
ButtonClear.State(false)
ChartRedraw()
}
if(id==CHARTEVENT_OBJECT_CLICK&&sparam=="Correctthemarks"&&State==2)
{
CorrectLabel()
ButtonCorrect.State(false)
ChartRedraw()
}
}
WehavereviewedallofthefunctionsoftheautomaticanalyzerofElliottWaves.
https://www.mql5.com/en/articles/260
84/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
8.Waystoimprovetheprogram
TheautomaticmarkupofElliottWavesprogram,writteninMQL5,hasseveralshortcomings:
1.Animperfectsystemofcheckingthemarkuprules.Forexample,whencheckingbytherules,theFibonaccirelationshipsbetweenthe
wavesarenottakenintoaccount,accordingtoboth,timeandprice.
2.Thepresenceofunpartitionedsectionsonthechart(gapsinthemarkup).Thismeansthatacorrectwavecannotbebuiltbasedonthe
pointstakenfromthegiventimeinterval.Thewayoutofthissituationistoincreasethenumberofpointsinordertoidentifyaparticular
wave.Forexample,tofindtheimpulse,lookfor8ormorepoints,ratherthanfor6point.
3.Theresultsofthemarkupdonotdisplayanyadditionalinformation,forexample,channelsarenotconstructedautomatically,goalsare
notevaluated,etc.
4.Theimplementationofworkingwiththewavestreeisnotprovidedinthisarticle(youcannotselectaspecificversionofthemarkup),
thereforthechartdisplaysonlyoneofmanyoptionsforamarkup(thefirstversionofthemarkup).
5.Regardlessofthefactthatthechartdisplaysonlyonevariantofthewaves,alloftheotheroptionsarestoredinthememoryandtakeup
itsspace.
6.TheprogramfocusesonthemarkupofMonthlytoDailycharts,astheoperationisveryslowwhenthereisalargenumberofbars(it
cantakehourstomarkupanhourlygraph).AnexampleofamarkupofamonthlychartofEURUSDisshowninFigure18.
https://www.mql5.com/en/articles/260
85/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
Figure18.ElliottWaves,identifiedbytheautomaticanalyzerinMQL5
Conclusion
ThisarticlereviewedanalgorithmoftheautomaticanalysisofElliottWaves.ThisalgorithmwasimplementedintheMQL5language.
Theprogramhasanumberofshortcomings,discussedabove,andgivesreasonfortheirfurtherelimination.Ihopethatthisissuewillinterest
thefansoftheElliottWaves,andsoontherewillappearmanyprogramswiththeautomaticanalysisofwaves.
TranslatedfromRussianbyMetaQuotesSoftwareCorp.
Originalarticle:https://www.mql5.com/ru/articles/260
Attachedfiles|
DownloadZIP
elliott_wave_en.zip (150.91KB)
https://www.mql5.com/en/articles/260
86/87
05/01/2017
TheImplementationofAutomaticAnalysisoftheElliottWavesinMQL5MQL5Articles
Warning:AllrightstothesematerialsarereservedbyMQL5Ltd.Copyingorreprintingofthesematerialsinwholeorinpartisprohibited.
MQL5.community
MetaTrader5
Website
Onlinetrading/WebTerminal
MetaTrader5TradingPlatform
About
Windows
Freetechnicalindicatorsandrobots
MetaTrader5UserManual
Timeline
iPhone/iPad
Articlesaboutprogrammingand
trading
MQL5automationlanguage
TermsandConditions
MacOS
MQL5CloudNetwork
PrivacyPolicy
Android
DownloadMetaTrader5
Contactsandrequests
Linux
Ordertradingrobotsonthe
Freelance
MarketofExpertAdvisorsand
applications
InstallPlatform
UninstallPlatform
JoinusdownloadMetaTrader5!
Copyright20002017,MQL5Ltd.
Followforexsignals
LowlatencyforexVPS
Tradersforum
Tradingblogs
https://www.mql5.com/en/articles/260
87/87