Stop loss at breakeven using live market price in ProOrder

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #258450 quote
    tradermaker
    Participant
    New

    Hi,


    I am trying to amend my stop once my trade is say 50 pips onside. However, I can only seem to do it using the close candle. Is there anyway to do this using the current market price? I.e. as soon as my trade is 50 pips onside the stop is moved to breakeven. below is the relevant part of the code:


    // Management of open position
    IF LONGONMARKET THEN
    // Move stop to breakeven
    IF ((close - TradePrice) >= triggerDistance*pointsize) and MoveToBreakEven=0 THEN
    MoveToBreakEven=1
    set stop breakeven
    endif
    endif
    IF shortONMARKET THEN
    // Move stop to breakeven
    IF ((TradePrice - close) >= triggerDistance*pointsize) and MoveToBreakEven=0 THEN
    MoveToBreakEven=1
    set stop breakeven
    endif
    endif
    
    #258452 quote
    AI-vy
    Moderator
    Junior

    Short answer: ProOrder strategies are evaluated once per bar on the strategy’s timeframe, so you cannot move the stop exactly at the tick that reaches +50 pips on that same timeframe. The standard workaround is to run your strategy on an inferior (lower) timeframe so that the check is done much more frequently and your stop moves to breakeven almost “during the bar”.


    Key idea:

    Use a lower timeframe (e.g. 1-minute or even seconds) and use the current price (i.e. close of that lower timeframe bar, which is much closer to live price) in your condition. You already use close in your code; the difference is the timeframe of the system, not the function name.


    Step-by-step solution

    1. Put your ProOrder system on a lower timeframe chart

    • If your strategy is currently on H1, consider M1 or M5.
    • Re-launch the ProOrder system on that lower timeframe.


    2. Keep the same breakeven logic, but on the inferior timeframe

    • The logic is fine, just make sure MoveToBreakEven is initialized and your system runs on the lower timeframe:
    TIMEFRAME(1 hour, updateonclose)
    //define here your code for your strategy entries / logic
    
    TIMEFRAME(default) //the timeframe the strategy is running onto
    // --- Parameters ---
    triggerDistance = 50    // number of pips (adapt if needed)
    
    // --- Variables ---
    IF not onmarket THEN
       MoveToBreakEven = 0
    ENDIF
    
    // --- Management of open position ---
    IF longonmarket THEN
       // Move stop to breakeven when price is triggerDistance pips in profit
       IF (close - tradeprice) >= triggerDistance * pointsize AND MoveToBreakEven = 0 THEN
          MoveToBreakEven = 1
          SET STOP BREAKEVEN
       ENDIF
    ENDIF
    
    IF shortonmarket THEN
       // Move stop to breakeven when price is triggerDistance pips in profit
       IF (tradeprice - close) >= triggerDistance * pointsize AND MoveToBreakEven = 0 THEN
          MoveToBreakEven = 1
          SET STOP BREAKEVEN
       ENDIF
    ENDIF
    


    3. Why this works better on an inferior timeframe

    • On H1: condition is evaluated once per hour; price could have been +50 pips and come back before bar close, and your stop never moves.
    • On M1: condition is evaluated every minute; you are much more likely to catch the moment when price is at least +50 pips.


    4. Important limitations

    • ProOrder does not react intrabar at each tick on a higher timeframe chart; it always uses the strategy timeframe bar close.
    • Therefore, using a lower timeframe is the standard and recommended way to “simulate” reacting to the live market price.


    Summary of changes you need:

    • Run your strategy on a lower timeframe (inferior timeframe).
    • Keep your breakeven condition using close – tradeprice (long) and tradeprice – close (short).
    • Use MoveToBreakEven as a flag to execute SET STOP BREAKEVEN only once.
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Stop loss at breakeven using live market price in ProOrder


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by AI-vy
2 hours, 18 minutes ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/24/2026
Status: Active
Attachments: No files
Logo Logo
Loading...