MFE Trailing Stop in % percentage

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #66249 quote
    InertiaInertia
    Participant
    Master

    Hi,

    I was wondering how I could replace the vlue in pts by an “x%” instead from the MFE ?

    //trailing stop
    trailingstop = 20
     
    //resetting variables when no trades are on market
    if not onmarket then
     MAXPRICE = 0
     MINPRICE = close
     priceexit = 0
    endif
     
    //case SHORT order
    if shortonmarket then
     MINPRICE = MIN(MINPRICE,close) //saving the MFE of the current trade
     if tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then  
      priceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price level
     endif
    endif
     
    //case LONG order
    if longonmarket then
     MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade
     if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
      priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price level
     endif
    endif
     
    //exit on trailing stop price levels
    if onmarket and priceexit>0 then
     EXITSHORT AT priceexit STOP
     SELL AT priceexit STOP
    endif
    #66261 quote
    NicolasNicolas
    Keymaster
    Legend

    It suffices to express the variable trailingstop converts to a point from a previously calculated data in percentage.

    For a trailingstop of 1%:

    Trailingstop = (close * 0.01)/pointsize

    Inertia thanked this post
    #66275 quote
    VonasiVonasi
    Moderator
    Master

    English speaking only in the English language forum please!

    Sorry Nicolas but I just could not stop myself posting this! 🙂

    #66284 quote
    InertiaInertia
    Participant
    Master

    Excellent Nicolas (FR UK ok 😉 )

    #66352 quote
    NicolasNicolas
    Keymaster
    Legend

    Ok guy! you got me! (Post edited) 😆

    Vonasi thanked this post
Viewing 5 posts - 1 through 5 (of 5 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

MFE Trailing Stop in % percentage


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Inertia @inertia Participant
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by NicolasNicolas
8 years, 6 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 03/24/2018
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...