Código não salva devido a erros.

Algoritmo

07/03/2021

Caros colegas alguém poderia me dar uma luz nesse pequeno código.


begin
if (BuyPosition=0) and (SellPosition=0)then
begin
if(IFR(14,0)<16) then

begin
if(BuyAtMarket(1)

end;

end;
if (BuyPosition=1)then
begin
if(IFR((14,0)>(80) then
begin
SellShortAtMarket(1);
end;
end:
end;

Fica aparecendo esses erros quando vou salvar.
Parser[4,11]: No final da chamada da função deve vir " ) "
Parser[9,1]: Faltou um " ) "
Parser[14,11]: Faltou um " ) "
Erro de Sintaxe
Geidione

Geidione

Curtidas 0

Respostas

Keniel Cenzi

Keniel Cenzi

07/03/2021

Olá Geidione,


"if(BuyAtMarket(1)" - Aqui acredito que você só precise de "BuyAtMarket(1)" sem o if, caso for usar o if então ficaria apenas "BuyAtMarket(1);"

"if(IFR((14,0)>(80) then" - Aqui você possui um problema com "(", no caso ficou faltando fechar um parêntese.

Sugestão para dixar o código mais clean e otimizado.

begin
if (BuyPosition=0) and (SellPosition=0) and (IFR(14,0) < 16) then
BuyAtMarket(1)
else if (BuyPosition = 1) and (IFR(14,0) > 80) then
SellShortAtMarket(1);
end;

Atenciosamente.



GOSTEI 0
Keniel Cenzi

Keniel Cenzi

07/03/2021

Olá Geidione, Corrigindo a resposta anterior.


"if(BuyAtMarket(1)" - Aqui acredito que você só precise de "BuyAtMarket(1)" sem o if, então ficaria apenas "BuyAtMarket(1);" se você for usar o if precisar de alguma condição seguida de "then".

"if(IFR((14,0)>(80) then" - Aqui você possui um problema com "(", no caso ficou faltando fechar um parêntese.

Sugestão para dixar o código mais clean e otimizado.

begin
if (BuyPosition=0) and (SellPosition=0) and (IFR(14,0) < 16) then
BuyAtMarket(1)
else if (BuyPosition = 1) and (IFR(14,0) > 80) then
SellShortAtMarket(1);
end;

Atenciosamente.



GOSTEI 0
Emerson Nascimento

Emerson Nascimento

07/03/2021

se os comandos estiverem corretos:
begin
	if (BuyPosition = 0) and (SellPosition = 0) then
	begin
		if (IFR(14,0) < 16) then
		begin
			if(BuyAtMarket(1)   <-- precisa terminar o código

			end;

		end;

		if (BuyPosition = 1) then  <-- jamais entrará nesta condição porque a condição principal impede
		begin
			if(IFR((14,0) > (80) then   <-- falta um parêntesis aqui. foram abertos 4, e fechados 3
			begin
				SellShortAtMarket(1);
			end;
		end:
	end;

   <-- falta em 'end'

ou talvez deva ser assim:
begin
	if (BuyPosition = 0) and (SellPosition = 0) then
	begin
		if (IFR(14,0) < 16) then
		begin
			BuyAtMarket(1)   <-- retirado o IF
		end;
	end;

	if (BuyPosition = 1) then
	begin
		if (IFR((14,0) > (80) then   <-- falta um parêntesis aqui. foram abertos 4, e fechados 3
		begin
			SellShortAtMarket(1);
		end;
	end:
end;

se a opção acima estiver correta, tem muitos 'ifs' e 'begin..end':
begin
	if (BuyPosition = 0) then
	begin
		if (SellPosition = 0) and (IFR(14,0) < 16) then
			BuyAtMarket(1);
	end
	else
		if (IFR(14,0) > 80) then
			SellShortAtMarket(1);
end;

GOSTEI 0
POSTAR