【问题标题】:how to set max draw down per trade in pine如何设置每次松木交易的最大回撤
【发布时间】:2021-11-17 07:29:27
【问题描述】:

大家好,所以我在 pine 中有一个跨界策略,它没有 tp、sl 它只是在看涨交叉时买入并在看跌时卖出

我保持原样,不乱用 tp 和 sl 但我想设置一个 5% 的最大回撤,如果它下降到 5% 或更多,它将在蜡烛关闭时关闭交易

buy= crossunder (k,d)
sell= crossover(k,d)


// strategy
strategy.entry ("long", strategy.long, 100, when = buy) 
strategy.close ("long", when = sell)

【问题讨论】:

    标签: pine-script algorithmic-trading trading cryptocurrency tradingview-api


    【解决方案1】:

    这是一个止损设置,它将每笔交易的回撤限制为 5%。通常,回撤将作为整个策略整体参考,我们也可以这样做!这是第一部分,虽然完成了一个输入来更改它,还有一个图表,以便您在交易时可以看到它。

    stopPer = input(5.0, title='Stop Loss %', type=input.float) / 100
    
    longStop = strategy.position_avg_price * (1 - stopPer)
    
    plot(strategy.position_size > 0 ? longStop : na, style=plot.style_linebr, color=color.red, linewidth=1, title="Long Fixed SL")   
    
    strategy.exit(id="Close Long", stop=longStop, when=strategy.position_size > 0)
    

    【讨论】:

    • 伙计,这真是太棒了,我真的很感激,非常感谢,我添加到图表中,它现在像时钟一样工作,非常感谢,如果你不这样做,我想再问一个问题'不介意!您认为 t.v 回测有多准确,自 8 月 1 日以来,我在 15m 帧上获得 1200% 这正常吗?它仅适用于 btc 图表,其他图表在同一时间段和相同 t.f 中获得 1-30% 的利润
    • 太好了,没问题!任何回溯测试软件都可能有许多警告,但如果采取谨慎措施避免偏见并了解导致偏见的原因,那么结果可以与预期行为一致。也就是说,这听起来确实有点奇怪,而且回报率有点高,所以我会持怀疑态度,但由于无法获得更多信息,我无法进一步评论,因为这只是猜测。干杯!
    • 现在它工作了,但交易没有达到 binanace 遗憾的是我做错了什么,如果你有时间我会发布代码请检查它,我真的很抱歉给你带来了很多麻烦,我我是一名新程序员
    • 没问题!我会尽力帮助
    • strategy.entry ("long", strategy.long, when =buy,comment="Long", alert_message= Long) strategy.close ("long", when = sell, comment="Close Long", alert_message= ExitLong) strategy.entry ("short", strategy.short, when=sell, comment="Short", alert_message= Short) strategy.close ("short", when=buy, comment="关闭空头", alert_message=ExitShort) strategy.exit("Long TSL", "long", trail_points = 0.02, trail_offset = 0.1,alert_message=ExitLong) strategy.exit("Short TSL", "short", trail_points = 0.02, trail_offset = 0.1, alert_message= ExitShort)
    猜你喜欢
    • 2022-12-03
    • 2021-12-26
    • 2019-08-19
    • 2018-02-17
    • 2016-10-24
    • 2018-12-28
    • 2018-09-12
    • 1970-01-01
    • 2020-08-26
    相关资源
    最近更新 更多