//Exploration to find stocks which are trading below 52 week low
Low52 = LLV(Low,250);
q = Close < Low52;
Filter = 1;
AddColumn(Low52,"52WL");
AddColumn(q,"Below 52WL");
AddColumn(Close,"Close");
You are looking for a close that is lower than the prior 250 lows, including today's low. That will never happen. To look for a close below 250 lows excluding today, try this instead:
q = Close < Ref(Low52,-1);
//Exploration to find stocks which are trading below 52 week low
Low52 = LLV(Low,250);
q = Close < Ref(Low52,-1);
Filter = 1;
AddColumn(Close,"Close");
AddColumn(Low52,"52WL");
AddColumn(q,"Below 52WL");
Hello Friend,
Even after making the necessary corrections when i run the exploration its not giving me correct results. For eg;- if Stock 'X' today closed at Rs.120, its 52 week low is 125 then i would like to show the result in the column "Below 52 WL" as 1. Is there a possibility to give a "if" condition so that once i run the exploration it gives me the results of only those stocks which meets the above criteria.
I'm just a beginner don't know much about AFL coding. Please do help me to solve the problem so that i can learn from you.
Thanks a lot and waiting for your response.
Filter variable already tells you what it is used for... to filter results.
Note: Filter expects true/false assignment.
So if "Filter = 1" -> it is equal to "Filter = True" and it means "Show all results without filtering". So if you want to get results of only when your custom condition is true at last bar then just add that condition to Filter line.
//Exploration to find stocks which are trading below 52 week low
Low52 = LLV(Low,250);
Is_Below = Close < Ref(Low52,-1);
Filter = Is_Below AND Status( "LastBarInRange" );
AddColumn(Close,"Close");
AddColumn(Ref(Low52,-1),"prev. 52WL");
AddColumn(Is_Below,"Below 52WL");
Thank You my dear friend its working perfectly fine. Great job