Utilisation Barindex pour une condition de quantité de bougies

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #110646 quote
    MontiL
    Participant
    Junior

    Bonjour à tous,

    Je souhaite vendre après que mon prix ait cassé une MM à la baisse (condition 1) et que ce prix soit resté sous la MM les 30 bougies suivantes (condition 2).

    Mon code me semble correct mais les ventes sur le graphique sont fausse. Quelqu’un maîtrise-t-il le barindex ?

    Merci d’avance !

    Livien

    DEFPARAM CumulateOrders = FALSE //une seule position
    
    Indicator1= Average[200](Close)
    MyRsi=RSI[14](Close)
    
    c1= Close CROSSES UNDER Indicator1
    c2= Close < indicator1
    
    // Conditions pour ouvrir une position acheteuse
    IF NOT LongOnMarket AND MyRsi<30 THEN
    Buy 1 CONTRACTS AT MARKET
    ENDIF
    
    // conditions pour ouvrir une position vendeuse
    IF c1 THEN
    bar1 = barindex
    IF c2 and barindex-bar1<30 THEN
    SELL 1 contracts at market
    ENDIF
    endif
    #110655 quote
    robertogozzi
    Moderator
    Master

    Voilà:

    DEFPARAM CumulateOrders = FALSE
    Indicator1= Average[200](Close)
    MyRsi=RSI[14](Close)
    c1= Close CROSSES UNDER Indicator1
    c2= Close < indicator1
    IF NOT LongOnMarket AND MyRsi<30 THEN
       Buy 1 CONTRACTS AT MARKET 
    ENDIF
    IF c1[31] and summation[30](c2)=30 THEN
       SELL 1 contracts at market 
    ENDIF
    #110661 quote
    fifi743
    Participant
    Master

    bonjour montil,

    par exemple

    barindex-tradeindex  donne le nombre de bar quand tu es en position

     

    cordialement

    #110669 quote
    robertogozzi
    Moderator
    Master

    Oui, mais quand il y a un moyen plus facile, pourquoi ne pas l'utiliser? Il est préférable d’utiliser cette expression pour quitter après un nombre de mesures donné:

    If barindex-tradeindex > 20 then
       Sell at market
    endif
    #110676 quote
    robertogozzi
    Moderator
    Master

    A la ligne 9 ci-dessus, 31 doit être remplacé par 30.

    Si vous souhaitez utiliser BarIndex, voici le code:

    DEFPARAM CumulateOrders = FALSE
    Indicator1= Average[200](Close)
    MyRsi=RSI[14](Close)
    c1= Close CROSSES UNDER Indicator1
    c2= Close < indicator1
    IF NOT LongOnMarket AND MyRsi<30 THEN
       Buy 1 CONTRACTS AT MARKET 
    ENDIF
    IF c1[30] AND LongOnMarket AND (BarIndex - TradeIndex) > 30 THEN
       Flag = 1
       FOR i = 0 TO 29
          IF c2[i] = 0 THEN
             Flag = 0
             Break
          ENDIF
       NEXT
       IF Flag = 1 THEN
          SELL 1 Contract at market 
       ENDIF
    ENDIF
    #110701 quote
    MontiL
    Participant
    Junior

    Merci beaucoup pour la rapidité de vos réponses ! Cela fonctionne bien maintenant.

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

Utilisation Barindex pour une condition de quantité de bougies


ProOrder : Trading Automatique & Backtests

New Reply
Author
author-avatar
MontiL @montil Participant
Summary

This topic contains 5 replies,
has 3 voices, and was last updated by MontiL
6 years, 4 months ago.

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 10/20/2019
Status: Active
Attachments: No files
Logo Logo
Loading...