I have a screener that’s running well and I am looking to introduce a new line of code to give a percentage of how far the close is from the high of the day.
The screener already has five conditions. one that the stock must have: close > open.
My thinking is that the code will be the criteria to sort the filtered stocks.
So far this is what I have:
Total = high-low
CloseDiff = high-close
criteria = IF (close=high) THEN return close as "Bull" ELSE return (CloseDiff/Total) ENDIF
SCREENER [condition1 and condition2 and condition3 and condition4 and condition5](criteria as "CloseRange")
My syntax is wrong and I can’t figure out where I’m going wrong. Basically if the close is the high, I want to return “Bull” to signify that, otherwise I’d like to see the percentage the close is away from the day’s high.
Any thoughts on where I’m going wrong? This is the first time I’ve tried an IF THEN ELSE statement.
RETURN is a reserved keyword of ProBuilder (for indicators).
a screener can only return conditions with the keyword SCREENER.
I can’t understand exactly what you want to be returned, but I suggest that you try replacing lines 4-6 with:
IF (close=high) THEN
SCREENER [condition1 and condition2 and condition3 and condition4 and condition5](close as "Bull")
ELSE
SCREENER [condition1 and condition2 and condition3 and condition4 and condition5](CloseDiff/Total)
ENDIF