raccourcir un code avec differentes variables

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #162957 quote
    magiclil
    Participant
    Average

    Bonjour Nicolas,

    Voici une partie de mon code que j’aimerais raccourcir

    and close[3] < Pivot and close[4] < Pivot and close[5] < Pivot and close[6] < Pivot and close[7] < Pivot and close[8] < 13947 and close[9] < Pivot and close[10] < Pivot

    j’ai essayé plusieurs choses comme

    and (close[3] and close[4] and close[5] and close[6] and close[7] and close[8] and close[9] and close[10] < Pivot)

    mais ca ne ressors pas les memes résultats qu’avec le code précedent.

    Une idée pour faire au plus court ? Merci

    #162961 quote
    Nicolas
    Keymaster
    Master

    Ce que tu as essayé de faire ne peut fonctionner. Car tu testes un prix comme une condition booléenne (vrai ou faux), donc forcément un prix est supérieur à zéro et il sera forcément VRAI.

    Dans le cas présent il faudrait faire une boucle :

    test = 1 //on considère pour le moment que ta condition est VRAI
    
    for i = 3 to 8 do 
     if close[i]>pivot then //si dans les bougies 3 à 8, le prix est dessus pivot 
      test = 0 //alors la condition est FAUX
      break //et on sort du test puisqu'il n'est plus obligatoire de continuer
     endif
    next
    
    // maintenant tu peux tester si test > 0 ou pas !
    magiclil thanked this post
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

raccourcir un code avec differentes variables


ProOrder : Trading Automatique & Backtests

New Reply
Author
author-avatar
magiclil @magiclil Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by Nicolas
5 years ago.

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 03/02/2021
Status: Active
Attachments: No files
Logo Logo
Loading...