OBV at xx-day high ?
I’d like to code a rule that alerts me when On Balance Volume is at a xx-day high, but although I can see OBV in the list of Indicators I can’t see how to check whether it’s at a high. Could someone point me in the right direction ?
Well, there is not a nice function to select the max or min of an indicator (as far as I know). So, one has to build it up; much like programmng.
There are several ways to do this: The ‘cleanest’ was would be to write a small function and place it into the CustomFunctions.mq4 file.
However, it can get a little removed from what is going on in the SQ files.
So, a less nice way to do it is to use the custom function to make a searching loop in the code. The advantage of this is one can look at what is going on strate in the code and one does not have to keep track of the CustomFunctions.mq4 file.
So, I have done the second solutions. (even though I think the first would have been better, which I might should do at some points anyway).
The Attached contains the two files with an long trade implementation. It’s a little messy just to understand. I will try to follow up with a better explanation tomorrow, or the next few days.
But, in the simplest terms, I made several tabs.
Get_OBV_Highest: searches the last number of bars of the On Balance Volume and finds the highest value.
MakeEntry : decides if the current volume is now higher than any of the last On Balance Volumes to make an entry. If true, makes an alarm to the screen (active only under live test) and places a trade
Comment: displays the last values of the On Balance Volume and shows the highest value.
In important input parameters are:
MaxCandlesBack : Number of candles back that the search fill find the maximum
AlertMessageNewHigh: when the Alert message pops up, it will display this message (active only during live test)
Lots: lots used for a trade
TP_inPips, SL_inPips: profit and stop loss levels
Ok, I tested this in back test. To see the fun functionality you will need also place the “On Balance Volume” indicator on the chart.
The trading and alert function will be to place a trade when a new On Balance Volume of the current candle becomes the highest in some set number of candles-back is made.
A still picture shows what is going on a little bit. http://screencast.com/t/gaAA6z2cPjc
See this short video. http://screencast.com/t/z9BcUlkp
i will have to try to follow this up in the next few days, But the basics are all working for a long entry (and alert window) in the way you might be interested.
Viewing 2 posts - 1 through 2 (of 2 total)