Tabela de conteúdos

Envio de Ordens

Comandos de Envio de Ordens

Exemplos

//@version=4
strategy("Reversão Demo")
 
if bar_index < 100
    strategy.entry("compra", strategy.long, 4, when=strategy.position_size <= 0)
    strategy.entry("venda", strategy.short, 6, when=strategy.position_size > 0)
 
plot(strategy.equity)
//@version=4
strategy("Uma Saída Demo")
 
strategy.entry("compra", strategy.long, 4, when=strategy.position_size <= 0)
strategy.exit("saida", "compra",  2, profit=10, loss=10)
//@version=4
strategy("Saída Parcial Demo")
if bar_index < 100
    strategy.entry("compra", strategy.long, 4, when=strategy.position_size <= 0)
strategy.exit("bracket1", "compra", 2, profit=10, stop=10)
strategy.exit("bracket2", "compra", profit=20, stop=20)

IDs de Ordens

Envio vs Execução

//@version=4
strategy("Execução Próxima Barra Demo")
if bar_index < 100
    strategy.order("compra", strategy.long, when=strategy.position_size == 0)
    strategy.order("venda", strategy.short, when=strategy.position_size != 0)
//@version=4
strategy("Entrada no Preço Demo")
var c = 0
if year >= 2018
    c := c + 1
if c == 1
    strategy.order("C1", strategy.long, 2, stop = high + 35 * syminfo.mintick)
    strategy.order("C2", strategy.long, 2, stop = high + 5 * syminfo.mintick)
//@version=4
strategy("Entrada no Preço Demo v2")
var c = 0
if year > 2020
    c := c + 1
if c == 1
    strategy.order("C1", strategy.long, 2, stop = high + 35 * syminfo.mintick, oca_type = strategy.oca.cancel, oca_name = "COMPRAS")
    strategy.entry("C2", strategy.long, 2, stop = high + 5 * syminfo.mintick, oca_type = strategy.oca.cancel, oca_name = "COMPRAS")