Ordre passé alors que la condition n'est pas remplie

Viewing 4 posts - 16 through 19 (of 19 total)
  • Author
    Posts
  • #117368 quote
    Nicolas
    Keymaster
    Master

    Il faut penser à GRAPHER ses variables, c’est la seule façon de débugger et de pouvoir comprendre certains comportements ne nous saute pas aux yeux à prime abord. Il n’y a pas de magie, moi et Roberto c’est ce que l’on fait ! 😉

    #117420 quote
    robertogozzi
    Moderator
    Master

    Comme vous pouvez le voir sur l’image ci-jointe, cela semble bien fonctionner.
    Voici la stratégie telle que je l’ai codée à partir de zéro:

    DEFPARAM CumulateOrders = false
    MyRsi = Rsi[14](close)
    IF MyRsi CROSSES OVER  50 THEN
       HH   = high
       LL   = low
    ENDIF
    IF MyRsi CROSSES UNDER 50 THEN
       PrevHH = HH
       PrevLL = LL
    HH     = 0
    LL     = 0
    ENDIF
    IF HH > 0 THEN
       HH   = max(HH,high)
       LL   = min(LL,low)
    ENDIF
    IF OnMarket OR (StrategyProfit <> StrategyProfit[1]) THEN
       PrevHH = 0
       PrevLL = 0
       HH     = 0
       LL     = 0
    ENDIF
    IF Not OnMarket AND (StrategyProfit = StrategyProfit[1]) AND (PrevHH > 0 AND PrevLL > 0) THEN
       BUY       1 CONTRACT AT PrevHH Stop
       SELLSHORT 1 CONTRACT AT PrevLL Stop
    ENDIF
    SET TARGET pPROFIT 100
    SET STOP   pLOSS   50

    J’attache également deux indicateurs, un à ajouter SUR le tableau des prix et l’autre à ajouter EN DESSOUS du tableau des prix.
    Les deux mettent en évidence lorsque RSI> 50:

    ONCE Bar1 = 0
    ONCE Bar2 = 0
    MyRsi = Rsi[14](close)
    IF MyRsi CROSSES OVER  50 THEN
       Bar1 = barindex
       HH   = high
       LL   = low
    ENDIF
    IF MyRsi CROSSES UNDER 50 THEN
       Bar2 = barindex - 1
       PrevHH   = HH
       PrevLL   = LL
       PrevBAR1 = Bar1
       PrevBAR2 = Bar2
       HH       = 0
       LL       = 0
       Bar1     = 0
       Bar2     = 0
    ENDIF
    IF HH > 0 THEN
       HH   = max(HH,high)
       LL   = min(LL,low)
    ENDIF
    IF HH = 0 THEN
       DRAWRECTANGLE(PrevBar1,PrevHH,PrevBar2,PrevLL)
    ENDIF
    RETURN
    ONCE t = 0
    MyRsi = Rsi[14](close)
    IF MyRsi CROSSES OVER  50 THEN
       t = 255
    ENDIF
    IF MyRsi CROSSES UNDER 50 THEN
       t = 0
    ENDIF
    IF HH > 0 THEN
       HH   = max(HH,high)
       LL   = min(LL,low)
    ENDIF
    BACKGROUNDCOLOR(211,211,211,t)
    RETURN MyRsi AS "Rsi",70 AS "70",50 AS "50",30 AS "30"
    Nicolas and Stef1618 thanked this post
    x-8.jpg x-8.jpg
    #117507 quote
    Stef1618
    Participant
    Average

    Merci beaucoup, effectivement l’approche est totalement différente et beaucoup plus carrée. Je ne connaissais pas les instructions MAX et MIN, dans ce contexte c’est bien plus adapté.

    Je pensais justement aussi le faire sous forme d’indicateur, donc c’est parfait.

    Je travaille souvent avec des breakout donc je pourrais également adapter cette structure de code dans d’autres conditions.

    Merci encore pour le temps passé et le résultat obtenu!

    #117509 quote
    Stef1618
    Participant
    Average

    Il faut penser à GRAPHER ses variables, c’est la seule façon de débugger et de pouvoir comprendre certains comportements ne nous saute pas aux yeux à prime abord. Il n’y a pas de magie, moi et Roberto c’est ce que l’on fait ! 😉

    Oui c’est vrai, je ne pense pas à grapher. D’habitude je lance directement en réel pour observer le comportement et j’analyse à partir de ça.

Viewing 4 posts - 16 through 19 (of 19 total)
  • You must be logged in to reply to this topic.

Ordre passé alors que la condition n'est pas remplie


ProOrder : Trading Automatique & Backtests

New Reply
Author
author-avatar
Stef1618 @stef1618 Participant
Summary

This topic contains 18 replies,
has 3 voices, and was last updated by Stef1618
6 years, 1 month ago.

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 01/17/2020
Status: Active
Attachments: 5 files
Logo Logo
Loading...