Problème de code de Martingale

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #8243 quote
    Doctrading
    Participant
    Master

    Bonjour,

    J’essaie de tester un code de martingale classique (doublement des lots à chaque perte).
    Avec une mise constante (n = 1), le code fonctionne (même si la stratégie est mauvaise, c’est juste un test).

    Mais mon code de martingale ne fonctionne pas, après seulement 18 trades (dont certains gagnants) il m’envoie rapidement plus de 4000 lots !

    Où y voyez-vous une erreur ?
    Merci par avance.

     

    // CODE HARAMI MARTINGALE
    
    Defparam cumulateorders = false
    
    // MARGTINGALE
    Once n = 1
    
    IF PositionPerf(1) <0 THEN
    n = n*2
    ELSIF PositionPerf(1)>=0THEN
    n =1
    ENDIF
    
    
    // Déinition du HARAMI (ou INSIDE BAR)
    c1= high[0] < high[1]
    c2= low[0] > low[1]
    harami = c1 and c2
    
    IF harami THEN
    buy n shares at high stop
    sellshort n shares at low stop
    amplitude = high - low
    ENDIF
    
    
    set stop loss amplitude
    set target profit amplitude
    
    #8244 quote
    Nicolas
    Keymaster
    Master

    Parce que tu refais le calcul à chaque bar et non pas au moment ou tu dois passer l’ordre, ta variable n s’incrémente sans cesse si le dernier trade était perdant.

    Voici la correction:

    
    Defparam cumulateorders = false
    
    // MARGTINGALE
    Once n = 1
    
    // Déinition du HARAMI (ou INSIDE BAR)
    c1= high[0] < high[1]
    c2= low[0] > low[1]
    harami = c1 and c2
    
    IF harami THEN
    IF PositionPerf(1) <0 THEN
    n = n*2
    ELSIF PositionPerf(1)>=0THEN
    n =1
    ENDIF
    buy n shares at high stop
    sellshort n shares at low stop
    amplitude = high - low
    ENDIF
    
    set stop loss amplitude
    set target profit amplitude
    
    GRAPH n

    Attention ça pique.

    #8255 quote
    Doctrading
    Participant
    Master

    Grand merci à toi.
    Effectivement c’est jouer avec le feu, mais c’est bien rigolo.

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

Problème de code de Martingale


Support ProOrder

New Reply
Author
author-avatar
Doctrading @doctrading Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by Doctrading
9 years, 8 months ago.

Topic Details
Forum: Support ProOrder
Language: French
Started: 05/27/2016
Status: Active
Attachments: No files
Logo Logo
Loading...