Neo traderBot

Neo traderBot

Você sabia?

A NeoTraderBot é a primeira comunidade aberta no Brasil com foco em compartilhar informações sobre automatização de estratégias

leaf leftleaf right
Notifications
Clear all

[Solucionado] Rompimento da Primeira Barra.

2 Posts
2 Usuários
0 Reactions
162 Visualizações
(@fernandomc)
Membro ativo
Registrou: 2 anos atrás
Posts: 6
Iniciador do tópico  

Fala Rapaziada, estou com esse código de rompimento da primeira barra do dia.

esta iniciando a operação certa, mais a saída de (stopLoss), esta dando erro, após iniciar a operação só fica o (stopgain) o (stopLoss) desaparece, algum colega pode dar uma olhada por favor.

var
  spred, fh, fsg, fsl, points,stopGain,stopLoss : float;

  Inicio
Se (Time >= HoraInicio)e(Time <= HorarioFim) entao
  
  
  begin
  fsg := 3;
  fsl := 1;
  if (IsBMF) then
    begin              
      spred := 0.06;
      fh := 1000;
    end
  else 
    begin
      spred := 0.06;
      fh := 1100;
    end;
           
  if (BuyPosition = 0) and (SellPosition = 0) and 
  (time < fh+BarDuration) 
  then
    begin
      PaintBar(clPurple);
      BuyStop((High + spred),(High + spred));
      SellShortStop((Low - spred),(Low - spred));
      points := High - Low;
      stopGain := points * fsg;
      stopLoss := points * fsl;
    end;

  if (BuyPosition = 1) then
    begin
      SellToCoverStop(BuyPrice + stopGain,BuyPrice + stopGain);
      SellToCoverStop(BuyPrice - stopLoss,BuyPrice - stopLoss);
      
    end
  else if (SellPosition = 1) then
    begin
      BuyToCoverStop(SellPrice - stopGain,SellPrice - stopGain);
      BuyToCoverStop(SellPrice + stopLoss,SellPrice + stopLoss);
      
    end; 


end;
Fim;





   
Citar
(@admin)
Membro Admin
Registrou: 2 anos atrás
Posts: 216
 

Boa noite @fernandomc!

 

        As ordens de alvo devem sempre ser colocadas como ordens limitadas. Assim o seu código precisa ser ajustado como segue abaixo:

 

  if (BuyPosition = 1) then
    begin
      SellToCoverLimit(BuyPrice + stopGain);
      SellToCoverStop(BuyPrice - stopLoss,BuyPrice - stopLoss);
      
    end
  else if (SellPosition = 1) then
    begin
      BuyToCoverLimit(SellPrice - stopGain);
      BuyToCoverStop(SellPrice + stopLoss,SellPrice + stopLoss);
      
    end; 

 

Abs!


   
ReplyCitar