Utilisation de la fonction QUIT

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #77723 quote
    Meta Signals Pro
    Participant
    Veteran

    Bonjour à tous,

    Quelqu’un saurait-il pourquoi cette stratégie très simple ne s’arrête pas après que le stop loss ait été touché ?

    Que faudrait-il écrire ?

    Merci merci !

    Chris

     

     

    defparam cumulateorders = false
    
    n= round(1000/close)
    
    // trailing stop : Moyenne Mobile de Hull
    Period=50
    inner = 2*weightedaverage[ round( Period/2 ) ](close)-weightedaverage[Period](close)
    MMHULL=weightedaverage[ round( sqrt(Period) ) ]( inner )
    
    //
    
    VolBull = (high-open)*volume
    MMVolBull = average[23](VolBull)
    
    c1 = VolBull[1] > MMVolBull[1] or VolBull > MMVolBull
    
    c2 = close crosses over MMHULL 
    
    if c1 and c2 then
    buy n shares at Market
    //first stoploss:
    SL = MMHULL
    set stop loss SL
    dynamicSL = SL
    if close <= SL then
    quit
    endif
    endif
     
    //dynamicSL
    if longonmarket then
    if(MMHULL>dynamicSL) then
    dynamicSL=MMHULL
    endif
    sell at dynamicSL stop
    if close <= dynamicSL then
    quit
    endif
    endif
    
    graph dynamicSL
    Image1-1.png Image1-1.png
    #78814 quote
    Meta Signals Pro
    Participant
    Veteran

    Bonjour à tous,

    Je bloque sur qch qui peut servir à bon d’entre-nous : sortir d’une stratégie quand un stop loss est touché car sinon la stratégie continue !!!!


    @nicolas
    : help please !!!-)

    Mille mercis

     

    defparam cumulateorders = false
    
    //entry = 21.1 // cas ou l'on veut rentrer sur un prix précis
    n= round(1000/close)
    
    // trailing stop sur Moyenne Mobile de Hull
    Period=25
    inner = 2*weightedaverage[ round( Period/2 ) ](close)-weightedaverage[Period](close)
    MMHULL=weightedaverage[ round( sqrt(Period) ) ]( inner )
    
    
    //if high > entry and high < entry*1.02 then // pour éviter de se faire gaper
    buy n shares at market
    SL = MMHULL
    set stop loss SL
    dynamicSL = SL
    
    //endif
     
    
    
    //dynamicSL
    if longonmarket then
    if (MMHULL>dynamicSL) then
    dynamicSL=MMHULL
    endif
    sell at dynamicSL stop
    //if close [tradeindex(1)] <=  dynamicSL or close [tradeindex(1)] <= SL then // j'ai essayé cela mais ca ne marche pas ... ca ne marche pas non plus avec if low <= dynamicSL 
    //quit
    //endif
    endif
    #78833 quote
    Nicolas
    Keymaster
    Master

    On peut tester POSITIONPERF si on était au marché sur la barre précédente et qu’on ne l’est plus à présent:

    if onmarket[1] and not onmarket and positionperf(1)<0 then 
     quit 
    endif
    Meta Signals Pro thanked this post
    #78848 quote
    Meta Signals Pro
    Participant
    Veteran

    super ; mille mercis Nicolas 😉

    #78851 quote
    Meta Signals Pro
    Participant
    Veteran

    juste un point :

    => pourquoi positionperf serait négatif ?

     

    Je viens d’essayer sans postionperf et le test fonctionne et la stratégie est quittée ;

    Ca vous semble correct ?

    #78890 quote
    Nicolas
    Keymaster
    Master

    Positionperf(N) retourne la performance du trade N, donc si elle est négative c’est que l’ordre est en perte (stoploss).

    Meta Signals Pro thanked this post
    #78952 quote
    Meta Signals Pro
    Participant
    Veteran

    ok top donc c’est une condition supplémentaire mais pas nécessaire ;

    Merci pour l’astuce !

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

Utilisation de la fonction QUIT


ProOrder : Trading Automatique & Backtests

New Reply
Author
Summary

This topic contains 6 replies,
has 2 voices, and was last updated by Meta Signals Pro
7 years, 6 months ago.

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 08/07/2018
Status: Active
Attachments: 1 files
Logo Logo
Loading...