With MQL5 for Metatrader5 we can create an Expert Advisor for the Forex Trading Market that is able to determine if the Bulls or the Bears dominate the Forex Market right now.
In this video we are going to talk about the Bulls power indicator.
It’s an oscillator, and it was created to tell the traders if the Bulls are stronger than the Bears.
When you zoom in into this indicator you will see, that the indicator shows you the biggest peak when the price is very high and when the indicator changes from below the line to above the line that could mean that the price will go up for a while.
The Bulls Power oscillator was also developed by Alexander Elder; you might know his book- Trading for a living.
The Bulls power indicator is also calculated on the basis of the last thirteen candles and it is said the indicator is better to use together with the Trend indicator like a moving average for example.
The Bulls and the Bears power indicators are both integrated in Meta Trader 5. If you click on Insert, indicator, oscillators, you will see the Bears power oscillator and we have already created another video for this one, and this time we are going to create an Expert Advisor for the Bulls power.
You see these are the thirteen candles for the calculation and this is how it looks like.
Now how can we create an Expert Advisor for this indicator? First of all please click on the little button over here or hit the F4 key.
That will bring up the Meta Editor and here we want to select File, New Expert Advisor from template, continue.
We will call it simple Bulls power, continue, continue, finish.
And now we want to delete everything above the Ontick function. Please also delete the two comment lines here.
And now we want to create a double array called my price array, and it will be an array for several prices.
And in the next step we are going to create a Bull’s power definition by using the iBullsPower function that is built in with MQL 5, and the calculation should be for the current symbol on the chart and the selected period.
That might be Euro, US dollar, and the sixty minutes chart for example, and we want to calculate the value for the last thirteen candles.
Now that we have done that, we want to sort the price from the current candle downwards by using the arraysetasseries function for the price array we have created here.
And after that we use copy buffer according to our definition from here for the first line or value of the indicator .
That’s zero here, from the current candle zero for three candles and we want to store the result in the price array here.
And now we need to get the value of the current candle, we have created the float variable called Bulls Power value for the current candle in the price array.
And the last step in our little Expert Advisor would be to create a chart output that will show the text Bulls power value directly on your chart by using the comment function.
Now please click on the compile button here or press the F7 key, okay we have missed a semicolon, let’s repeat that, and now it works.
We have zero errors and one warning, that is because I have used a float variable here.
A float has a size of four bytes and a double has a size of eight bytes and in our case a float is enough.
Okay, now please click on this little button here or press the F4 key to go back to MetaTrader. In Meta Trader you want to click on View, Strategy Tester or press the control and the R key.
That will show the little Strategy Tester panel here and there we want to select the simple Bulls power.ex5 file and please don’t forget to mark the visualisation option here, pick any currency pair and start the test.
And this is how our simple Bulls power Expert Advisor works, you see we have one digit less behind the dot here, but this is still precise enough to generate an entry signal.
Okay, now you know how to create an Expert Advisor by using the simple Bulls power indicator and you have done it with a few lines of MQL 5 code.
Download “MQL5 Simple Bulls Power Indicator from MQL5 Tutorial”SimpleBullsPower.txt – Downloaded 327 times – 692.00 B