profit reduces by 33%

Viewing 15 posts - 16 through 30 (of 40 total)
  • Author
    Posts
  • #69132 quote
    Leo
    Participant
    Veteran

    Hello Léo

    I don’t understand : MaxX=MaxX=max(x,MaxX)

    could you explain me well detailed ??

     

    IF LongOnMarket AND close > TradePrice THEN
       x = (close - tradeprice) / pipsize         //convert price to pips
       MaxX=max(x,MaxX) //store the max profit during trade
    IF x >= 30 THEN                            //go ahead only if 30+ pips
          y = MaxX * 0.666                       //y = 66.6% of current profit
          SELL AT TradePrice + Y*pipsize STOP      //convert pips to price
       ENDIF
    ENDIF

    Copy paste problem. MaxX is a variable which store the maximum profit and when the profit is at 66% of the higher value it closes the trade.

    NOTE: always reset to 0 the MaxX when you open a trade

    #69133 quote
    Leo
    Participant
    Veteran
    Once MaxX=0
    IF LongOnMarket AND close > TradePrice THEN
       x = (close - tradeprice) / pipsize         //convert price to pips
       MaxX=MaxX=max(x,MaxX) //store the max profit during trade
    IF x >= 30 and x < 0.66*MaxX THEN                 //Exit only if 30+ pips
    SELL AT MARKET
    MaxX=0
    ENDIF
    ENDIF

     

    Maybe like this

    #69148 quote
    Vonasi
    Moderator
    Master

    MaxX=MaxX=max(x,MaxX)

    Copy paste problem again Leo!

    #69153 quote
    Leo
    Participant
    Veteran

    Have you ever try to write a code from your mobile phone? No way!

    #69161 quote
    Vonasi
    Moderator
    Master

    Have you ever try to write a code from your mobile phone? No way!

    I’m one of those weirdo’s in life who doesn’t have a mobile phone. If someone needs to talk to me that badly they can phone my girlfriend. And as for everything else that a phone can do these days the engineer in me says that it is not the right tool for most of those jobs anyway – which I think you may have just proven.

    Must go as trying to add up my losses on my abacus.

    #69190 quote
    Madrosat
    Participant
    Master

    thank you for your answer Leo I understand the purpose (( store the max profit) but there is something that I do not understand in the computer language of this line if someone can detail this formula for me to understand

    #69191 quote
    Vonasi
    Moderator
    Master

    The line should read

    MaxX = MAX(x,MaxX)

    It ensures that the value of MaxX remains at which ever is the highest value of the last highest MaxX and the new x calculated at this bar. This way the value of MaxX can only ever go up and not down.

    #69198 quote
    rama
    Participant
    Senior

    I am back testing now, I will update the results

     

    alternate way of coding is

    x= time of the trade 1 initiated

    y=(Highest(2000)(high)- tradeprice)

    if ctime >= x and and   y>=30 then

    if close(1)<=  tradeprice+.667*y

     

    sell at market

    endif

    endif

    what is x? in terms for PRT code

    picture attached for x

    time.jpg time.jpg
    #69203 quote
    robertogozzi
    Moderator
    Master

    After some testing I changed the code as follows (it seems to be working as expected):

    IF Not OnMarket THEN
       y = 0
    ENDIF
    IF LongOnMarket AND close > (TradePrice + (y * pipsize)) THEN
       x = (close - tradeprice) / pipsize        //convert price to pips
       IF x >= 30 THEN                           //go ahead only if 30+ pips
          y = max(x * 0.666, y)                  //y = 66.6% of max profit
       ENDIF
    ENDIF
    IF y THEN                                   //Place pending STOP order when y>0
       SELL AT Tradeprice + (y * pipsize) STOP  //convert pips to price
    ENDIF

    Give me some feedback.

    #69243 quote
    rama
    Participant
    Senior

    Many thanks , code seems to be working well results attached.

    I will evaluate results and post updates

    robertogozzi thanked this post
    33percent_profit_trailing.jpg 33percent_profit_trailing.jpg
    #69270 quote
    GraHal
    Participant
    Master

    I was looking for this Thread and  instinctively went to the ProOrder Support Forum … with all the coding support shouldn’t this be in that Forum?

    #69271 quote
    rama
    Participant
    Senior

    Admin can move this thread to appropriate place

    #69273 quote
    robertogozzi
    Moderator
    Master

    Right. I didn’t even realize that.

    GraHal thanked this post
    #69662 quote
    rama
    Participant
    Senior

    I want introduce steps of trailing into the stop loss

    for steps I have modified code as follows, can you confirm whether this will work ? if not suggest me code changes

    ret=.2
    ret1=.7
    
    IF Not OnMarket THEN
    y = 0
    ENDIF
    IF LongOnMarket AND close > (TradePrice + (y * pipsize)) THEN
    x = (close – tradeprice) / pipsize //convert price to pips
    IF x >= 10 and x<=30 THEN //go ahead only if 30+ pips
    y = max(x * ret, y) //y = 66.6% of max profit
    ENDIF
    
    IF x >= 30 and x<=70 THEN //go ahead only if 30+ pips
    y = max(x * ret1, y) //y = 66.6% of max profit
    ENDIF
    ENDIF
    IF y THEN //Place pending LIMIT (not STOP) order when y>0
    SELL AT Tradeprice + (y * pipsize) stop //convert pips to price
    ENDIF
    #69663 quote
    robertogozzi
    Moderator
    Master

    To write code, please use the <> “insert PRT code” button, to make code easier to read. Thank you.

    I’ll take a look at your code ASAP.

Viewing 15 posts - 16 through 30 (of 40 total)
  • You must be logged in to reply to this topic.

profit reduces by 33%


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
rama @rama Participant
Summary

This topic contains 39 replies,
has 6 voices, and was last updated by GraHal
7 years, 10 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/24/2018
Status: Active
Attachments: 7 files
Logo Logo
Loading...