30MA Volatile Assets StrategyThis strategy features:
Gaussian Channel with SMA basis and standard deviation bands
Stochastic RSI filter for entries
Long-only trades with 100% equity allocation
0.1% commission and no slippage
Clear entry/exit conditions based on price and indicator positions
Defined trading period from 2024 to 2069
Индикаторы и стратегии
Candlestick Bible: Dynamic Price Follower Strategy Overview:
This trading strategy, named "Candlestick Bible: Dynamic Price Follower (Corrected)", is designed to trade based on candlestick patterns, the market trend, and price action dynamics. It generates long (buy) and short (sell) signals using a combination of:
Candlestick pattern recognition
Exponential moving averages (EMA)
Price movement analysis (ATR)
The strategy does not include any position management logic (like trailing stops or exit rules). It simply enters trades based on specific conditions, and you would need to manually manage exits or apply additional rules for that.
Detailed Breakdown of Each Section:
1. Pattern Detection:
This part of the strategy identifies specific candlestick patterns:
Pin Bar Detection: A "Pin Bar" is a candlestick with a long shadow (upper or lower) and a small body. The strategy looks for Bullish Pin Bars (when the lower shadow is at least twice the body size) and Bearish Pin Bars (when the upper shadow is at least twice the body size).
Engulfing Pattern: The strategy detects Bullish Engulfing (when the current candlestick fully engulfs the previous bearish candlestick) and Bearish Engulfing (when the current candlestick fully engulfs the previous bullish candlestick).
These patterns are used to trigger entry conditions in the strategy.
2. Dynamic Trend System:
Exponential Moving Averages (EMAs): The strategy uses two EMAs to determine the current market trend:
Fast EMA (8-period): A quicker-moving average, more responsive to recent price changes.
Slow EMA (21-period): A slower-moving average that smooths out price action.
The strategy compares the fast EMA to the slow EMA:
If the fast EMA is above the slow EMA, the market is considered bullish.
If the fast EMA is below the slow EMA, the market is considered bearish.
This trend direction is important for confirming whether a long (buy) or short (sell) signal is valid.
3. Price Movement System:
Average True Range (ATR): The strategy uses ATR (14-period) to gauge the market's volatility.
Trail Offset: Although the exit logic for trailing stops has been removed, the ATR value is used to calculate the distance for potential trailing stops (for future strategies that might include exit rules).
4. Strategy Rules:
Long (Buy) Condition:
The strategy will enter a long position if either a Bullish Pin Bar or a Bullish Engulfing pattern is detected, and the market is in a bullish trend (i.e., the fast EMA is above the slow EMA).
The closing price should also be above the slow EMA to confirm the strength of the bullish trend.
Short (Sell) Condition:
The strategy will enter a short position if either a Bearish Pin Bar or a Bearish Engulfing pattern is detected, and the market is in a bearish trend (i.e., the fast EMA is below the slow EMA).
The closing price should be below the slow EMA to confirm the strength of the bearish trend.
5. Strategy Entries:
The strategy will enter long positions when the long condition is met (i.e., a bullish candlestick pattern forms and the market is bullish).
The strategy will enter short positions when the short condition is met (i.e., a bearish candlestick pattern forms and the market is bearish).
No exit rules are implemented. Therefore, trades are entered but not automatically exited.
6. Visual Feedback:
EMA Lines: The strategy plots the Fast EMA (blue) and Slow EMA (red) on the chart to visually represent the market’s trend.
Entry Signals: The strategy uses plotshape to visually mark entry points:
Green triangle (below the bar) indicates a long (buy) signal.
Red triangle (above the bar) indicates a short (sell) signal.
Summary of the Strategy's Actions:
The strategy checks for Bullish or Bearish Pin Bars or Bullish or Bearish Engulfing patterns.
It filters these signals by checking the market trend (using the Fast and Slow EMAs).
It enters trades when both the candlestick pattern and market trend align:
Long trade: If there is a Bullish pattern and the market is in a bullish trend.
Short trade: If there is a Bearish pattern and the market is in a bearish trend.
The strategy will not exit positions automatically (you would need to manually manage exits, or implement additional exit rules).
What’s Missing:
Position Management: No trailing stop or stop-loss logic is included in this version of the strategy. Once a position is opened, it will remain open until manually closed or additional exit conditions are added.
ELISAThe indicator uses Bollinger Bands with various moving average types. The strategy rules are to go long when the price closes above the upper band and close the long when it closes below the lower band. So, the entry and exit conditions are based on the close relative to the bands.
Estrategia NASDAQ Futuros - EMA + RSI + Bollinger//@version=5
strategy("Estrategia NASDAQ Futuros - EMA + RSI + Bollinger", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// Parámetros de la EMA
ema_rapida = ta.ema(close, 9)
ema_lenta = ta.ema(close, 21)
// Parámetros del RSI
rsi_length = 14
rsi_sobrecompra = 70
rsi_sobreventa = 30
rsi = ta.rsi(close, rsi_length)
// Parámetros de las Bandas de Bollinger
bb_length = 20
bb_desviacion = 2
= ta.bb(close, bb_length, bb_desviacion)
// Condiciones de Entrada
condicion_compra = ta.crossover(ema_rapida, ema_lenta) and rsi < rsi_sobreventa and close < bb_inferior
condicion_venta = ta.crossunder(ema_rapida, ema_lenta) and rsi > rsi_sobrecompra and close > bb_superior
// Ejecución de las Órdenes
if (condicion_compra)
strategy.entry("Compra", strategy.long)
if (condicion_venta)
strategy.entry("Venta", strategy.short)
// Gestión del Riesgo
stop_loss = 50 // Ajusta según el valor del futuro del NASDAQ
take_profit = 100
strategy.exit("Cerrar Compra", "Compra", stop=strategy.position_avg_price * (1 - stop_loss/10000), limit=strategy.position_avg_price * (1 + take_profit/10000))
strategy.exit("Cerrar Venta", "Venta", stop=strategy.position_avg_price * (1 + stop_loss/10000), limit=strategy.position_avg_price * (1 - take_profit/10000))
// Visualización en el Gráfico
plot(ema_rapida, color=color.blue, title="EMA Rápida (9)")
plot(ema_lenta, color=color.red, title="EMA Lenta (21)")
plot(bb_superior, color=color.green, title="Banda Superior")
plot(bb_inferior, color=color.red, title="Banda Inferior")
hline(rsi_sobrecompra, "Sobrecompra", color=color.red)
hline(rsi_sobreventa, "Sobreventa", color=color.green)
Elisathe indicator uses Bollinger Bands with various moving average types. The strategy rules are to go long when the price closes above the upper band and close the long when it closes below the lower band. So, the entry and exit conditions are based on the close relative to the bands.
Gold Trading StrategyStrategy Logic:*
1. *Trend Filter:* Uses 50/200 EMA crossovers (common for gold trend identification)
2. *Momentum Confirmation:* MACD crossover system with RSI filter
3. *Volatility Breakout:* Entry on 20-period high/low breaks
4. *Risk Management:* 2% stop-loss and 3% take-profit levels
*Key Features:*
- Visual EMA trend lines
- Dynamic support/resistance levels
- Clear buy/sell signals with alerts
- Integrated risk management
- Works best on 1H-4H timeframes for gold
*Usage Tips:*
1. Apply to XAU/USD charts
2. Best used on 1-hour or 4-hour timeframes
3. Combine with fundamental analysis (USD news, geopolitical events)
4. Adjust stop-loss/take-profit based on volatility (use ATR as reference)
*Optimization Suggestions:*
- Test different EMA combinations (e.g., 100/200)
- Adjust RSI thresholds based on gold's current volatility
- Modify lookback period for support/resistance levels
- Experiment with different timeframes (works best 1H-4H)
Remember to:
- Always forward-test with small positions first
- Adjust parameters during different market regimes
- Combine with gold-specific news analysis
- Monitor USD strength and real yields correlation
EMA 5 and SMA 10 Crossover with RSI by santosh kadamExplanation of the Script:
Indicators:
EMA 5 and SMA 10: These are the two moving averages used to determine the trend direction.
Buy signal is triggered when EMA 5 crosses above SMA 10.
Sell signal is triggered when EMA 5 crosses below SMA 10.
RSI 14: This is used to filter buy and sell signals.
Buy trades are allowed only if RSI 14 is above 60.
Sell trades are allowed only if RSI 14 is below 50.
Buy Conditions:
The strategy waits for the EMA crossover (EMA 5 crosses above SMA 10).
The strategy checks if RSI 14 is above 60 for confirmation.
If the price is below 60 on RSI 14 at the time of crossover, the strategy will wait until the price crosses above 60 on RSI 14 to initiate the buy.
Sell Conditions:
The strategy waits for the EMA crossover (EMA 5 crosses below SMA 10).
The strategy checks if RSI 14 is below 50 for confirmation.
If the price is above 50 on RSI 14 at the time of crossover, the strategy will wait until the price crosses below 50 on RSI 14 to initiate the sell.
Exit Conditions:
The Buy position is closed if the EMA crossover reverses (EMA 5 crosses below SMA 10) or RSI 14 drops below 50.
The Sell position is closed if the EMA crossover reverses (EMA 5 crosses above SMA 10) or RSI 14 rises above 60.
Plotting:
The script plots the EMA 5, SMA 10, and RSI 14 on the chart for easy visualization.
Horizontal lines are drawn at RSI 60 and RSI 50 levels for reference.
Key Features:
Price Confirmation: The strategy ensures that buy trades are only initiated if RSI 14 crosses above 60, and sell trades are only initiated if RSI 14 crosses below 50. Additionally, price action must cross these RSI levels to confirm the trade.
Reversal Exits: Positions are closed when the EMA crossover or RSI condition reverses.
Backtesting:
Paste this script into the Pine Editor on TradingView to test it with historical data.
You can adjust the EMA, SMA, and RSI lengths based on your preferences.
Let me know if you need further adjustments or clarification!
Demo GPT - Bollinger Bands StrategyDemo GPT - Bollinger Bands Strategy, this strategy is going to help the people in identifying buy and sell signals
Donchian Channel Strategy by ardhankurniawanThis strategy combines the Donchian Channel with a 200-period Simple Moving Average (SMA) to identify potential long and short trade opportunities. The Donchian Channel is calculated using a 20-period range, and it plots the upper, lower, and midlines. The strategy enters a long position when the price breaks above the highest point of the Donchian Channel and is above the SMA 200, and enters a short position when the price falls below the lowest point of the Donchian Channel and is below the SMA 200. A custom stop loss is applied for both long and short positions based on the midline of the Donchian Channel, with a 45% offset.
Disclaimer:
This trading strategy is for research purposes only and should not be considered as financial or investment advice. The use of this strategy involves risk, and past performance is not indicative of future results. Always conduct your own research and consult with a financial advisor before making any investment decisions. Trading involves significant risk, and you could lose more than your initial investment. By using this strategy, you agree to take full responsibility for any trades executed and the associated risks.
Engulfing Candles Strategy by ardhankurniawanThis strategy is based on the Engulfing Candlestick pattern and incorporates a Risk-Reward ratio of 1:2. It utilizes two primary indicators:
1. SMA 200 (200-period Simple Moving Average): Used to identify the overall trend, with buy signals occurring above the SMA and sell signals below it.
2. Bollinger Bands: Provides a volatility-based range for price action. Buy signals occur when the price is above both the SMA 200 and the middle Bollinger Band, while sell signals occur when the price is below both.
The strategy executes a long position (buy) when a Bullish Engulfing candle pattern forms above the SMA 200 and the middle Bollinger Band, and it exits the position using a stop loss at the low of the Bullish Engulfing candle and a take profit at a 1:2 risk-reward ratio. Similarly, a short position (sell) is initiated when a Bearish Engulfing pattern appears below the SMA 200 and the middle Bollinger Band, with the stop loss placed at the high of the Bearish Engulfing candle and a take profit at the same 1:2 risk-reward ratio.
The strategy is designed for trend-following trades with clear entry and exit points based on candlestick patterns and key indicators.
Disclaimer:
This trading strategy is for research purposes only and should not be considered as financial or investment advice. The use of this strategy involves risk, and past performance is not indicative of future results. Always conduct your own research and consult with a financial advisor before making any investment decisions. Trading involves significant risk, and you could lose more than your initial investment. By using this strategy, you agree to take full responsibility for any trades executed and the associated risks.
1AM CRT (Long)1am utc-5 CRT long execution 2 and 3 am than take profit
1am utc-5 CRT long execution 2 and 3 am than take profit1am utc-5 CRT long execution 2 and 3 am than take profit1am utc-5 CRT long execution 2 and 3 am than take profit1am utc-5 CRT long execution 2 and 3 am than take profit1am utc-5 CRT long execution 2 and 3 am than take profit1am utc-5 CRT long execution 2 and 3 am than take profit1am utc-5 CRT long execution 2 and 3 am than take profit1am utc-5 CRT long execution 2 and 3 am than take profit1am utc-5 CRT long execution 2 and 3 am than take profit
Simple Falling Wedge Strategy - FoenySmiles v1.0This is a trend reversal strategy trying to catch the bottom of downtrends when they show signs of weakening (falling wedge pattern) while using trailing stops to protect profits if the reversal works out.
Falling wedge strategy:
Looks for falling wedge patterns where both highs and lows are declining
Specifically, it wants to see Lower highs for 3 consecutive bars, Lower lows for 3 consecutive bars, RSI must be above 30 (showing the downtrend might be losing momentum)
Risk Management:
Uses ATR (Average True Range) to set stop losses
Initial stop loss is set at: Entry Price - (ATR × 2.0)
Stop loss trails upward as price moves up, but never moves down
Uses 100% of account equity for position sizing
Includes 0.1% commission and 3 points slippage in calculations
Exit Rules:
The strategy exits when either:
Price closes below the trailing stop loss or RSI becomes overbought (>70)
Key Parameters:
RSI Length: 3 periods (very short-term momentum)
Pattern Lookback: 11 bars
ATR Period: 14 bars
ATR Multiplier: 2.0 for stop loss calculation
Date Range: 2018 to 2069
Shoutout to Sam Price for being an awesome mentor and supporting a community of inspired traders. Let's go lifers!!
foneysmiles gmail.com if you have any questions or have other ideas on use cases.
TFEX Futures Strategy with Volume Profile//@version=5
strategy("TFEX Futures Strategy with Volume Profile", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// กำหนดพารามิเตอร์
fastLength = input.int(9, title="Fast MA Length")
slowLength = input.int(21, title="Slow MA Length")
rsiLength = input.int(14, title="RSI Length")
overbought = input.float(70, title="Overbought Level")
oversold = input.float(30, title="Oversold Level")
vpLength = input.int(20, title="Volume Profile Length") // ความยาวของ Volume Profile
// คำนวณ Moving Averages
fastMA = ta.sma(close, fastLength)
slowMA = ta.sma(close, slowLength)
// คำนวณ RSI
rsi = ta.rsi(close, rsiLength)
// สัญญาณ Moving Average Crossover
maCrossover = ta.crossover(fastMA, slowMA) // Fast MA ข้าม Slow MA ขึ้น (สัญญาณ Buy)
maCrossunder = ta.crossunder(fastMA, slowMA) // Fast MA ข้าม Slow MA ลง (สัญญาณ Sell)
// สัญญาณ RSI
rsiBuySignal = rsi < oversold // RSI ต่ำกว่า Oversold (สัญญาณ Buy)
rsiSellSignal = rsi > overbought // RSI สูงกว่า Overbought (สัญญาณ Sell)
// Volume Profile
var float vpHigh = na
var float vpLow = na
if bar_index == last_bar_index - vpLength
vpHigh = ta.highest(high, vpLength)
vpLow = ta.lowest(low, vpLength)
// แสดง Volume Profile Zone
bgcolor(bar_index >= last_bar_index - vpLength ? color.new(color.blue, 90) : na, title="Volume Profile Zone")
// เงื่อนไขการเทรดด้วย Volume Profile
volumeProfileFilter = close > vpLow and close < vpHigh // ราคาปิดอยู่ในโซน Volume Profile
// เงื่อนไขการเทรด
if (maCrossover and rsiBuySignal and volumeProfileFilter)
strategy.entry("Buy", strategy.long)
label.new(bar_index, low, text="Buy", style=label.style_label_up, color=color.green, textcolor=color.white, size=size.small)
if (maCrossunder and rsiSellSignal and volumeProfileFilter)
strategy.entry("Sell", strategy.short)
label.new(bar_index, high, text="Sell", style=label.style_label_down, color=color.red, textcolor=color.white, size=size.small)
// แสดง Moving Averages บนกราฟ
plot(fastMA, title="Fast MA", color=color.blue, linewidth=2)
plot(slowMA, title="Slow MA", color=color.red, linewidth=2)
// แสดง RSI บนกราฟ
hline(overbought, "Overbought", color=color.red)
hline(oversold, "Oversold", color=color.green)
plot(rsi, title="RSI", color=color.purple, linewidth=2)
SMA + RSI + Volume + ATR StrategySMA + RSI + Volume + ATR Strategy
1. Indicators Used:
SMA (Simple Moving Average): This is a trend-following indicator that calculates the average price of a security over a specified period (50 periods in this case). It's used to identify the overall trend of the market.
RSI (Relative Strength Index): This measures the speed and change of price movements. It tells us if the market is overbought (too high) or oversold (too low). Overbought is above 70 and oversold is below 30.
Volume: This is the amount of trading activity. A higher volume often indicates strong interest in a particular price move.
ATR (Average True Range): This measures volatility, or how much the price is moving in a given period. It helps us adjust stop losses and take profits based on market volatility.
2. Conditions for Entering Trades:
Buy Signal (Green Up Arrow):
Price is above the 50-period SMA (indicating an uptrend).
RSI is below 30 (indicating the market might be oversold or undervalued, signaling a potential reversal).
Current volume is higher than average volume (indicating strong interest in the move).
ATR is increasing (indicating higher volatility, suggesting that the market might be ready for a move).
Sell Signal (Red Down Arrow):
Price is below the 50-period SMA (indicating a downtrend).
RSI is above 70 (indicating the market might be overbought or overvalued, signaling a potential reversal).
Current volume is higher than average volume (indicating strong interest in the move).
ATR is increasing (indicating higher volatility, suggesting that the market might be ready for a move).
3. Take Profit & Stop Loss:
Take Profit: When a trade is made, the strategy will set a target price at a certain percentage above or below the entry price (1.5% in this case) to automatically exit the trade once that target is hit.
Stop Loss: If the price goes against the position, a stop loss is set at a percentage below or above the entry price (0.5% in this case) to limit losses.
4. Execution of Trades:
When the buy condition is met, the strategy will enter a long position (buying).
When the sell condition is met, the strategy will enter a short position (selling).
5. Visual Representation:
Green Up Arrow: Appears on the chart when the buy condition is met.
Red Down Arrow: Appears on the chart when the sell condition is met.
These arrows help you see at a glance when the strategy suggests you should buy or sell.
In Summary:
This strategy uses a combination of trend-following (SMA), momentum (RSI), volume, and volatility (ATR) to decide when to buy or sell a stock. It looks for opportunities when the market is either oversold (buy signal) or overbought (sell signal) and makes sure there’s enough volume and volatility to back up the move. It also includes take-profit and stop-loss levels to manage risk.
Altcoin Long/Short Strategy//@version=5
strategy("Altcoin Long/Short Strategy", overlay=true, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=2, commission_type=strategy.commission.percent, commission_value=0.1)
// —————— Inputs ——————
emaFastLength = input.int(20, "Fast EMA")
emaSlowLength = input.int(50, "Slow EMA")
rsiLength = input.int(14, "RSI Length")
bbLength = input.int(20, "Bollinger Bands Length")
riskRewardRatio = input.float(1.5, "Risk/Reward Ratio")
stopLossPerc = input.float(2, "Stop Loss %") / 100
// —————— Indicators ——————
// Trend: EMAs
emaFast = ta.ema(close, emaFastLength)
emaSlow = ta.ema(close, emaSlowLength)
ema200 = ta.ema(close, 200)
// Momentum: RSI & MACD
rsi = ta.rsi(close, rsiLength)
= ta.macd(close, 12, 26, 9)
// Volatility: Bollinger Bands
basis = ta.sma(close, bbLength)
dev = ta.stdev(close, bbLength)
upperBand = basis + 2 * dev
lowerBand = basis - 2 * dev
// —————— Strategy Logic ——————
// Long Conditions
longCondition =
close > ema200 and // Long-term bullish
ta.crossover(emaFast, emaSlow) and // EMA crossover
rsi > 50 and // Momentum rising
close > lowerBand and // Bounce from lower Bollinger Band
macdLine > signalLine // MACD bullish
// Short Conditions
shortCondition =
close < ema200 and // Long-term bearish
ta.crossunder(emaFast, emaSlow) and // EMA crossunder
rsi < 50 and // Momentum weakening
close < upperBand and // Rejection from upper Bollinger Band
macdLine < signalLine // MACD bearish
// —————— Risk Management ——————
stopLoss = strategy.position_avg_price * (1 - stopLossPerc)
takeProfit = strategy.position_avg_price * (1 + (riskRewardRatio * stopLossPerc))
// —————— Execute Trades ——————
if (longCondition)
strategy.entry("Long", strategy.long)
strategy.exit("Exit Long", "Long", stop=stopLoss, limit=takeProfit)
if (shortCondition)
strategy.entry("Short", strategy.short)
strategy.exit("Exit Short", "Short", stop=stopLoss, limit=takeProfit)
// —————— Plotting ——————
plot(emaFast, "Fast EMA", color=color.blue)
plot(emaSlow, "Slow EMA", color=color.orange)
plot(ema200, "200 EMA", color=color.gray)
plot(upperBand, "Upper Bollinger", color=color.red)
plot(lowerBand, "Lower Bollinger", color=color.green)
Gaussian Channel with Stochastic RSIStrategy based on the Gaussian Channel and add Stochastic RSI to avoid bad trades.
Good for Long only, no shorting.
Never uses lookahead_on.
AK-GBT1AK-GBT1 ist eine Test Trading Strategy für automatisiertes Trading mit Cornix. Es ist noch noch in der Beta Phase und befindet sich im intensiven Test.
gold 1m stgyye script gold me 1m sahi kaam karta hai chaho to aap test Karke dekh sakte ho iska Norman Maine Kiya ware
EMA50150 with SMA150 Stop-loss and Re-Entry #gangesThis strategy is a trading system that uses Exponential Moving Averages (EMA) and Simple Moving Averages (SMA) to determine entry and exit points for trades. Here's a breakdown of the key components and logic:
Key Indicators:
EMA 50 (Exponential Moving Average with a 50-period window): This is a more responsive moving average to recent price movements.
EMA 150 (Exponential Moving Average with a 150-period window): A slower-moving average that helps identify longer-term trends.
SMA 150 (Simple Moving Average with a 150-period window): This acts as a stop-loss indicator for long trades.
User Inputs:
Start Date and End Date: The strategy is applied only within this date range, ensuring that trading only occurs during the specified period.
Trade Conditions:
Buy Signal (Long Position):
A buy is triggered when the 50-period EMA crosses above the 150-period EMA (indicating the price is gaining upward momentum).
Sell Signal (Short Position):
A sell is triggered when the 50-period EMA crosses below the 150-period EMA (indicating the price is losing upward momentum and moving downward).
Stop-Loss for Long Positions:
If the price drops below the 150-period SMA, the strategy closes any long positions as a stop-loss mechanism to limit further losses.
Re-Entry After Stop-Loss:
After a stop-loss is triggered, the strategy monitors for a re-entry signal:
Re-buy: If the price crosses above the 150-period EMA from below, a new long position is triggered.
Re-sell: If the 50-period EMA crosses below the 150-period EMA, a new short position is triggered.
Trade Execution:
Buy or Sell: The strategy enters trades based on the conditions described and exits them if the stop-loss conditions are met.
Re-entry: After a stop-loss, the strategy tries to re-enter the market based on the same buy/sell conditions.
Risk Management:
Commission and Slippage: The strategy includes a 0.1% commission on each trade and allows for 3 pips of slippage to account for real market conditions.
Visuals:
The strategy plots the 50-period EMA (blue), 150-period EMA (red), and 150-period SMA (orange) on the chart, helping users visualize the key levels for decision-making.
Date Range Filter:
The strategy only executes trades during the user-defined date range, which helps limit trades to a specific period and avoid backtesting errors on irrelevant data.
Stop-Loss Logic:
The stop-loss is triggered when the price crosses below the 150-period SMA, closing the long position to protect against significant drawdowns.
Overall Strategy Goal:
The strategy aims to capture long-term trends using the EMAs for entry signals, while protecting profits through the stop-loss mechanism and offering a way to re-enter the market after a stop-loss.
Advanced Multi-Strategy Trading SystemTrade with the trend: The strategy uses EMAs, RSI, and MACD to identify the trend and momentum, helping you enter trades that align with the broader market movement.
Risk management: You can control your risk with dynamic position sizing, stop loss, and take profit levels. The trailing stop ensures that you lock in profits as the market moves in your favor.
Strategy Execution: When the buy or sell signals appear, the strategy will automatically enter trades for you. The script calculates optimal position sizes and manages the trades based on your predefined risk parameters.
queen of the kings//@version=5
strategy("queen of the kings", overlay=true, initial_capital=100000, commission_value=0.1, commission_type=strategy.commission.percent)
// Time window
startDate = timestamp("2016-01-01T00:00:00")
endDate = timestamp("2069-01-01T00:00:00")
timeInWindow = time >= startDate and time <= endDate
// Original EMAs and SMAs
len1 = input.int(5, title="EMA 1")
src1 = input.source(close, title="Source One")
out1 = ta.ema(src1, len1)
plot(out1, title="EMA 1", color=color.lime, transp=0, linewidth=2)
len2 = input.int(9, title="EMA 2")
src2 = input.source(close, title="Source Two")
out2 = ta.ema(src2, len2)
plot(out2, title="EMA 2", color=color.yellow, transp=0, linewidth=2)
len3 = input.int(12, title="EMA 3")
src3 = input.source(close, title="Source Three")
out3 = ta.ema(src3, len3)
plot(out3, title="EMA 3", color=color.orange, transp=0, linewidth=2)
len4 = input.int(21, title="EMA 4")
src4 = input.source(close, title="Source Four")
out4 = ta.ema(src4, len4)
plot(out4, title="EMA 4", color=color.red, transp=0, linewidth=2)
len5 = input.int(50, title="EMA 5")
src5 = input.source(close, title="Source Five")
out5 = ta.ema(src5, len5)
plot(out5, title="EMA 5", color=#F900F9, transp=0, linewidth=2)
len6 = input.int(200, title="EMA 6")
src6 = input.source(close, title="Source Six")
out6 = ta.ema(src6, len6)
plot(out6, title="EMA 6", color=#01F9F1, transp=0, linewidth=2)
len7 = input.int(100, title="SMA 1")
src7 = input.source(close, title="Source Seven")
out7 = ta.sma(src7, len7)
plot(out7, color=color.blue, transp=0, linewidth=2, title="SMA 1")
len8 = input.int(200, title="SMA 2")
src8 = input.source(close, title="Source Eight")
out8 = ta.sma(src8, len8)
plot(out8, color=color.white, transp=0, linewidth=2, title="SMA 2")
// Strategy specific EMA
strategy_ema = ta.ema(close, 2000)
// Stochastic RSI
smoothK = input.int(3, "Stoch RSI K")
smoothD = input.int(3, "Stoch RSI D")
lengthRSI = input.int(14, "RSI Length")
lengthStoch = input.int(14, "Stoch Length")
rsi1 = ta.rsi(close, lengthRSI)
stoch = ta.stoch(rsi1, rsi1, rsi1, lengthStoch)
k = ta.sma(stoch, smoothK)
d = ta.sma(k, smoothD)
// Price relative to EMA calculations
priceAboveEma = close > strategy_ema * 1.005
priceBelowEma = close < strategy_ema * 0.99
// Crossover conditions
crossAboveThreshold = ta.crossover(close, strategy_ema * 1.005)
crossBelowThreshold = ta.crossunder(close, strategy_ema * 0.99)
// Strategy conditions with StochRSI
longCondition = crossAboveThreshold and k > d and k < 80 and strategy.position_size == 0
exitLong = crossBelowThreshold and strategy.position_size > 0
// Strategy execution
if timeInWindow
if (longCondition)
strategy.entry("Long", strategy.long)
if (exitLong)
strategy.close("Long")
// Plot signals
plotshape(series=longCondition, title="Buy Signal", style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)
plotshape(series=exitLong, title="Sell Signal", style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)
// Plot the threshold lines
plot(strategy_ema * 1.005, color=color.green, style=plot.style_circles, title="Buy Threshold")
plot(strategy_ema * 0.99, color=color.red, style=plot.style_circles, title="Sell Threshold")
Moving Average Crossover with Stop Loss and Take ProfitMoving Average Crossover with Stop Loss and Take Profit