ahujat Posted September 26, 2023 Report Share Posted September 26, 2023 (edited) I have two scanners running in a single scanner code, on intraday data. On one of the scans, scanner condition might happen multiple times, and the scanner sets and clears the scanner column in the portfolio based on when the condition is met and then maybe on the second bar the condition is unmet and then it clears the scan column. On the second scan, if the condition is met once, the alert remains visible through the day. As an example, my scan looks for the bar closing below Previous day's low (Just an example but the real scan is a more than that) 1. In the first scan, it should set the scan column but when if the next or later bar closes above Previous day's low, it should unset the scan column. 2. In the second scan, whenever a bar close below the previous day's low, it should set the scan column but even if the next or later bar closes above the previous day's low, scan column should still be set. Basically, in this case, the scanner code has to remember the scan condition is met and then ignore further movements. I am able to do the first scan but can't figure out the second one. Is there an example for that? Or some simple code that I can incorporate into my scanner code? Edited September 26, 2023 by ahujat Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted September 27, 2023 Report Share Posted September 27, 2023 Let's say your scan result (that you pass in SetScanResult) is Double. Just have a Double variable set in the scan (outside the functions). Call it TriggeredValue. At start, set it to 0 (or some "invalid" value). When the condition is satisfied, set it to whatever you're passing to SetScanResult. And before you check for the condition, just say if TriggeredValue is not 0, SetScanResult to it and don't even continue checking for the condition. Quote Link to comment Share on other sites More sharing options...
Jerry Medved Posted September 27, 2023 Report Share Posted September 27, 2023 and reset the var on start of day Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.