pourquoi ça plante ? un paramètre de type entier positif est attendu

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #52453 quote
    Nightster
    Participant
    Junior

    Bonjour

    J’ai créer deux indicateurs ultra simples, le premier marche bien, pour le 2e j’ajoute une conditions supplémentaire toute simple et ça plante, pourquoi ? où est l’erreur

    ==================
    1-celui qui marche

    if barindex < 200 then
    p = Round(Barindex / 4)
    else
    p = 200
    endif
    
    return average[p](volume)

    ===========================================================
    2- celui qui ne marche pas, c’est le même auquel j’ai ajouté une condition toute simple

    if barindex < 200 then
    p = Round(Barindex / 4)
    else
    p = 200
    endif
    
    ind1 = average[p](volume)
    
    if close >= open then
    if volume > ind1 then
    flag =1
    elsif volume < ind1 then
    flag = 0
    endif
    endif
    return flag

    =================

    Merci pour votre aide

    #52454 quote
    Nightster
    Participant
    Junior

    Je voulais supprimer ou éditer ce post mais ça ne semble pas possible alors je précise
    c’est l’introduction de la variable ind1 qui fait planter l’indicateur, mais pourquoi ?

    puisque le même code n°1 écrit comme ça plante aussi

    if barindex < 200 then
    p = Round(Barindex / 4)
    else
    p = 200
    endif
    
    ind1 = average[p](volume)
    
    return  ind1
    #52471 quote
    Nicolas
    Keymaster
    Master

    Qu’est ce que tu veux dire par “ça plante.?”

    #52491 quote
    Nightster
    Participant
    Junior
    #52513 quote
    Nicolas
    Keymaster
    Master

    Le résultat de ton calcul de “p” doit être inférieur à 1 sans doute. Tu peux remédier à ce problème comme ceci:

    if barindex < 200 then
    p = Round(Barindex / 4)
    else
    p = 200
    endif
    
    ind1 = average[max(1,p)](volume)
    
    return  ind1

    Cela permettra à la moyenne mobile de n’utiliser que la valeur 1 période à minima, et jamais en dessous même si ton calcul de p trouve moins.

    #52525 quote
    Nightster
    Participant
    Junior

    Merci Nicolas, ça marche, c’est le principal

    Dommage que je ne comprends pas ce qui a provoqué l’erreur puisqu’elle se produit sur des titres qui ont plusieurs centaines de barres, enfin, je comprendrai peut peut être un jour !

    #52527 quote
    Nicolas
    Keymaster
    Master

    Le problème survient sans doute à la lecture du premier BARINDEX, il devrait être égal à 0 je pense, d’ou l’impossibilité d’arrondir à 1 ton calcul effectué à la ligne 2.

    #52543 quote
    Nightster
    Participant
    Junior

    Merci Nicolas:)

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.

pourquoi ça plante ? un paramètre de type entier positif est attendu


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
author-avatar
Nightster @nightster Participant
Summary

This topic contains 7 replies,
has 2 voices, and was last updated by Nightster
8 years, 3 months ago.

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 11/12/2017
Status: Active
Attachments: 1 files
Logo Logo
Loading...