I am new to programming with pro-real code, so I need your help with the below.
I try to create an indicator of the buy/sell climax. In theory a buy climax occurs if a stock has a new 52 week high but then closes below previous week’s close. In my first approach to the code I tried to compile only the first part – meaning to check if a stock has a new 52 week high (then I will think the rest). I put the following code.
My result is that bclimax is always 0, although I would expect to have 1 also in many days that had high. What am I missing here?
Because you are trying to check a condition that can’t exist. The current High cannot be superior to the Highest high, it is the Highest high 🙂 So you’ll have to check is the current High is above the highest one, 1 bar ago, like in this code:
1
2
3
4
5
6
7
IFDHigh(0)>Highest[365][1]THEN
bclimax=1
ELSE
bclimax=0
ENDIF
returnbclimaxAS"Buy Climax"
EDIT: there is no 365 trading days in year. You should adapt this lookback period to get something near the real value.
To help us continually offer you the best experience on ProRealCode, we use cookies. By clicking on "Continue" you are agreeing to our use of them. You can also check our "privacy policy" page for more information.Continue