该策略通过分析两天的收盘价差异,判断未来价格运动方向,实现短线交易。策略简单直观,易于实施,适合短线交易者。
该策略的核心逻辑是比较今天的收盘价和昨天的收盘价。具体来说:
这里的关键是设定合理的阈值。如果阈值设置过大,将错过较小的价格波动;如果阈值过小,将因正常波动而引发过多非理性交易。策略采用可调节的阈值设计,默认值为0.004,步长0.001,可以根据历史数据进行测试,选择合适的阈值。
总的来说,该策略捕捉价格在连续两个交易日之间的变化,通过阈值过滤正常波动,判断未来可能的价格趋势方向,以此进行短线交易。策略思路简单直观,容易理解和实现。
要解决这些风险,可以考虑:
该策略可以考虑从以下几个方向进行优化:
多种时间周期回测 - 采用不同的时间周期(日线、4小时、1小时等)回测策略参数,选择最优时间周期和参数。
结合波动率指标 - 加入考虑价格波动率的指标,如ATR,可以更好地建立动态阈值。
加入止损逻辑 - 设定合理的止损点,以控制单次损失。
优化仓位管理 - 优化建仓的仓位大小和加仓规则,在保证止损的同时,提高盈利。
考虑交易成本 - 在回测中加入交易手续费,滑点等交易成本考量,使回测更贴近实盘。
引入机器学习 - 应用机器学习算法提取更多特征,建立更强大的交易信号。
本策略基于收盘价差异判断未来价格趋势,采用简单直观的思路设计短线交易策略。策略容易实现,适合短线操作,但可能存在一定亏损风险。通过多种优化手段,可以提高策略稳定性和盈利能力。本策略为基础策略,可为进一步研究提供思路和参考。
/*backtest
start: 2023-08-28 00:00:00
end: 2023-09-27 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
strategy("Daily Close Comparison Strategy (by ChartArt) repainting results", shorttitle="CA_-_Daily_Close_Strat", overlay=false)
// ChartArt's Daily Close Comparison Strategy
//
// Version 1.0
// Idea by ChartArt on February 28, 2016.
//
// This strategy is equal to the very
// popular "ANN Strategy" coded by sirolf2009,
// but without the Artificial Neural Network (ANN).
//
// Main difference besides stripping out the ANN
// is that I use close prices instead of OHLC4 prices.
// And the default threshold is set to 0 instead of 0.0014
// with a step of 0.001 instead of 0.0001.
//
// This strategy goes long if the close of the current day
// is larger than the close price of the last day.
// If the inverse logic is true, the strategy
// goes short (last close larger current close).
//
// This simple strategy does not have any
// stop loss or take profit money management logic.
//
// List of my work:
// https://www.tradingview.com/u/ChartArt/
//
// __ __ ___ __ ___
// / ` |__| /\ |__) | /\ |__) |
// \__, | | /~~\ | \ | /~~\ | \ |
//
//
threshold = input(title="Price Difference Threshold repainting results", type=float, defval=0.004, step=0.001)
getDiff() =>
yesterday=security(syminfo.tickerid, 'D', close[1])
today=security(syminfo.tickerid, 'D', close)
delta=today-yesterday
percentage=delta/yesterday
closeDiff = getDiff()
buying = closeDiff > threshold ? true : closeDiff < -threshold ? false : buying[1]
hline(0, title="zero line")
bgcolor(buying ? green : red, transp=25)
plot(closeDiff, color=silver, style=area, transp=75)
plot(closeDiff, color=aqua, title="prediction")
longCondition = buying
if (longCondition)
strategy.entry("Long", strategy.long)
shortCondition = buying != true
if (shortCondition)
strategy.entry("Short", strategy.short)