Bom dia John, tudo bem? O código abaixo está praticamente terminado, para que ele termine, a estrutura : if (High[i] >= High[h - Strength]), precisa de solução o Profit alega:
"Não é possível utilizar índice negativo para acessar uma série de dados (-1)" ... Como tentar fazer uma "falcatrua" para burlar isso? segue o código completo:
input Strength (5);Length (5);
vari: Integer;
h: integer;xswingHigh: float;foundSwingHigh: Boolean;
begin
// obtém o índice do maior valor da série High dentro do período Lengthfor i := 0 to Length - 1 dobeginh:= Round(highestBar(high,Strength));if High[i] >= h thenh := i;end;
i := 0;while (i < Length) and not foundSwingHigh dobegin// verifica se o valor atual é um swing highif (High[i] >= High[h - Strength]) and (High[i] > High[i + 1]) and (High[i] > High[i - 1]) thenbegin// encontrou um swing highfoundSwingHigh := true;xswingHigh := High[i];end;
i := i + 1;end;
plot(xswingHigh);
end;
Boa tarde @pedro-henrique-t-de-carvalho!
Cara, você precisaria primeiro explicar exatamente o que deseja fazer com o seu código, para que possamos ajudar no problema.
Sem entrar em detalhes sobre o objetivo do seu código, o Profit está te dizendo que você não pode ter indexador negativo. Isso está acontecendo nessa parte do código: High[h - Strength] e também vai ocorrer nessa parte: High[i - 1], quando i = 1.
Posta aí qual é a sua ideia com esse código que facilita!
Abs!
@admin John, Justamente um 'swinghigh' !
Percebi o que o Profit esta me dizendo, é justamente isso que quero burlar, nem que o indice retorne a zero. Será que é possível?
Abraços,