繁体   English   中英

止损止盈系统很破

[英]Stop loss and take profit system is very broken

在我的系统中,止损位于最后五根蜡烛的最低价格,但如果价格之间的距离小于 0.075%,则使用最小止损距离。 短裤也一样,但翻转了。

MinStopLong = strategy.position_avg_price * (1 - 0.00075)
MinStopShort = strategy.position_avg_price * (1 + 0.00075)
StopLossLong = ta.lowest(low,5)
StopLossShort = ta.highest(high,5)
if MinStopLong < StopLossLong
    StopLossLong := MinStopLong
if MinStopShort > StopLossShort
    StopLossShort := MinStopShort

//Take Profit

TakeProfitLong = strategy.position_avg_price + (2 * (strategy.position_avg_price - StopLossLong))
TakeProfitShort = strategy.position_avg_price - (2 *(StopLossShort - strategy.position_avg_price))

//Plot

//Strategy Exit
if strategy.position_avg_price>0
    strategy.exit(id='loss', stop=StopLossLong) 
    strategy.exit(id='win',limit=TakeProfitLong)
if strategy.position_avg_price<0
    strategy.exit(id='loss', stop=StopLossShort)
    strategy.exit(id='win', limit=TakeProfitShort)'''

买入似乎没有获利,而空头似乎在下一次开盘时亏损。 我不知道为什么这会严重破坏。

也许尝试只使用 1 strategy.exit,你不需要 2 我觉得这是主要问题,第一个 strategy.exit 设置为退出 100% 的交易,然后第二个 strategy.exit 不能有任何东西离开

我的意思是,仅使用 1 strategy.exit 处理您的 SL 和 TP

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM