
この戦略は,単純な移動平均に基づいたクロス平均線逆転戦略である.これは,長さ1と長さ5の単純な移動平均を使用し,短周期移動平均が,下から長い周期移動平均を横断するときに多し,上から下を通るときに空し,典型的なトレンド追跡戦略である.
この戦略は,1日間のシンプル移動平均sma1と5日間のシンプル移動平均sma5をclose価格で計算し,sma1の上にsma5をかけたときに多入し,sma1の下のsma5をかけたときに空き入りをする.オフストップは入場価格の下5ドル,オフストップは入場価格上150ドル,オフストップは入場価格上5ドル,オフストップは入場価格下150ドルとする.
改善する方向:
この戦略は,簡単な双均線戦略として,操作が簡単で,実装が容易な特性を有し,戦略のアイデアを迅速に検証することができる.しかし,その承受能力と利益の余地は比較的限られており,パラメータとフィルタリング条件を最適化して,より多くの市場環境に適応させる必要がある.初心者向けの最初の量化戦略として,基本的構成要素を含み,簡単な枠組みとして,繰り返し改善することができる.
/*backtest
start: 2023-02-19 00:00:00
end: 2024-02-19 00:00:00
period: 2d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Valeria 181 Bot Strategy Mejorado 2.21", overlay=true, margin_long=100, margin_short=100)
var float lastLongOrderPrice = na
var float lastShortOrderPrice = na
longCondition = ta.crossover(ta.sma(close, 1), ta.sma(close, 5))
if (longCondition)
strategy.entry("Long Entry", strategy.long) // Enter long
shortCondition = ta.crossunder(ta.sma(close, 1), ta.sma(close, 5))
if (shortCondition)
strategy.entry("Short Entry", strategy.short) // Enter short
if (longCondition)
lastLongOrderPrice := close
if (shortCondition)
lastShortOrderPrice := close
// Calculate stop loss and take profit based on the last executed order's price
stopLossLong = lastLongOrderPrice - 5 // 10 USDT lower than the last long order price
takeProfitLong = lastLongOrderPrice + 151 // 100 USDT higher than the last long order price
stopLossShort = lastShortOrderPrice + 5 // 10 USDT higher than the last short order price
takeProfitShort = lastShortOrderPrice - 150 // 100 USDT lower than the last short order price
// Apply stop loss and take profit to long positions
strategy.exit("Long Exit", from_entry="Long Entry", stop=stopLossLong, limit=takeProfitLong)
// Apply stop loss and take profit to short positions
strategy.exit("Short Exit", from_entry="Short Entry", stop=stopLossShort, limit=takeProfitShort)