好的,我正在测试一个策略,我需要让策略进入和退出正确。
在我的例子中,我想下一个带有固定止损和限价的订单。
如果有另一个买入(或卖出)信号并打开头寸,我想要第二个入场点,它有自己的固定止损和限价。
目前,我可以使用 strategy.entry()
持有多个职位,并且可以使用 strategy.exit()
然而,当下一个买入/卖出信号产生时,新交易的退出头寸会计算并且也会改变已经打开的交易的退出条件
这里是触发进入和退出的语句
//Strategy Entry Signals
if (showBuySig)
BuyStopPrice = atrSell[1]
BuyLimitPrice = open + ((open - atrSell[1])*1.5)
strategy.entry("HildayBuy", strategy.long, comment="HildaBuy")
strategy.exit("HildaBuy", stop = BuyStopPrice, limit = BuyLimitPrice, comment="SL/TP")
简单地说,如果产生买入信号,那么它会创建一个入场点并设置(更新现有的)离场价格
Pyramiding 设置为 10 以允许多个位置。
现在,我只需要了解如何为每个位置设置单独的退出点,但真的很难弄清楚如何。
更新
我使用 TIME 为每个订单创建了一个唯一的字符串引用:
IDnumBuy = tostring(time)
BuyStopPrice = close - (close - atrSell)
BuyLimitPrice = close + ((close - atrSell)*1.5)
strategy.entry(IDnumBuy, strategy.long, comment="Buy Entry: "+tostring(close)+" TP:"+tostring(BuyLimitPrice)+ " SL:"+tostring(BuyStopPrice)+" ID:"+IDnumBuy)
strategy.exit("Exit", IDnumBuy, stop = BuyStopPrice, limit = BuyLimitPrice, comment="SL/TP ")```
答案 0 :(得分:0)
试试这个:
Future<void> uploadFile(String filePath) async {
File file = File(filePath);
try {
await firebase_storage.FirebaseStorage.instance
.ref('uploads/file-to-upload.png')
.putFile(file);
} on firebase_core.FirebaseException catch (e) {
// e.g, e.code == 'canceled'
}
}