Trailing Stop based on time

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #185188 quote
    RichardVeenRichardVeen
    Participant
    Junior

    Hi,

    Question: is it possible to set a Trailing Stop based on time?

    The situation is as follows:

    Buy 1 LOT AT MARKET with a trailing stop of 10 points (from the entry price) in a 15 min chart.

    After buying 1 LOT, the price drops and the trailing stop stays at 10 points and after 5 min. the price is still below the entry price.

    Is it possible that after 5 min. , the trailing stop moves automatically to 5 points (from the entry price) and after 10 min. to breakeven and so on….. so in steps of 5?

    #185222 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    There you go (you should run it on a 5-minute, or 1-minute, chart):

    Timeframe(default)
    IF Not OnMarket THEN
       MyEXIT    = 10 * PipSize
       LastPrice = 0
    ENDIF
    //
    Timeframe(15 minute,UpdateOnClose)
    IF close CROSSES OVER average[200,1](close) AND Not OnMarket THEN
       BUY 1 CONTRACT AT MARKET
       SET STOP   LOSS   MyEXIT
       SET TARGET PROFIT MyEXIT * 3
    ENDIF
    //
    Timeframe(default)
    IF OnMarket THEN
       IF Not OnMarket[1] THEN
          MyEXIT    = (TradePrice - MyEXIT)
          LastPrice = TradePrice
       ENDIF
       IF close > (LastPrice + 5*PipSize) THEN
          LastPrice = close
          MyEXIT    = MyEXIT + 5*PipSize
       ENDIF
    ENDIF
    IF LongOnMarket THEN
       SELL AT MyEXIT STOP
    ENDIF
    //graphonprice MyEXIT     coloured(255,0,0,255)
    //graphonprice TradePrice coloured(0,0,255,255)
    //graphonprice LastPrice  coloured(0,128,0,155)
    #187072 quote
    RichardVeenRichardVeen
    Participant
    Junior
Viewing 3 posts - 1 through 3 (of 3 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

Trailing Stop based on time


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/11/2022
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...