Jump to content
Medved Trader Forums

Static/Dynamic scan in the same scanner.

Recommended Posts

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 by ahujat
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...