Ok, after some further details I have an more detailed solution. Attached screenshot shows the scan layout with results. As well as a chart setup to show the essential elements of the scan. I am providing two pieces of code. The first is the one that checks for moving average crossover within the last 14 bars. This will be added to the custom scan as a study filter set to 30 min time frame.
def ma20 = Average(close, 20);
def ma50 = Average(close, 50);
def crossAbove = ma20[1] < ma50[1] and ma20 > ma50;
# crossAbove is true/false and returns a numeric value of 1 or zero
def crossWithin14 = Highest(crossAbove, 14) > 0;
# crossWithin14 checks for the highest value of crossAbove within 14 bars
# and returns true if the lowest value is greater than zero.
plot scan = crossWithin14;
The next piece of code combines both the PSAR along with the Heiken Ashi. Because Rachid has explained that both of these filters should operate on the daily time frame. So when adding this as study filter to the scan, make sure you sent the time frame to Daily.
# Parablic SAR
input accelerationFactor = 0.02;
input accelerationLimit = 0.2;
def psar = ParabolicSAR(accelerationFactor, accelerationLimit).parSAR;
def psarTrigger = psar[1] < close[1]; # Heiken Ashi def haClose = ohlc4; rec haOpen = CompoundValue(1, (haopen[1] + haclose[1]) / 2, (open[1] + close[1]) / 2); def adjOpen = Round(haOpen / TickSize(), 0) * TickSize(); def adjClose = Round(haClose / TickSize(), 0) * TickSize(); def haTrigger = adjClose > adjOpen;
plot scan = psarTrigger and haTrigger;
Ok, that’s all I have.
Pete, I am trying to edit the original post to attach a picture but I get a white empty box!
yeah, I know. not sure why but that feature has never worked. I’ll check the settings. but if you need to add a screenshot you’ll need to post is at a new answer to this question.
I attached the pic, but when I post the answer I get “content can not be empty” error message. I could not add any text in the box because it is not clickable. For now just let me know if you have any questions in regard to my previous question clarification. Thanks