Profit Trailing Stop

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #99343 quote
    solar
    Participant
    Senior

    Hi everyone, i am new to prorealcode

    Can anyone help me code the following trailing stop strategy?

    Exit the trade when bookprofit retace 40% from its maximum level (minimum level to be triggered = $1000 bookprofit)

    Many thanks!

    #99687 quote
    solar
    Participant
    Senior

    Does anyone have any suggested solution ?

    #99695 quote
    Vonasi
    Moderator
    Master

    Just record your maximum profit achieved by comparing the position price to the high for long trades (or low for short trades). Then calculate what value would be 40% lower or higher and place a pending order at that price. Something like this – once again not tested and written after just one coffee! Written for non cumulating positions.

    defparam cumulatepositions = false
    
    if not longonmarket and (your long conditions) then
    buy 1 contract at market
    maxprofit = 0
    endif
    
    if not shortonmarket and (your short conditions) then
    sellshort 1 contract at market
    maxprofit = 0
    endif
    
    if longonmarket then
    maxprofit = max(high - positionprice, maxprofit)
    exitprice = positionprice + (maxprofit * 0.60)
    if maxprofit >= 1000 then
    sell at exitprice stop
    endif
    endif
    
    if shortonmarket then
    maxprofit = max(positionprice - low, maxprofit)
    exitprice = positionprice - (maxprofit * 0.60)
    if maxprofit >= 1000 then
    exitshort at exitprice stop
    endif
    endif
    
    solar thanked this post
    #99737 quote
    solar
    Participant
    Senior

    By the way, is “set stop %trailing ” not available in ProOrder?

    the coding was fine in ProBacktest, yet the program said it cannot be used in ProOrder.

    I am currently using PRTv10.3

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

Profit Trailing Stop


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
solar @fatlung Participant
Summary

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

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