
This is an intelligent trading strategy system based on Exponential Moving Average (EMA). The strategy utilizes crossover signals between short-term and long-term EMAs, combined with price-EMA relationships to identify market trends and trading opportunities. The strategy was developed with AI assistance, achieving automated trading through dynamic price trend analysis.
The core logic of the strategy is based on several key components: 1. Dual EMA System: Uses 9-period and 21-period exponential moving averages as signal indicators 2. Trend Determination: Market trend direction is determined by the position of short-term EMA relative to long-term EMA 3. Entry Signals: Long positions are taken when price breaks above short-term EMA in uptrends; short positions when price breaks below short-term EMA in downtrends 4. Exit Mechanism: Reverse crossovers between price and short-term EMA serve as stop-loss signals
This is a well-structured trend-following strategy with clear logic. Through the coordinated use of EMA indicators, it achieves effective market trend capture. The strategy’s optimization potential mainly lies in signal filtering and risk management aspects, with continuous improvements potentially enhancing strategy stability and profitability.
/*backtest
start: 2024-12-19 00:00:00
end: 2024-12-25 08:00:00
period: 45m
basePeriod: 45m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Jerryorange
//@version=6
strategy("Smart EMA Algo", overlay=true)
// Inputs
emaShortLength = input.int(9, title="Short EMA Length", minval=1)
emaLongLength = input.int(21, title="Long EMA Length", minval=1)
src = input(close, title="Source")
// EMA Calculations
emaShort = ta.ema(src, emaShortLength)
emaLong = ta.ema(src, emaLongLength)
// Market Direction
isUptrend = emaShort > emaLong
isDowntrend = emaShort < emaLong
// Entry Conditions
longCondition = isUptrend and ta.crossover(close, emaShort)
shortCondition = isDowntrend and ta.crossunder(close, emaShort)
// Exit Conditions
exitLong = ta.crossunder(close, emaShort)
exitShort = ta.crossover(close, emaShort)
// Strategy Logic
if (longCondition)
strategy.entry("Buy", strategy.long)
if (shortCondition)
strategy.entry("Sell", strategy.short)
if (exitLong)
strategy.close("Buy")
if (exitShort)
strategy.close("Sell")
// Plot EMAs
plot(emaShort, color=color.blue, title="Short EMA")
plot(emaLong, color=color.red, title="Long EMA")