MQL5 TUTORIAL ADVANCED CHAIKIN EXPERT ADVISOR

video
play-sharp-fill

In this video we want to talk about the Chaikin Oscillator it’s the indicator here below the candle chart. You see that it is rapidly running between two extremes and it’s trading on the chart right here.
I will speed it up a little bit. This is the graphical representation of the automated trading system; I use the Forex Trading Framework.
In this video we are going to create an entry module that is able trade the Chaikin Oscillator automated.
To do that please click on the little button here, now you should see the Metaeditor window and this is the Forex Trading Framework.
The framework basically is a collection of several functions that can manage the trades and it can also include any kind of entry and this is the one we are going to create now.
So please click on “File /New /Expert Advisor” from template (template), Continue (Next). I will have to call this one: “Check Entry Chaikin mq5” (CheckEntyry_Chaikin.mq5). Continue, continue and finish.
Now you can remove everything above the “OnTick” function and the two comment lines here.
In the “OnTick” function we declare a string variable for the signal – that will be called signal – and we will not have any assigned value because we are going to calculate it later.
The next thing we need to do is to create an array for several prices that will be called: “myPriceArray”. We define the properties for Chaikin Expert Advisor by using the built-in function: “iChaikin” that needs to have some parameters; the first one is for the symbol – that’s the current chart, the second one is “_Period” – that is for the period on the chart, we have values of 3, 10, MODE_EMA and VOLUME_TICK here so let’s right click on the Chaikin Oscillator, select properties and you will see that it calculated based on the tick volume, the Fast Moving Average has a value of 3, the Slow Moving Average has a value of 10 and the method is Exponential and that’s exactly what we use here.
Now let’s sort the prices in the array from the current candle downwards, that can be done by using “ArraySetAsSeries” for the price array (myPriceArray) and with “CopyBuffer” we fill our price array according to the Chaikin definition (ChaikinDefinition) we have created here. We just have one line, in MQL5 that’s represented by buffer zero, the current candle is also zero and we want to calculate 3 candles – that’s the 3 here – and store the result in our price array (myPriceArray).
Now its possible to get the value of the current candle, we will assign it to the variable: “ChaikinValue” and we get it by looking into the value for candle zero of our price array (myPriceArray[0]).
We also want to calculate the value of the candle before – that’s candle 1 – because if candle 1 was above the dotted line here and candle 0 is below the dotted line here that would be a crossover. Here it is the other way around; candle 1 was below the dotted line and candle 0 is above the dotted line.
How do we do that in MQL5? Well, if the Chaikin value (ChaikinValue) is above zero and the previous Chaikin value (PreviousChaikinValue) is below zero that would create a buy signal so we assign the word “buy” to our signal. In the other case if the zero line is crossed from above the Chaikin value (ChaikinValue) would be below zero and the previous Chaikin value (PreviousChaikinValue) would be above zero and in that case we assign the word “sell” to our signal.
In the last step we need to return the signal to our main module by using the “return” function.
In my case the main module is the Forex Trading Framework and within the “OnTick” function of the main module we call the Check Entry (CheckEntry) function of the entry module we just have created.
Okay. Please save the module.
I need to recompile the Framework here. That can be done by clicking on the “Compile” button here or by pressing F7 on the keyboard.
Oh, I have messed something up here! This need to be a string function and it needs to have the name CheckEntry because we are calling it here, so let’s save this and recompile the main Framework. That worked, so now I can click on the little button here or press F4 to go back to Metatrader.
In Metatrader I click on “View/Strategy Tester” or press CTRL and R; that should show the “Strategy Tester” panel here, here I select my main module; that’s the Forex Trading Framework from October 2017. I set the trading risk to 10 here – that’s a high value but I am on a demo account – and I start a new test.
This is our Expert Advisor at work and now you know how to create an Expert Advisor Entry Module for your own framework to trade the Chaikin Oscillator.

Download “MQL5 TUTORIAL - ADVANCED CHAIKIN EXPERT ADVISOR”

AdvancedChaikin.txt – Downloaded 374 times – 1.11 KB