Ciclo For

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #159875 quote
    maximus78
    Participant
    Senior

    Buonasera a tutti!

    come posso trascrivere questo codice mediante un più semplice ciclo for?

    Prima analizzo i massimi delle ultime 5 candele di tutti i ROC% con periodo compreso tra 1 e 10, e tra questi voglio il massimo valore.

    Grazie in anticipo!

    Max

    a1=(highest[5](roc[1]))
    a2=(highest[5](roc[2]))
    a3=(highest[5](roc[3]))
    a4=(highest[5](roc[4]))
    a5=(highest[5](roc[5]))
    a6=(highest[5](roc[6]))
    a7=(highest[5](roc[7]))
    a8=(highest[5](roc[8]))
    a9=(highest[5](roc[9]))
    a10=(highest[5](roc[10]))
    
    X=max(a1,(max(a2,max(a3,max(a4,max(a5,max(a6,max(a7,max(a8,max(a9,a10))))))))))
    
    return X
    #159876 quote
    robertogozzi
    Moderator
    Master

    Eccolo:

    x = 0
    For i = 1 to 10
       x = max(x,(highest[5](roc[i])))
    Next
    return x
    #159880 quote
    maximus78
    Participant
    Senior

    Perfetto, grazie mille Roberto!

    #185627 quote
    maximus78
    Participant
    Senior

    Ciao Roberto, scusa mi riallaccio al codice che avevi scritto sopra…volevo chiederti, come faccio ad implementare il codice nel seguente modo sempre trovando il valore maggiore dei roc, ma di periodi precedenti a scalare come nel seguente modo:

    a1=highest[5](roc[1])[9]
    a2=highest[5](roc[2])[8]
    a3=highest[5](roc[3])[7]
    a4=highest[5](roc[4])[6]
    a5=highest[5](roc[5])[5]
    a6=highest[5](roc[6])[4]
    a7=highest[5](roc[7])[3]
    a8=highest[5](roc[8])[2]
    a9=highest[5](roc[9])[1]
    a10=highest[5](roc[10])
    Grazie mille
    Max
    #185629 quote
    robertogozzi
    Moderator
    Master

    Eccolo (non l’ho provato):

    x = 0
    For i = 1 to 10
       j = 10 - i
       x = max(x,(highest[5](roc[i]))[j])
    Next
    return x
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Ciclo For


ProBuilder: Indicatori & Strumenti Personalizzati

New Reply
Author
author-avatar
maximus78 @maximus78 Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by robertogozzi
4 years, 2 months ago.

Topic Details
Forum: ProBuilder: Indicatori & Strumenti Personalizzati
Language: Italian
Started: 01/29/2021
Status: Active
Attachments: No files
Logo Logo
Loading...