The section "Creation by Programming" is dedicated to users who wish to program a market scan on their own. A detailed description of the commands available is included in the "ProScreener Programming Guide".
Even if you have never written code, we suggest you use the "Creation by Programming" window to improve market scans created with the ProScreener wizard. We are going to show you some examples of modifications that you will be able to do by yourself without being an expert programmer.
You can also have a look at the trading systems section of ProRealTime.com, where you can download a variety of code published by our programmers or by other members of our community.
Adapt your market scan to conditions on previous bars
Useful information before starting:
Let's create a market scan that looks for securities whose Moving Average has a positive trend, meaning an increasing value of the Moving Average indicator. The ProScreener wizard also allows us to compare the current bar with the previous bar. The code is the following:
We can modify our code and set more stringent conditions: we want the positive trend to be verified for the last 2 bars (or periods).
Let's duplicate the c1 line to create a second condition, named c2. Then we insert respectively  after indicator1 and  after indicator2 and include the c2 condition between the SCREENER brackets. See the code below:
Group your conditions into one ProScreener
In this section, you will see how to cumulate searching conditions with additional flexibility. For example, you may want to detect:
- securities having a RSI > 70 and positive price trend
- and securities having RSI < 30 and a negative price trend
When setting multiple conditions in the Assisted creation wizard, you have the choice between "Match all conditions" or "Match any of the conditions", but you cannot create one screener that searches for either 2 simultaneous bullish conditions or 2 simultaneous bearish conditions for example. This can be done with a little modification in the code.
First of all, let's create a ProScreener based on the conditions above and let's set a sorting criteria using the RSI indicator. The code is the following:
In the code c1 and c2 are the bullish conditions, c3 and c4 the bearish conditions. We can just group them in the SCREENER line, to get a market scan that searches for securities meeting 2 bullish conditions or 2 bearish conditions in the same program. See the code in below:
The ProScreener window will display the results using the value of the RSI as the sorting criteria. By examining the RSI value, you will easily see if the security meets the bullish conditions or the bearish conditions.