Implementing and Analyzing Relative Strength with Custom Screener in ProBuilder

10 Sep 2015
0 comment
0 attachment

This ProBuilder script is designed to create a custom screener that calculates and analyzes the relative strength of a stock compared to a benchmark index. The relative strength is a popular metric used in technical analysis to compare the performance of an individual stock or asset to a broader market index.


EQUITYFRAME("Indices Euronext","PXI")
valeur2=close equityframe(default)
valeur1=close
Forcerelative= valeur1/valeur2
while Forcerelative < 0.4 and Forcerelative > 0 do
    forcerelative=forcerelative*10
wend
while Forcerelative > 6 do
    forcerelative=forcerelative/10
wend
avg = average[10](forcerelative)
test = forcerelative crosses over avg or forcerelative crosses under avg
SCREENER[test](forcerelative AS"RelativeStrength")

Explanation of the code:

  • Setting the Equity Frame: The EQUITYFRAME function is used to set the reference index for comparison, which in this case is “Indices Euronext” with the symbol “PXI”.
  • Calculating Relative Strength: The script calculates the relative strength (Forcerelative) by dividing the close price of the current equity (valeur1) by the close price of the index (valeur2).
  • Normalizing the Relative Strength: Two while loops are used to scale the relative strength value into a more manageable range. If the value is less than 0.4, it is multiplied by 10 until it is no longer less than 0.4. If it is greater than 6, it is divided by 10 until it falls below this threshold.
  • Calculating the Moving Average: The average[10](forcerelative) function calculates the 10-period moving average of the normalized relative strength.
  • Detecting Crossovers: The test variable checks for crossover events where the relative strength crosses over or under its moving average, which can signal potential changes in trend.
  • Creating the Screener: Finally, the SCREENER function is used to filter and display stocks where a crossover event has occurred, labeling the output as “RelativeStrength”.

This script is useful for traders and analysts who want to screen stocks based on their performance relative to a broader market index, helping to identify potential outperformers or underperformers.

Related Post

Check out this related content for more information:

https://www.prorealcode.com/topic/croisement-ema-avec-force-relative-comparaison/#post-168280

Visit Link
What is a Snippet? A snippet is a small, reusable chunk of code designed to solve specific tasks quickly. Think of it as a shortcut that helps you achieve your coding goals without reinventing the wheel. How to Use: Simply copy the snippet and paste it into your project where needed. Don't forget to tweak it to fit your context. Snippets are not just time-savers; they're also learning tools to help you become a more efficient coder.
Nicolas Master
I created ProRealCode because I believe in the power of shared knowledge. I spend my time coding new tools and helping members solve complex problems. If you are stuck on a code or need a fresh perspective on a strategy, I am always willing to help. Welcome to the community!
Author’s Profile

Comments

Search Snippets

Showing some results...
Sorry, no result found!

Snippets Categories

global
35
indicator
133
strategy
171

Recent Snippets

How to Create a Simple MTF Trend Dashboard with EMA and SMA
indicator
This indicator builds a compact multi-timeframe (MTF) dashboard that shows whether price is trading above or below a [...]
How to Display Per-Bar Volume Accumulation in Real Time (Intrabar Updates)
global
This snippet tracks and displays the current bar’s accumulated volume while the bar is still forming, instead of only [...]
Ticks Counter: Count Tick Updates Per Bar on Tick or Time Charts
global
This snippet counts how many tick updates have occurred for the current bar by incrementing a per-bar counter on each [...]
How to Build a Step-Based Trailing Stop That Moves to Break-Even First
strategy
This snippet implements a step trailing stop that advances in fixed increments once price reaches predefined profit [...]
Utilizing Arrays to Track and Compare Indicator Values Within the Same Bar in ProBuilder
indicator
This ProBuilder code snippet demonstrates how to use arrays to compare the values of an indicator (RSI in this case) [...]
Logo Logo
Loading...