Hello,
I have been trying unsuccessfully to write a script to do the following in an EOD scan -
-“the close has not been less than the 50sma for more than 10 times” - during the Scanning Manager “Date Range” settings, which I could make from 22/12/2019 to 22/12/2024 as an example.
I have made my own attempts, used 2 examples from Ai Chat and tried the following example from - Scripterbot as follows -
// Define the 50-day Simple Moving Average
SMA50 = MA(BARS=50, STYLE=Simple); // Calculate the 50-day SMA
// Check if the Close is less than the 50-day SMA
CloseBelowSMA50 = CLOSE < SMA50; // Condition for Close below the 50-day SMA
// Count the number of times the Close has been below the 50-day SMA
CountBelowSMA50 = BarsTrue(CloseBelowSMA50); // Count occurrences
// Check if the count is less than or equal to 10
finalCondition = CountBelowSMA50 <= 10; // Final condition
// Output the final condition for scanning
finalCondition; // Output the result
This example runs ok but appears not to be correct as well so I am back to square 1.
My criteria may be a bit strict, but once I have a working base script, I can alter the numbers.
I would really appreciate some help in getting this to work correctly please.
Thanks for your help,
Regards,
Brad