Khush 30M
PROJECT: XAUUSD GOLD MOTHER-BABY CANDLE STRATEGY
Create a professional TradingView Indicator using Pine Script Version 6.
The indicator must be designed specifically for XAUUSD (GOLD).
1. MASTER TIMEFRAME
The strategy must ALWAYS use the 30-minute timeframe for all setup calculations.
The user may view any chart timeframe, such as:
– 1 Minute
– 3 Minutes
– 5 Minutes
– 15 Minutes
– 30 Minutes
– 1 Hour
– 4 Hours
Regardless of the currently selected chart timeframe, the indicator must continuously monitor the 30-minute strategy in the background.
2. MOTHER CANDLE CONDITIONS
Identify a strong bearish RED candle on the 30-minute timeframe.
This candle will be called the MOTHER CANDLE.
The candle must be fully closed before confirming the setup.
3. BABY CANDLE CONDITIONS
The candle immediately following the Mother Candle must be a bullish GREEN candle.
This candle will be called the BABY CANDLE.
Important conditions:
– Baby Candle must be completely inside the Mother Candle.
– Baby Candle HIGH must be lower than Mother Candle HIGH.
– Baby Candle LOW must be higher than Mother Candle LOW.
– Both upper and lower wicks must remain inside the Mother Candle range.
– Baby Candle must be fully closed before activating the setup.
4. SELL ENTRY CONDITIONS
After confirming the Mother Candle and Baby Candle:
Monitor ONLY the immediately following 30-minute candle.
As soon as this next running candle breaks below the Baby Candle LOW:
GENERATE AN IMMEDIATE SELL SIGNAL.
VERY IMPORTANT:
– Do not wait for the running candle to close.
– Entry must trigger immediately when the Baby Candle LOW is breached.
– Use real-time intrabar monitoring.
– Do not use candle-close confirmation for entry.
– Trigger only once per valid setup.
5. ENTRY, STOP LOSS AND TAKE PROFIT
ENTRY:
The actual breakout price when the Baby Candle LOW is breached.
STOP LOSS:
Baby Candle HIGH.
RISK:
Stop Loss minus Entry Price.
TAKE PROFIT:
Minimum Risk-to-Reward Ratio of 1:3.
Formula:
Risk = Stop Loss – Entry Price.
Target = Entry Price – (Risk × 3).
Display all three levels clearly on the chart.
6. MULTI-TIMEFRAME ALERT SYSTEM
This is one of the most important features.
The indicator must continuously monitor the 30-minute XAUUSD strategy regardless of the user’s current chart timeframe.
For example:
If the user is watching a 1-minute chart and a valid 30-minute setup forms, the indicator must detect it.
If the user is watching a 3-minute, 5-minute, 15-minute, 1-hour or any other chart, the indicator must still monitor the 30-minute setup.
When the 30-minute Baby Candle LOW breaks, immediately send the SELL alert.
The alert must work independently of the chart timeframe.
Use a reliable Pine Script Version 6 multi-timeframe architecture.
IMPORTANT TECHNICAL REQUIREMENTS:
– Avoid lookahead bias.
– Use confirmed 30-minute Mother and Baby candles.
– Monitor the actual 30-minute running candle for breakout.
– Do not rely only on request.security() if it causes intrabar breakout events to be missed.
– Use appropriate lower-timeframe data or another reliable intrabar monitoring method where necessary.
– Handle duplicate signals correctly.
7. TRADINGVIEW ALERT SYSTEM
Create dynamic alerts using Pine Script alert().
Alert frequency:
ONCE PER BAR.
DO NOT USE:
ONCE PER BAR CLOSE.
The alert must trigger immediately when the Baby Candle LOW breaks.
Alert message must include:
– XAUUSD SELL SIGNAL
– Strategy: Mother-Baby Breakdown
– Timeframe: 30 Minutes
– Entry Price
– Stop Loss
– Take Profit
– Risk Reward: 1:3
Only one alert per setup is allowed.
8. CHART VISUALIZATION
Display a professional and clean trading interface.
Show:
– Mother Candle highlighted with a box.
– Baby Candle highlighted with a different box.
– Baby Candle HIGH and LOW levels.
– SELL entry label.
– Entry Price horizontal line.
– Stop Loss horizontal line.
– Take Profit horizontal line.
– Risk Reward ratio.
– Clear trade information panel.
Use RED color for SELL signals.
9. DUPLICATE SIGNAL PROTECTION
– Generate only one SELL signal per setup.
– Once a setup is triggered, mark it as consumed.
– Never reuse the same Mother and Baby candles.
– If the next 30-minute candle closes without breaking the Baby Candle LOW, expire the setup.
– Do not carry expired setups into subsequent candles.
10. ADDITIONAL SETTINGS
Provide user-configurable options for:
– Enable/Disable Alerts.
– Enable/Disable Chart Labels.
– Enable/Disable Entry, SL and TP Lines.
– Risk Reward Ratio (Default 1:3).
– Mother Candle minimum size.
– Baby Candle maximum size.
The default strategy conditions must remain unchanged unless the user modifies them.
11. CODE QUALITY
– Use Pine Script Version 6.
– Write complete, clean and optimized code.
– No compilation errors.
– No lookahead bias.
– Avoid repainting of confirmed historical setups.
– Correctly handle real-time intrabar execution.
– Use proper state management for setups and alerts.
– Make the indicator suitable for XAUUSD.
12. FINAL MOST IMPORTANT INSTRUCTIONS
The exact strategy sequence must be:
BIG RED MOTHER CANDLE
↓
SMALL GREEN BABY CANDLE INSIDE MOTHER CANDLE
↓
NEXT 30-MINUTE CANDLE
↓
BABY CANDLE LOW BREAK
↓
IMMEDIATE SELL ALERT
The SELL alert must trigger immediately during the running candle.
Never wait for the running candle to close.
The indicator must monitor the 30-minute strategy even when the user is viewing a different timeframe.
Do not create BUY signals.
Also explain the correct TradingView alert setup required for real-time intrabar notifications.


