Neo traderBot

Neo traderBot

Você sabia?

leafleafleafDocy banner shape 01Docy banner shape 02Man illustrationFlower illustration

Fórum aberto da Comunidade NeoTraderBot

Notifications
Clear all

Erro: Compilando ... Parser[5,1]: O código deve começar com begin Erro de Sintaxe

3 Posts
2 Usuários
0 Reactions
851 Visualizações
(@florisvaldo-rios)
Novo membro
Registrou: 10 meses atrás
Posts: 2
Iniciador do tópico  

// Robô de tendência com stop móvel, alvo e auto reverse
// Evita operar em mercado lateral usando ADX

// Definição de parâmetros de entrada
Inputs:
PeriodoMME(20),
PeriodoADX(14),
LimiteADX(20),
AlvoTicks(38),
StopTicks(20);

// Declaração de variáveis
Vars:
MediaMME(0.0),
ValorADX(0.0),
TendenciaAlta(false),
TendenciaBaixa(false);

begin
// Cálculo da MME e do ADX
MediaMME = XAverage(Close, PeriodoMME);
ValorADX = ADX(PeriodoADX);

// Verifica se mercado está com tendência
if ValorADX > LimiteADX then
begin
TendenciaAlta = Close > MediaMME;
TendenciaBaixa = Close < MediaMME;

// Se não estiver posicionado
if MarketPosition = 0 then
begin
if TendenciaAlta then
Buy ("Compra") next bar at market
else if TendenciaBaixa then
SellShort ("Venda") next bar at market;
end;
end;

// Se estiver comprado, aplica alvo, stop móvel e auto reverse
if MarketPosition = 1 then
begin
Sell ("StopMovel") next bar at EntryPrice - StopTicks * MinMove / PriceScale stop;
Sell ("Alvo") next bar at EntryPrice + AlvoTicks * MinMove / PriceScale limit;

// Auto reverse
if Close <= EntryPrice - StopTicks * MinMove / PriceScale then
SellShort ("AutoReverseV") next bar at market
else if Close >= EntryPrice + AlvoTicks * MinMove / PriceScale then
SellShort ("AutoReverseV") next bar at market;
end;

// Se estiver vendido, aplica alvo, stop móvel e auto reverse
if MarketPosition = -1 then
begin
BuyToCover ("StopMovel") next bar at EntryPrice + StopTicks * MinMove / PriceScale stop;
BuyToCover ("Alvo") next bar at EntryPrice - AlvoTicks * MinMove / PriceScale limit;

// Auto reverse
if Close >= EntryPrice + StopTicks * MinMove / PriceScale then
Buy ("AutoReverseC") next bar at market
else if Close <= EntryPrice - AlvoTicks * MinMove / PriceScale then
Buy ("AutoReverseC") next bar at market;
end;
end;


   
Citar
(@florisvaldo-rios)
Novo membro
Registrou: 10 meses atrás
Posts: 2
Iniciador do tópico  

Alguém pode ajudar? Grato


   
ReplyCitar
(@bruno1410)
Membro ativo
Registrou: 8 meses atrás
Posts: 5
 

input
PeriodoMME(20);
PeriodoADX(14);
LimiteADX(20);
AlvoTicks(38);
StopTicks(20);
tamanhoTick(1.0); // ajuste para WIN=1 ou WDO=0.5

var
mme, adxValor : float;
alvoCompra, stopCompra, alvoVenda, stopVenda : float;
podeComprar, podeVender : boolean;

begin
mme := MediaExp(PeriodoMME, Close);
adxValor := ADX(PeriodoADX, 0); // ✅ Corrigido: 2 parâmetros

podeComprar := false;
podeVender := false;

// Verifica tendência
if adxValor > LimiteADX then
begin
if (Close > mme) then
podeComprar := true
else if (Close < mme) then
podeVender := true;
end;

// Entrada comprada
if not HasPosition and podeComprar then
begin
BuyAtMarket;
alvoCompra := Close + AlvoTicks * tamanhoTick;
stopCompra := Close - StopTicks * tamanhoTick;
end;

// Entrada vendida
if not HasPosition and podeVender then
begin
SellShortAtMarket;
alvoVenda := Close - AlvoTicks * tamanhoTick;
stopVenda := Close + StopTicks * tamanhoTick;
end;

// Gestão posição comprada
if IsBought then
begin
if Close <= stopCompra then
begin
SellToCoverAtMarket;
SellShortAtMarket; // Auto reverse
end
else if Close >= alvoCompra then
begin
SellToCoverAtMarket;
SellShortAtMarket; // Auto reverse
end;
end;

// Gestão posição vendida
if IsSold then
begin
if Close >= stopVenda then
begin
BuyToCoverAtMarket;
BuyAtMarket; // Auto reverse
end
else if Close <= alvoVenda then
begin
BuyToCoverAtMarket;
BuyAtMarket; // Auto reverse
end;
end;
end;


   
ReplyCitar