Neo traderBot

Neo traderBot

Você sabia?

Confira os nossos eBooks, Snippets e Fóruns produzidos para cada plataforma!

leaf leftleaf right
Notifications
Clear all

Setup - Cruzamento de 2 médias

1 Posts
1 Usuários
0 Reactions
234 Visualizações
(@admin)
Membro Admin
Registrou: 2 anos atrás
Posts: 216
Iniciador do tópico  

Prezados membros,

 

       por oportunidade da série de vídeos "Passeando pela Lojinha", na qual realizamos a análise de desempenho das estratégias mais assinadas na Loja de Estratégias do Profit Chart, compartilho abaixo a implementação do setup clássico de Cruzamento de 2 médias (Double crossover) da Comunidade NeoTraderBot.

 

input
  pQtdePeriodosMediaRapida(5);
  pQtdePeriodosMediaLenta(20);

var
  bSinalCompra,bSinalVenda : boolean;
  fMediaRapida,fMediaLenta : float;

begin
  //Inicializa variáveis a cada processamento
  bSinalCompra := False;
  bSinalVenda := False;

  fMediaRapida := MediaExp(pQtdePeriodosMediaRapida, Close);
  fMediaLenta := MediaExp(pQtdePeriodosMediaLenta, Close);

  //Plota indicadores
  SetPlotColor(1,clRed);
  SetPlotWidth(1,2);
  SetPlotStyle(1,psDash);
  SetPlotColor(2,clWhite);
  SetPlotWidth(2,2);
  Plot(fMediaRapida);
  Plot2(fMediaLenta);

  //Se já houver média lenta, realiza cálculos de entrada/saida/liquidação
  if (fMediaLenta <> 0) then
  begin
    if  (fMediaRapida > fMediaLenta)
    and (fMediaRapida[1] <= fMediaLenta[1])  
    then bSinalCompra := True;

    if  (fMediaRapida < fMediaLenta)
    and (fMediaRapida[1] >= fMediaLenta[1]) 
    then bSinalVenda := True;

  end;

  if Not hasPosition and bSinalCompra then BuyAtMarket;
  if Not hasPosition and bSinalVenda then SellShortAtMarket;
  if (Position > 0) and bSinalVenda then ReversePosition;
  if (Position < 0) and bSinalCompra then ReversePosition;

end;

   
Citar