Taille de position toujours en euros

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #140686 quote
    Pepe_WPepe_W
    Participant
    New

    Bonjour,

    J’ai un code fonctionnel qui fait la chose suivante lorsque la longCondition est valide :

    • Place une Stop Loss au lowest close des 10 dernières bougies
    • Place un Take Profit à 1.5 fois la Stop Loss

    Ensuite, je m’attaque à la taille de la position.

    Voilà ce que je voudrais avoir :
    Je perds 10€ quand la Stop Loss est touchée et je gagne 15€ quand le Take Profit est touché

    Voilà ce que j’ai :
    Je perds 10 unités de la seconde paire Forex (exemple sur USD/CAD => je perds 10CAD) quand la Stop Loss est touchée et je gagne 15 unités de la seconde paire Forex (exemple sur EUR/YEN=> je gagne 15YEN) quand le Take Profit est touché.

    Voilà le code :

    // Définition des paramètres du code
    DEFPARAM CumulateOrders = False
    DEFPARAM NoCashUpdate = True
    
    // ============================================================================================================ //
    // ==============================================INDICATEURS=================================================== //
    // ============================================================================================================ //
    
    macdLigne = MACDline[12,26,9](close)
    signalLigne = MACDSignal[12,26,9](close)
    ema200 = ExponentialAverage[200](close)
    
    // ============================================================================================================ //
    // ===========================================MONEY MANGEMENT================================================== //
    // ============================================================================================================ //
    
    capital = 1000
    pourcentageRisk = 0.01
    currentEquity = capital + StrategyProfit
    risk = round(currentEquity*pourcentageRisk)
    
    // ============================================================================================================ //
    // =========================================LONG POSITIONS===================================================== //
    // ============================================================================================================ //
    
    // LONG CONDITIONS
    longCondition1 = (macdLigne CROSSES OVER signalLigne)
    longCondition2 = (macdLigne < 0) AND (signalLigne < 0)
    longCondition3 = (close > ema200)
    longCondition = longCondition1 AND longCondition2 AND longCondition3
    
    // SET LA STOPLOSS
    IF longCondition AND NOT ONMARKET THEN
      longSL = Lowest[10](close)
    ELSE
      longSL = longSL[1]
    ENDIF
    
    // SET LE TAKE PROFIT
    longEntryPrice = close
    longTailleSL = ABS(longEntryPrice - longSL)
    IF longCondition AND NOT ONMARKET THEN
      longTP = close + (1.5 * longTailleSL)
    ELSE
      longTP = longTP[1]
    ENDIF
    longTailleTP = ABS(longTP - longEntryPrice)
    
    // REGLER LA TAILLE DE LA POSITION
    longPositionSize = (currentEquity * pourcentageRisk) / longTailleSL
    
    // STRATEGY ENTRY/EXIT
    IF longCondition AND NOT ONMARKET then
      BUY longPositionSize CONTRACTS AT MARKET
      SET STOP LOSS longTailleSL
      SET TARGET PROFIT longTailleTP
    ENDIF

    Une idée sur comment faire ça ? Merci !

    #140694 quote
    NicolasNicolas
    Keymaster
    Legend

    ça n’est pas possible, les backtests sont toujours réalisés dans la monnaie de l’instrument, donc effectivement ici c’est le diviseur de la paire forex.

    Pepe_W thanked this post
    #140720 quote
    Pepe_WPepe_W
    Participant
    New

    Ok ça marche merci !

    #140903 quote
    Pepe_WPepe_W
    Participant
    New

    Salut !

    Je up ce sujet car après avoir navigué sur les forums je pense qu’il est possible d’avoir les pertes et les gains de respectivement 10€ et 15€ et ça, peut importe la paire forex.

    Je rappelle qu’avec mon position sizing actuel si je trade par exemple du USD/YEN et que le Take Profit est touché, je vais gagné 15YEN et non 15€, ce qui est dérengeant.

    Après avoir lu plusieurs posts, je pense qu’en changeant mon position sizing et en modifiant le BUY, je peux faire en sorte de perdre/gagner bien 10€/15€ à chaque trade.

    Voici le position sizing auquel je pense :

    //MM lot size
    REM Money Management
    Capital = 10000
    Risk = 0.01 // = 1%
    StopLoss = 100 // value of stoploss in pips/points
    REM Calculate contracts
    equity = Capital + StrategyProfit
    maxrisk = round(equity*Risk)
    PositionSize = abs(round((maxrisk/StopLoss)/PointValue)*pipsize)

    En sachant que ma StopLoss dans mon code vaut un prix et non une valeur en pips.

    Voilà le BUY auquel je pense :

    // Au lieu de faire ça : 
    BUY longPositionSize CONTRACTS AT MARKET
    
    // Peut être faire ça :
    BUY longPositionSize PERPOINT AT MARKET
    
    // Ou même ça (selon robertogozzi) :
    BUY longPositionSize PERPOINT at -close limit
    

    Ma question est donc : Est-il possible de m’émanciper de la valeur de la paire forex ? Si oui, comment fusionner ces morceaux de code avec le mien pour obtenir 10€/15€ par perte/gain et ça peut importe la paire forex ?

    Merci !

Viewing 4 posts - 1 through 4 (of 4 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

Taille de position toujours en euros


ProOrder : Trading Automatique & Backtests

New Reply
Author
author-avatar
Pepe_W @pepe_w Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by Pepe_WPepe_W
6 years, 3 months ago.

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 08/03/2020
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...