POSITIONPERF and Highest[] function for TAKE PROFIT

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #16276 quote
    Philippo
    Participant
    Average

    Hi all, I notice my strategy is good at picking entries and then cumulates the position when it meets further entry signals and is in profit. Trouble is that this kind of strategy needs to be very protective over its gains or as quick as they come, they go on the first downturn.

    I would like to set an exit point based purely on the position performance, that is I want to lock in some gains by identifying when position performance is turning south. Exactly how, not sure, but something like:

    if positionperf < (Highest positionperf over 20 bars *0.95)  (i.e. we’re losing 5% from our peak gain in the last 20 bars) then

    close position

    endif

    n= highest[20](POSITIONPERF)

    I am trying to identify the point in the last 20 bars when my position was best. From there I will exit position if it falls below a certain %.

    However the command above when pushed through the GRAPH command does not produce the expected, it’s blank. Is this the right way or is there a way with SET STOP %TRAILING y? Note I am using cumulative orders.

    #16281 quote
    Nicolas
    Keymaster
    Master

    You could use the “floatingprofit” variable calculation we made for cfta’s pyramiding trading strategy

    This is an idea not tested, it may suit your request I think:

    if not onmarket then 
     highestprofit = 0
    endif
    
    if onmarket then 
     //floating profit
     floatingprofit = (((close-positionprice)*pointvalue)*countofposition)/pipsize //actual trade gains
     highestprofit = max(highestprofit,floatingprofit)
    endif

    The “highestprofit” variable store the maximum profit met while we are still on market. So you can made your own calculation from there.. Would be glad to know if it works for you! Share your code! 🙂

    #16286 quote
    Philippo
    Participant
    Average

    I have doubts that positionperf works like other variables….

    #16287 quote
    Philippo
    Participant
    Average

    that looks exactly what I am looking for 🙂 Thanks

    #16298 quote
    Philippo
    Participant
    Average

    Hi, I need even simpler, but couldn’t have done it without your help Nicolas, thanks

    PositionKeepProfit=0.1 // max allowed drop from highest profit peak
    //
    //other code
    //
    
    if not onmarket then
    maxperf=0
    else
    maxperf= max(positionperf, maxperf)
    bailout = (1-positionperf/maxperf) > PositionKeepProfit 
    if bailout and longonmarket then
    SELL AT MARKET 
    exitreason=-9
    elsif bailout and shortonmarket then
    EXITSHORT AT MARKET
    exitreason=-10
    endif
    endif
    
    
            
        
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

POSITIONPERF and Highest[] function for TAKE PROFIT


ProOrder support

New Reply
Author
author-avatar
Philippo @philipd Participant
Summary

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

Topic Details
Forum: ProOrder support
Language: English
Started: 11/10/2016
Status: Active
Attachments: No files
Logo Logo
Loading...