Identifying Market Phases Using Moving Averages in ProBuilder

14 Jul 2024
0 comment
0 attachment

This code snippet is designed to identify six distinct market phases using two moving averages (MA50 and MA200) on a daily timeframe. It can be integrated into trading strategies to optimize entry and exit conditions based on the current market phase.

//Market Phases
// based off https://www.youtube.com/live/pXxmhZsqbzA?si=UbPSOTYNvrVpvc-v
Timeframe (1 day)
MA200 = average[200] (close)
MA50 = average[50] (close)
$mp[1] = close > MA50 and MA50 > MA200 and MA50[0] > MA50[1] and MA200[0] > MA200[1] //Bullish Phase
$mp[2] = close < MA50 and MA50 > MA200 // Warning Phase
$mp[3] = MA50[0] < MA50[1] and MA50 > MA200 and MA200[0] > MA200[1] //Distribution Phase
$mp[4] = MA50[0] < MA50[1] and MA200[0] < MA200[1] and MA50 < MA200 //Bearish Phase
$mp[5] = MA200[0] < MA200[1] and MA50[0] > MA50[1] and close > MA50 and close < MA200 //Recovery Phase $mp[6] = close > MA50 and MA50[0] > MA50[1] and MA200[0] > MA200[1] //Accumulation Phase
Timeframe (default)
//your code 

This code uses two key moving averages to determine the market’s phase:

  • MA200 (Moving Average over 200 days) and MA50 (Moving Average over 50 days) are calculated to represent long-term and medium-term trends, respectively.
  • $mp[1] identifies a Bullish Phase, where the price is above MA50, MA50 is above MA200, and both MAs are trending upwards.
  • $mp[2] signals a Warning Phase, where the price falls below MA50 but MA50 is still above MA200, indicating potential instability.
  • $mp[3] denotes a Distribution Phase, characterized by a declining MA50 while MA50 remains above MA200 and MA200 is trending upwards.
  • $mp[4] marks a Bearish Phase, with both MA50 and MA200 trending downwards and MA50 below MA200.
  • $mp[5] indicates a Recovery Phase, where MA200 is declining, MA50 is rising, and the price is between these two averages.
  • $mp[6] represents an Accumulation Phase, with both moving averages and the price trending upwards.

This approach allows traders to adapt their strategies based on the prevailing market conditions, potentially enhancing decision-making processes.

Related Post

Check out this related content for more information:

https://www.prorealcode.com/topic/market-phases-code-snippet/#post-237035

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 Legend
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
135
strategy
171

Recent Snippets

A multi indicator Dashboard for ProRealTime
indicator
This snippet creates a compact on-chart dashboard that aggregates multiple indicator states into a single, readable [...]
How to Track Up/Down Cumulative Volume Inside Each Candle (Tick Volume Delta)
indicator
This snippet separates the real-time, intra-candle volume into up-volume and down-volume based on whether the last [...]
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 [...]
Logo Logo
Loading...