Trailing stop tightening

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #231655 quote
    winnie37
    Participant
    Veteran

    Bien sûr, voici la traduction en anglais de votre demande :

    Hello,
    I am using the code below with a trailing stop of 30 points. If there is a favorable movement of 30 pips, the trailing stop moves to 25 pips, then to 20 pips, 10 pips, and 5 pips if the movement continues. Unfortunately, in live trading, after gaining 30 pips, the trailing stop correctly adjusts to 25 pips, but after a few movements, it goes back to 30 pips. I don’t understand what’s not working. Do you have any suggestions for modifications? Thank you.

    Here is the code:

    ///Variables pour le stop suiveur

    monPrixEntree = tradeprice
    monStopSuiveur = 30 // Valeur initiale du stop suiveur en pips
    IF NOT OnMarket THEN
    // Enregistrer le prix d’entrée à l’ouverture d’une position
    monPrixEntree = close
    ENDIF

    IF OnMarket THEN
    // Calculer la différence de prix en pips
    gainEnPips = (close – monPrixEntree) / pipSize

    // Ajuster le stop suiveur en fonction des gains
    IF gainEnPips >= 100 THEN
    monStopSuiveur = 5
    ELSIF gainEnPips >= 70 THEN
    monStopSuiveur = 10
    ELSIF gainEnPips >= 50 THEN
    monStopSuiveur = 20
    ELSIF gainEnPips > 30 THEN
    monStopSuiveur = 25

    ENDIF
    ENDIF
    // Appliquer le stop suiveur ajusté
    IF OnMarket THEN
    SET STOP pTRAILING monStopSuiveur
    ENDIF

    #231661 quote
    JS
    Participant
    Senior

    Hi,

    Use Set Stop pLoss monStopSuiveur instead of Set Stop pTrailing monStopSuiveur

    For monPrixEntree“, use the TradePrice(1) instead of TradePrice

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

Trailing stop tightening


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
winnie37 @winnie37 Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by JS
1 year, 10 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/18/2024
Status: Active
Attachments: No files
Logo Logo
Loading...