该策略利用心理线指标判断市场买卖力道比,以捕捉市场趋势变化。当买盘力道强于卖盘时做多,当卖盘力道强于买盘时做空。心理线简单易用,可作为趋势识别的辅助工具。
心理线指标计算一定周期内收盘价上涨的比例。
当比例超过50%时,认为买盘力道大于卖盘力道,给出做多信号。
当比例低于50%时,认为卖盘力道大于买盘力道,给出做空信号。
当比例在50%附近震荡,认为买卖平衡,市场无明确方向。
可灵活调整参数,对短期或长期趋势进行判断。
计算方法简单,易于实盘操作。
直观显示买卖力道强弱,辅助判断资金流向。
可 discover 部分反转信号。
可搭配其他指标一起使用,提高策略效果。
无法判断趋势的持续时间和力度。
参数设置不当可能产生大量错误信号。
单独使用容易被套,应该与其他指标组合。
需要优化参数以适应不同品种和周期。
测试不同参数在各品种的效果,找到最佳周期。
组合更多指标判断趋势持续性。
优化资金管理策略,设置止损和止盈。
评估趋势强弱,避免反向开仓过早。
在特定时间段关闭策略,规避容易产生错误的时间段。
心理线指标本身较为简单,但搭配使用效果不错。可作为发现趋势变化的辅助工具之一,但不宜单独使用。通过参数优化及整合其他指标,可将心理线策略提升到一个新的水平,值得进一步研究。
/*backtest
start: 2023-09-12 00:00:00
end: 2023-09-19 00:00:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
////////////////////////////////////////////////////////////
// Copyright by HPotter v1.0 10/04/2018
// Psychological line (PSY), as an indicator, is the ratio of the number of
// rising periods over the total number of periods. It reflects the buying
// power in relation to the selling power.
//
// If PSY is above 50%, it indicates that buyers are in control. Likewise,
// if it is below 50%, it indicates the sellers are in control. If the PSY
// moves along the 50% area, it indicates balance between the buyers and
// sellers and therefore there is no direction movement for the market.
//
// You can change long to short in the Input Settings
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
strategy(title="Psychological line Backtest")
Length = input(20, minval=1)
reverse = input(false, title="Trade reverse")
xPSY = sum(close > close[1],Length) / Length * 100
clr = iff(xPSY >= 50, green, red)
pos = iff(xPSY > 50, 1,
iff(xPSY < 50, -1, nz(pos[1], 0)))
possig = iff(reverse and pos == 1, -1,
iff(reverse and pos == -1, 1, pos))
if (possig == 1)
strategy.entry("Long", strategy.long)
if (possig == -1)
strategy.entry("Short", strategy.short)
barcolor(possig == -1 ? red: possig == 1 ? green : blue )
p1 = plot(50, color=black, title="0")
p2 = plot(xPSY, color=blue, title="PSY")
fill(p1, p2, color=clr)