Inclure BBANDS stop dans programme pro order

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #30505 quote
    VictorioVictorio
    Participant
    Senior

    Bonjour.

    Je souhaite inclure un indicateur de la librairie dans un programme pour pro-order

    BBands stop

    J’ai dans un premier appelé l’indicateur et crée 2 conditions “BBL” et “BBS”

    indicateur=CALL"BBAND STOP"(CLOSE)
    BBL=TYPICALPRICE<indicateur
    BBS=TYPICALPRICE>indicateur

    J’obtiens le résultat désiré, tout va bien. J’ai voulu ensuite intégré le code afin de procéder à une optimisation, toujours avec les 2 conditions BBL et BBS:

    Length=20      // Bollinger Bands Period
    Deviation=2    // Deviation
    MoneyRisk=1.00 // Offset Factor
    // --- end of settings
    
    avg=average[Length]
    dev=std[Length]*Deviation
    smax = avg+dev
    smin = avg-dev
    if close>smax[1] then
    trend=1
    endif
    if close<smin[1] then
    trend=-1
    endif
    if trend>0 and smin<smin[1] then
    smin=smin[1]
    endif
    if trend<0 and smax>smax[1] then
    smax=smax[1]
    endif
    bsmax=smax+0.5*(MoneyRisk-1)*(smax-smin)
    bsmin=smin-0.5*(MoneyRisk-1)*(smax-smin)
    if(trend>0 and bsmin<bsmin[1]) then
    bsmin=bsmin[1]
    endif
    if(trend<0 and bsmax>bsmax[1]) then
    bsmax=bsmax[1]
    endif
    if trend>0 then
    TrendLine=bsmin
    r=127
    g=255
    endif
    if trend<0 then
    TrendLine=bsmax
    r=255
    g=165
    endif
    BBL=TYPICALPRICE<TRENDLINE
    BBS=TYPICALPRICE>TRENDLINE

    Je n’obtiens pas du tout le même résultat ! rien ne va plus !

    J’ai beau chercher, je ne trouve pas à côté de quoi je suis passé.

    Merci pour votre coup d’oeil averti et votre aide.

    #30506 quote
    NicolasNicolas
    Keymaster
    Legend

    J’ai pourtant bien les bonnes infos avec ce code: (j’ai graphé les variables pour vérification, voir image jointe).

    Defparam Cumulateorders=false
    
    Length=20      // Bollinger Bands Period
    Deviation=2    // Deviation
    MoneyRisk=1.00 // Offset Factor
    // --- end of settings
    
    avg=average[Length]
    dev=std[Length]*Deviation
    smax = avg+dev
    smin = avg-dev
    if close>smax[1] then
    trend=1
    endif
    if close<smin[1] then
    trend=-1
    endif
    if trend>0 and smin<smin[1] then
    smin=smin[1]
    endif
    if trend<0 and smax>smax[1] then
    smax=smax[1]
    endif
    bsmax=smax+0.5*(MoneyRisk-1)*(smax-smin)
    bsmin=smin-0.5*(MoneyRisk-1)*(smax-smin)
    if(trend>0 and bsmin<bsmin[1]) then
    bsmin=bsmin[1]
    endif
    if(trend<0 and bsmax>bsmax[1]) then
    bsmax=bsmax[1]
    endif
    if trend>0 then
    TrendLine=bsmin
    endif
    if trend<0 then
    TrendLine=bsmax
    endif
    BBL=TYPICALPRICE<TRENDLINE
    BBS=TYPICALPRICE>TRENDLINE
    
    graph bbl coloured(200,0,0) as "bbl" 
    graph bbs coloured(0,200,0) as "bbs"
    
    if 0>1 then 
    buy 1 share at market
    endif
    bbands-stop-trading-automatique.png bbands-stop-trading-automatique.png
    #30518 quote
    VictorioVictorio
    Participant
    Senior

    Oui, tout me semble  correct. ; et bien que parfois distrait, j’ai bien tout vérifier me semble-t-il. Les différences sont notables (cf attachement) et si les positions courtes ont des résultats similaires, les longs sont en surnombre dans la version avec code intégré . Mais je ne trouve toujours pas le bug…

    Capture-d’écran-2017-03-31-à-14.51.19.png Capture-d’écran-2017-03-31-à-14.51.19.png
    #30524 quote
    VictorioVictorio
    Participant
    Senior

    On ne se refait pas….J’avais bien sur fait une erreur dans une autre partie du code.

    Désolé.

    #30530 quote
    NicolasNicolas
    Keymaster
    Legend

    Un partage de la stratégie finale peut être ? qui intéressera surement d’autres personnes et même si elle ne performe pas forcément .. 🙂

    #30543 quote
    VictorioVictorio
    Participant
    Senior

    Bien sur, rien de plus simple, et rien d’exceptionnel.

    Pro-order ne rentre en position call que si le prix est < à la BBANDS STOP et inversement short que si >

    D’autre part, si en position call, en PV latente, et que le prix croise la BBANDSSTOP à la baisse, il sort, et inversement pour les shorts.

    OUT=CALL"BBAND STOP"(CLOSE)
    OUTL=TYPICALPRICE CROSSES UNDER OUT AND POSITIONPERF>0
    OUTS=TYPICALPRICE CROSSES OVER OUT AND POSITIONPERF>0
    
    IF LONGONMARKET AND OUTL THEN
    SELL AT MARKET
    ENDIF
    IF SHORTONMARKET AND OUTS THEN
    EXITSHORT AT MARKET
    ENDIF
    Nicolas thanked this post
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Inclure BBANDS stop dans programme pro order


ProOrder : Trading Automatique & Backtests

New Reply
Author
author-avatar
Victorio @victorio Participant
Summary

This topic contains 5 replies,
has 2 voices, and was last updated by VictorioVictorio
9 years, 6 months ago.

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 03/31/2017
Status: Active
Attachments: 2 files
ProRealCode ProRealCode
Loading...