In this video we are going to talk about the Bulls Power Indicator, it is drawn in a separate window below the candles. The Bulls Power Indicator basically can tell us if the bulls are stronger than the bears. Whenever those lines of the histogram are above the zero line we will put out a buy signal here and whenever the direction changes and the histogram is drawn below the zero line that would be a sell signal.
To create the Indicator and the Expert Advisor that is going to trade it you need to click on the little button here or press F4 on your keyboard and now you should see the Metaeditor window and here you want to click on “File/ New/ Expert Advisor (template)” from template, “Continue”, I will call this file Simple Bulls Power (SimpleBullsPower.ex4) click on “Continue “, “Continue” and” Finish” and now you can remove everything above the “OnTick” function and the two comment lines here.
Let’s create a string variable for the signal here – I will also call it signal – it doesn’t contain a value so far because that is what we are going to calculate in this simple Expert Advisor and to do that we can use the “iBullsPower” function that is included in MQL4, that will calculate the Bulls Power Indicator and return its value.
Now what is meant by value? If we passed the execution here we will have a value. In this case it’s 0.0006 and that matches the value of the last bar here of the histogram and to calculate it we need to pass a few parameters.
The first one is the current symbol on the chart, the second parameters for the selected period on your chart, in my case I’m trading a 1 minute chart, the period could also be something like 5 minutes 15 minutes and so on and “_Period” makes sure that we are calculating the correct period that is the period from the chart you are trading right now. The next parameter has the value 13 and when you click on “Insert/ Indicators/ Oscillators/ Bulls Power” you will see the period has a value of 13 and we calculate the value based on the close price and that’s exactly why the 13 is used here as the third parameter and “PRICE_CLOSE” is parameter number 4.
Well this last parameter stands for the shift.
What is a shift? Actually you can move the current indicator value to the right or to the left depending on the shift value. We don’t want to do that so we use 0 and if the Bulls Value is above 0 and the histogram is drawn above the line here we consider that to be a buy signal so we assign the word: “buy” to our signal variable. In the other case if the Bulls Value is below 0 or in MQL4 if BullsPowerValue is smaller than 0 we assign the word: “sell” to our signal.
Last but not least we create a screen output by using the built in “Comment” function to output the words: “BullsPowerValue:” followed by the calculated value and in a new line we output: “Signal:” followed by the calculated signal.
Okay. That’s it.
Now you can click on the compile button here or press F7 to compile your code and that should work without any errors and in that case you can click on the button here or press F4 to go back to Metatrader.
In Metatrader we will use a little trick, please click on “Insert/ Indicators/ Oscillators/ Bulls Power”, click “OK”. Now the Bulls Power Indicator will be drawn on your chart and now we right click in the chart, select “Template/ Save Template” and save it as: “tester.tpl” because that is the template that is going to be used for your next back-test.
To start the Strategy Tester you can click on “View/ Strategy Tester” or press CTRL + R, please select the newly created “SimpleBullsPower.ex4” file and start your test.
Now you should see the little Expert Advisor at work, it creates an output for a current Bulls Power Value and below that you see a buy or a sell signal.
On a real account you would combine the signal of the Bulls Power Value to something like a trend following indicator and use it as a filter but for now you know how to create an Expert Advisor that is able to create the output for the Bulls Power Value and you have coded it yourself with a few lines of MQL4 code.

Download “MQL4 Tutorial - Simple Bulls Power Expert Advisor”

SimpleBullsPower.txt – Downloaded 1605 times – 649.00 B