Type/to search
0
Follow
0
Followers
Ajuda sobre o uso da pirâmide
Help
Created 2022-11-17 09:00:59  
 3
 1067

strategy ((title = "Obter sinais de multiplicação para entrar em posições de multiplicação", pyramding = 5)
if longCondition and strategy.position_size <= 0
strategy.entry ("abrir mais", strategy.long, when = lowLong, amount = amount, comment = "abrir mais posições")
if strategy.position_size > 0 and lowShort
strategy.close_all (em inglês)

Este código é o meu código de execução de estratégia. O que eu quero implementar é que, quando o sinal de condição longa é acionado e o sinal de cabeça pequena é acionado, uma posição é aberta, e depois o sinal de cabeça pequena é acionado, uma posição é fechada, semelhante a Martin.

Como os indicadores abaixo, por exemplo, a linha verde indica que o garfo é o meu sinal de longCondition, as quatro setas verdes indicam o sinal de lowLong, e as setas vermelhas indicam o sinal de lowShort, como é que o garfo verde pode ser cortado para abrir mais entradas consecutivas?

Related Recommendations
Comment
All comments (3)

    第一个问题,如果要忽略pyramding参数,可以把下单函数strategy.entry改成strategy.order,这个order函数就忽略加仓次数限制的。其它和entry函数一样。

    strategy(title = "获取开多信号,进入多头仓位") if longCondition and strategy.position_size >= 0 strategy.order("开多", strategy.long, when = lowLong, amount = amount, comment = "多头开仓") if strategy.position_size > 0 and lowShort strategy.close_all("平多", comment = "多头平仓")

    这样看看行不行。

    4 years ago

    其实也不是忽略pyramiding参数,之前的代码是没法多次同向下单,您给的我回测了下是可以实现多次同向下单了。那如果这样的话,如何限制同方向的最大下单数呢?

    4 years ago

    那就还用entry函数,设置pyramding参数。就可以控制了。

    4 years ago
  • 1
iPhone Download
Forums
PINE Language
© 2015 - ∞ INVENTOR PTE LTD (SG)