首页 > 解决方案 > 如何从柱上的最高价或最低价关闭所有订单?

问题描述

我有如下策略,每笔交易有多个条目。我想在 %x 盈利后立即退出。

但 close_all 始终采用柱线收盘价,而不是所需的最高或最低价。

我怎样才能做到这一点。?:

strategy(title =  - TAKE %x PROFIT", shorttitle="15 %1 strategy", overlay=true, pyramiding=10 , calc_on_order_fills=true, calc_on_every_tick=true , process_orders_on_close=true)

..
..

    
if (strategy.position_size > 0 )
    strategy.close_all(when=high>=longExitPrice)
    

if (strategy.position_size < 0 )
    strategy.close_all(when=low<=shortExitPrice)

标签: pine-scriptalgorithmic-tradingtradingcryptocurrency

解决方案


    strategy.exit("Stop Loss/TP","LONG",  limit=longExitPrice)

strategy.exit is the solution.


推荐阅读