9

CPR AFL Code with Exploration

Central Pivot Range (CPR) is one of the most popular indicators for intraday trading. Similar to traditional pivot points, it shows support/resistance levels for the day along with the pivot point. However, the pivot point in the case of CPR consists of 3 levels – Pivot, BC, and TC. In this post, we are going to look at the CPR AFL code with built-in exploration. Using this exploration code, you would not only see the CPR levels of your watchlist but also scan for the narrow range CPR symbols.

To understand CPR in-depth, its calculation, uses and interpretation please follow the below link.

All you want to know about CPR Indicator

CPR Exploration – Overview

This exploration code is based on the standard calculation formulas for CPR levels:

TC = (Pivot – BC) + Pivot

Pivot = (High + Low + Close)/3

BC = (High + Low)/2

Here High, Low, and Close prices are the previous day’s price levels. So, if you want to see the CPR levels for the current day, then the high, low, and close prices should correspond to the previous day (from EOD timeframe).

Below are some of the important columns from the exploration:

Pivot – The CPR pivot level

TC – CPR top central level

BC – CPR bottom central level

NarrowRange – Indicates if the CPR width is narrow or not

R1/R2/R3/R4 – Resistance Levels

S1/S2/S3/S4 – Support levels

CPR AFL Code – Download Link

You may download the exploration code from the below link. The file is in zip format, you’ll have to unzip it before use.

CPR AFL Exploration Code

The code has been tested in Amibroker version 6 and above. The trial version of Amibroker can be downloaded from this link.

How to use this Exploration Code?

Step 1: Open Amibroker, Click on File–>New–>Formula and copy-paste the exploration code you downloaded.

Step 2: Click on File–>New–>Analysis. Set time frame to Daily.

Step 3: In the “Apply to” drop-down select ‘All symbols’ or filter based on the list of stocks you want to watch. In the range drop-down, select ‘1 recent day(s)’ to run exploration only for the current day. And select the AFL code in the “Formula” box.

CPR AFL Code

Note – You’ll need EOD data loaded into Amibroker to use this exploration.

Also Read: CPR Spreadsheet with Narrow Range Indicator

Understanding the Exploration Code

Let’s understand the exploration code in detail.

First of all, this is purely an exploration code, so you won’t be able to superimpose it in charts.

There are 3 primary variables in the AFL code; PrevLow, PrevHigh, and PrevClose. They store the Low, High, and Close prices respectively of the previous trading day.

CPR AFL Code 1

If your database is updated up to the previous trading day, the PrevDay variable should be 0. But if you are using a real-time DB which is updated up to the current day, the PrevDay variable should be 1.

Next, the Pivot, BC, and TC levels are calculated using the formulas mentioned before in this article.

CPR AFL Code 2

The narrow range CPR levels are calculated by comparing the absolute difference of TC and BC values with the previous close price. If the percentage difference is less than a defined threshold (NRThreshold variable) then the narrow range condition is satisfied. The default value of the threshold is 0.2.

CPR AFL Code 3

Then the support resistance levels are calculated using the standard formulas:

CPR AFL Code 4

Finally, all the calculated variables are added to the exploration using AddColumn() or AddTextColumn() functions.

CPR AFL Code 5

The values are appropriately color-coded for easy interpretation. Also, there is a filter condition “C>10” to filter out all penny stocks.

Disclaimer:

All the AFL’s posted in this section are for learning purpose. Trading Tuitions does not necessarily own these AFL’s and we don’t have any intellectual property rights on them. We might copy useful AFL’s from public forums and post it in this section in a presentable format. The intent is not to copy anybody’s work but to share knowledge. If you find any misleading or non-reproducible content then please inform us at support@tradingtuitions.com

Related Posts

9 Comments

  1. Hello Admin,
    I find ur articles, post very helpful. Bhagwan Apko khoob tarakki dey!
    Thanks alot sir.

  2. Once again amazing afl. This website just rocks. Most helpful site for trader community. Keep it up.

  3. This is best website for Amibroker afl. No need to go to google you will find everything there

Leave a Reply

Your email address will not be published.