OFFSET NEGATIF

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #71211 quote
    Yvan63
    Participant
    Senior

    Bonsoir,

    J’ai bien lu les différents posts au sujet des arrêts du système de TRADING dûs au OFFSETS négatifs.
    Mais je ne sais comment débugger le programme, sur quel genre de calcul ou fonction cela s’applique-t-il ?
    Il est dommage que lors du plantage il n’est pas indiqué où s’est produite l’erreur.
    Voici mon code, si vous avez une idée d’où un zéro peut sortir !!

    Merci

    // Définition des paramètres du code
    DEFPARAM CumulateOrders = False // Cumul des positions désactivé
    //Annule tous les ordres en attente et ferme toutes les positions à 0:00, puis empêche toute création d'ordre avant l'heure "FLATBEFORE".
    //DEFPARAM FLATBEFORE = 070000
    ////// Annule tous les ordres en attente et ferme toutes les positions à l'heure "FLATAFTER"
    //DEFPARAM FLATAFTER = 210000
    
    Taille1 = 1
    Taille2 = 1 
    
    // Empêche le système de placer de nouveaux ordres sur les jours de la semaine spécifiés
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
    
    myMoyennedeHull = CALL "Moyenne de Hull"[9]
    
    Long1 = Close < average [23,0](close)
    Long2 = (close - open) > Taille1
    Long3 = close > myMoyennedeHull
    Long4 = (close[1] - open[1]) > Taille2
    
    IF Long1 and Long2 and Long3 and Long4 AND not daysForbiddenEntry and not ONMARKET THEN
    BUY 1 CONTRACT AT MARKET
    TSL = 1 // Use TSL?
    SL = 8 // Initial SL
    EndIf
    
    TrailingDistance = 3 // Distance from close to TSL
    TrailingStep = 2 // Pips locked at start of TSL
     
    IF TSL = 1 THEN
     
    //reset the stoploss value
    IF NOT ONMARKET THEN
    newSL = 0
    CAND = 0
    ENDIF
     
    //manage long positions
    IF LONGONMARKET THEN
    //first move (breakeven)
    IF newSL = 0 AND CLOSE - TRADEPRICE(1) >= TrailingDistance*PipSize THEN
    newSL = TRADEPRICE(1) + TrailingStep*PipSize
    ENDIF
    //next moves
    CAND = BarIndex - TradeIndex
    IF newSL > 0 AND CLOSE[1] >= HIGHEST[CAND](CLOSE) THEN
    newSL = CLOSE[1] - TrailingDistance*PipSize
    ENDIF
    ENDIF
     
    //manage short positions
    IF SHORTONMARKET THEN
    //first move (breakeven)
    IF newSL = 0 AND TRADEPRICE(1) - CLOSE[1] >= TrailingDistance*PipSize THEN
    newSL = TRADEPRICE(1) - TrailingStep*PipSize
    ENDIF
    //next moves
    CAND = BarIndex - TradeIndex
    IF newSL > 0 AND CLOSE[1] <= LOWEST[CAND](CLOSE) THEN
    newSL = CLOSE[1] + TrailingDistance*PipSize
    ENDIF
    ENDIF
     
    //stop order to exit the positions
    IF newSL > 0 THEN
    SELL AT newSL STOP
    EXITSHORT AT newSL STOP
    ENDIF
    
    SET STOP pLOSS SL // Protection
    
    ENDIF
    
    #71224 quote
    Nicolas
    Keymaster
    Master

    [CAND] vaut 0 ou est négatif.

    Cela est dut à ton calcul fait aux lignes 45 et 58, sans doute lorsque l’ordre courant est très récent. Pour éviter un offset négatif, on peut assurer que la variable CAND vaut à minima 1 comme ceci:

    CAND = max(1,BarIndex - TradeIndex)

    CAND vaudra alors toujours la valeur la plus élevée entre 1 et “barindex-tradeindex”.

    Yvan63 thanked this post
    #71250 quote
    Yvan63
    Participant
    Senior

    Merci pour l’info.

    Le seul moyen que l’on dispose pour “logger” des opérations / valeurs est la fonction GRAPH ?

    #71251 quote
    Nicolas
    Keymaster
    Master

    Sous ProBacktest, oui en effet.

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

OFFSET NEGATIF


ProOrder : Trading Automatique & Backtests

New Reply
Author
author-avatar
Yvan63 @yvan63 Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by Nicolas
7 years, 9 months ago.

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 05/23/2018
Status: Active
Attachments: No files
Logo Logo
Loading...