本策略是一个基于简单移动平均线的趋势跟踪和反转交易策略。它使用1日线和4日线的均线交叉来判断趋势方向,进而产生买入和卖出信号。
当1日线从上方向下交叉4日线时,产生卖出信号;当1日线从下方向上交叉4日线时,产生买入信号。这样通过快速移动平均线和慢速移动平均线的交叉来判断市场趋势的转折点,进而获利。
入市后设置止损点和止盈点。止损点设置为入市价格之下10个点,止盈点设置为入市价格之上100个点。这样可以限制损失和锁定利润。
可以通过调整均线参数,设置动态止损止盈机制,或加入其它指标判断来降低这些风险。
本策略整体来说是一个典型的双均线交易策略。它使用快慢均线交叉判断趋势转折点,设置止损止盈控制风险,简单实用,容易理解,适合初学者。通过参数调整和优化,可以适应不同市场环境,也可以加入其他指标过滤来提高效果。总的来说,本策略作为一个入门学习策略是非常不错的。
/*backtest
start: 2023-11-19 00:00:00
end: 2023-12-19 00:00:00
period: 1h
basePeriod: 15m
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/
// © cesarpieres72
//@version=5
strategy("300% STRATEGY", overlay=true, margin_long=10, margin_short=10)
var float lastLongOrderPrice = na
var float lastShortOrderPrice = na
longCondition = ta.crossover(ta.sma(close, 1), ta.sma(close, 4))
if (longCondition)
strategy.entry("Long Entry", strategy.long) // Enter long
shortCondition = ta.crossunder(ta.sma(close, 1), ta.sma(close, 4))
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 - 170 // 10 USDT lower than the last long order price
takeProfitLong = lastLongOrderPrice + 150 // 100 USDT higher than the last long order price
stopLossShort = lastShortOrderPrice + 170 // 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)