Re: Rijay's System of Moving Averages

171
h4-h1 trading setup with color candles
you can set your own timeframe for coloring of candles
for trading see all timeframe coloring of candles gets in sync and moving averages have converged
These users thanked the author rijay for the post (total 6):
anubis19, Tsar, moey_dw, AlainP, thomdel, eduarescobar

Re: Rijay's System of Moving Averages

172
This indicator helps set up two user defined timeframes for display of arrow, when both time frames align it triggers arrow in direction of trend.

for example set first comparison timeframe to H1 and second comparison timeframe to H4 and it will trigger arrow when this two timeframes align in direction of trend.
These users thanked the author rijay for the post (total 5):
thomdel, anubis19, Jimmy, ashdays, eduarescobar

Re: Rijay's System of Moving Averages

173
color candles with trigger arrow and histogram version attached
These users thanked the author rijay for the post:
eduarescobar

Re: Rijay's System of Moving Averages

174
mtf logic according to this example in this code,

for example of H4(4 hourly) chart, there are 4 one hourly candles ,if for first 3 hours the color of current forming 4 hourly bar is red and then in 4th hour color changes to blue then on one hourly chart first 3 candles should remain red(extracting color from current forming H4 candle bar) and only 4th candle should change to blue color,


the same logic to all time frame for mtf function calculation
These users thanked the author rijay for the post:
thomdel

Re: Rijay's System of Moving Averages

175
xu ma v3 with


mtf logic according to this example in this code, for example of H4(4 hourly) chart, there are 4 one hourly candles ,if for first 3 hours the color of current forming 4 hourly bar is red and then in 4th hour color changes to blue then on one hourly chart first 3 candles should remain red(extracting color from current forming H4 candle bar) and only 4th candle should change to blue color,

the same logic to all time frame for mtf function calculation
These users thanked the author rijay for the post (total 2):
thomdel, Krunal Gajjar

Re: Rijay's System of Moving Averages

176
rijay wrote: Thu Jun 04, 2026 4:29 pm xu ma v3 with


mtf logic according to this example in this code, for example of H4(4 hourly) chart, there are 4 one hourly candles ,if for first 3 hours the color of current forming 4 hourly bar is red and then in 4th hour color changes to blue then on one hourly chart first 3 candles should remain red(extracting color from current forming H4 candle bar) and only 4th candle should change to blue color,

the same logic to all time frame for mtf function calculation


Reason for this Post :
Read the above 2 to 3 posts , but it creates a confusion as to which Indicator is appropriate / correct / right.


Respected Rijay,

Which indicator is Right to Use ? ( Which Indicator will provide the Right info )


XU-MA v3 bg with time frame selection for candles and background both
Or
XU-MA v3 bg with time frame selection for candles and background both new mtf logic


moving_averages gradient color candles mtf 1 four color candle bg arrow
Or
moving_averages gradient color candles mtf 1 four color candle bg arrow nrp
Or
moving_averages gradient color candles mtf 1 four color candle bg arrow nrp true



Thanks for your Indicators, Time, Efforts, Shares.
Thanks a Lot.

Re: Rijay's System of Moving Averages

177
thomdel wrote: Thu Jun 04, 2026 5:15 pm Reason for this Post :
Read the above 2 to 3 posts , but it creates a confusion as to which Indicator is appropriate / correct / right.


Respected Rijay,

Which indicator is Right to Use ? ( Which Indicator will provide the Right info )


XU-MA v3 bg with time frame selection for candles and background both
Or
XU-MA v3 bg with time frame selection for candles and background both new mtf logic


moving_averages gradient color candles mtf 1 four color candle bg arrow
Or
moving_averages gradient color candles mtf 1 four color candle bg arrow nrp
Or
moving_averages gradient color candles mtf 1 four color candle bg arrow nrp true



Thanks for your Indicators, Time, Efforts, Shares.
Thanks a Lot.


if you are facing confusion just simply use this indicator

rest of indicators posted above are applying different mtf logic to get around mtf repainting issue, and coloring of background according to candle coloring
These users thanked the author rijay for the post:
thomdel

Re: Rijay's System of Moving Averages

178
thomdel wrote: Thu Jun 04, 2026 5:15 pm Reason for this Post :
Read the above 2 to 3 posts , but it creates a confusion as to which Indicator is appropriate / correct / right.


Respected Rijay,

Which indicator is Right to Use ? ( Which Indicator will provide the Right info )


XU-MA v3 bg with time frame selection for candles and background both
Or
XU-MA v3 bg with time frame selection for candles and background both new mtf logic


moving_averages gradient color candles mtf 1 four color candle bg arrow
Or
moving_averages gradient color candles mtf 1 four color candle bg arrow nrp
Or
moving_averages gradient color candles mtf 1 four color candle bg arrow nrp true



Thanks for your Indicators, Time, Efforts, Shares.
Thanks a Lot.


if you want more option like background coloring, mtf and arrow display besides color candle , you can use this version, where option of both moving average candle coloring and candle coloring according to xu ma v3 are there in it to select from


to understand what logic is used in this indicator, just asking antigravity or codex is good option.



code interpretation--
Overall Purpose
It's a multi-timeframe (MTF) moving average indicator that colors candles, draws MA lines, shows trend/signal MAs (XU-MA), paints background, and draws alignment arrows — all driven by MA slope and position logic.

Core Components
1. Gradient Color Moving Average Lines
Two MA lines are plotted — a fast MA (e.g. period 14) and a slow MA (e.g. period 34). Both use the same 20-step gradient palette:

The slope angle of the MA is calculated against ATR (normalized angle): angle = atan(change / (ATR × bars)) × 180/π
The angle is mapped to one of 20 color steps between ColorTo (down color, e.g. DeepPink) and ColorFrom (up color, e.g. Lime)
Steep upward slope → vivid green end; steep downward slope → vivid pink end; flat → middle color
2. Colored Candles (4-color MA-position mode)
Each candle is colored based on price position relative to both MAs:

Condition Color
Price below both MAs Red (Bearish)
Price above both MAs Blue (Bullish)
Price below fast, above slow LightBlue
Price above fast, below slow LightRed
When CandleColorTF is set to a higher timeframe (e.g. H4 on an H1 chart), the color is derived from HTF MA values instead of current-chart MAs.

3. MTF Color-Lock (Non-Repainting)
This is the key logic we implemented. The problem it solves:

Without this, every H1 candle inside the same H4 bar would retroactively change color every tick as the H4 MA shifts.

How it works:

A candleColorLocked[] buffer tracks which bars have been permanently assigned
When a lower-TF bar first closes (transitions from bar 0 to bar 1), the HTF color at that exact moment is written and locked = 1.0
On every subsequent tick, if locked == 1.0, the bar is skipped — its color never changes again
Only the live forming bar (i == 0) always recalculates freely
This same lock pattern is applied to:

Candle colors (candleColorLocked) — via CandleColorTF
Arrow state (arrowStateLocked) — via TF1/TF2
XU-MA state (xuTrendLocked) — via TRENDtf/SIGNALtf
4. TF Alignment Arrows
Compares MA color state on two user-selected timeframes (TF1, TF2):

Both blue (bullish) → up arrow (↑) drawn below the bar, state = 1.0
Both red (bearish) → down arrow (↓) drawn above the bar, state = 0.0
Uses edge detection — arrow only fires on the first bar where alignment occurs, not on every subsequent bar
Arrow state is also used to color candles in CANDLE_COLOR_ARROW mode.

5. XU-MA TREND + SIGNAL (Band-based MA)
Two separate MAs (TREND and SIGNAL) each use three handles:

MA(PRICE_HIGH) — upper band
MA(PRICE_LOW) — lower band
MA(median/close) — center line for display
Direction logic per MA:

price > MA(High) → direction = +1 (bullish breakout above band)
price < MA(Low) → direction = -1 (bearish breakdown below band)
price inside band → direction = hold previous (persistence/no-flip zone)
Combined xtrend:

TREND=+1 AND SIGNAL=+1 → xtrend = +1 (both bull → Blue line)
TREND=-1 AND SIGNAL=-1 → xtrend = -1 (both bear → Crimson line)
anything else → xtrend = 0 (disagreement → no line)
In CANDLE_COLOR_XUMT mode, candles use xtrend:

xtrend=+1 → Blue
xtrend=-1 → Red
TREND bull but SIGNAL not → LightBlue
TREND bear but SIGNAL not → LightRed
6. Background Coloring
Uses OBJ_RECTANGLE objects drawn behind the chart (OBJPROP_BACK=true). Each bar gets a rectangle from its open time to its close time, colored to match the candle color. BgMaxBars limits how far back rectangles are drawn. All rectangles are cleaned up in OnDeinit and when the feature is toggled off.

7. Candle Color Mode Switch
Three modes selectable via CandleColorMode:

Mode Source
CANDLE_COLOR_MA 4-color MA position logic
CANDLE_COLOR_ARROW Arrow state (TF1/TF2 alignment)
CANDLE_COLOR_XUMT XU-MA TREND+SIGNAL xtrend
These users thanked the author rijay for the post:
thomdel

Re: Rijay's System of Moving Averages

180
QWMA (Quadratic Weighted Moving Average) gradient color candles

and
moving average ribbon with gradient coloring of candles