profit reduces by 33%

Viewing 15 posts - 1 through 15 (of 40 total)
  • Author
    Posts
  • #69043 quote
    rama
    Participant
    Senior

    I have a buy order

    initial stop is 20

     

    market went in my favor say to 30,40,50 etc

    when market moves back  I want keep  66 .6 profit

    if longonmarket then

    if  ( x-close)<=.66*(close-tradeprice) then

    sell at market

    endif

    endif

     

    what is the X? how to code variable X

    #69049 quote
    robertogozzi
    Moderator
    Master

    Try this one

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

    Roberto

    #69052 quote
    GraHal
    Participant
    Master

    I’ve added above to the Snippet Link Database

    https://docs.google.com/spreadsheets/d/1rgboqj7sVwsP9ZRhOduOefye48QMWC07jWVXCl-KJPU/edit?usp=sharing

    Thank You @robertogozzi

    AlgoAlex thanked this post
    #69055 quote
    robertogozzi
    Moderator
    Master

    I’ve added above to the Snippet Link Database

    https://docs.google.com/spreadsheets/d/1rgboqj7sVwsP9ZRhOduOefye48QMWC07jWVXCl-KJPU/edit?usp=sharing

    Thank You @robertogozzi

    Sorry GraHal, I forgot to (as I do most of times). Thanks for paying attention.

    #69065 quote
    rama
    Participant
    Senior

    Thanks for your fast reply Roberto. I have am back testing this now, will take another 4 to 5 hours get decent result.

    I my guess it may not work, as soon as the  profit falls below the 30 , the stop will go to the original stop loss

    I am keeping fingers crossed, I will post the results by EoD today

    #69067 quote
    robertogozzi
    Moderator
    Master

    This trailing SL is hard coded in your strategy, not managed by ProOrder or your broker, it’s a pending order to be set at each new candle.

    You may as well have set your stop ploss at, say 100 pips, but still exit in profit as this code is progressing candle after candle.

    #69071 quote
    rama
    Participant
    Senior

    please find the screen shots

    if max profit once gone past 30 say 36

    I want keep stop loss .66(tradeprice+36) at least in the event market is coming back.

    on the other hand if the profit goes to 60 i want keep .66(tradeprice+60)

     

    I tested the code is not working, as the price keeps falling after >=30 SL coming down by .33%

    stop1.jpg stop1.jpg stop2.jpg stop2.jpg
    #69074 quote
    robertogozzi
    Moderator
    Master

    Well… It works almost like that, but if it reaches 50 pips profit Y will be set to 33.3, but if the next candle decreases to 40 pips profit, it won’t keep 33.3 but will decrease to 26.6.

    I will make a change.

    #69075 quote
    robertogozzi
    Moderator
    Master

    This should work

    IF Not OnMarket THEN
       y = 0
    ENDIF
    IF LongOnMarket AND close > TradePrice 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
          SELL AT close - (y * pipsize) STOP      //convert pips to price
       ENDIF
    ENDIF
    #69076 quote
    rama
    Participant
    Senior

    I am running the strategy on 3 sec or 5 seconds range.

    it is keeping changing, the whole is ideas is keep some profits.

     

    how above set stop loss trailing SL

    SL=(1-y)

    #69080 quote
    rama
    Participant
    Senior

    thanks, I am doing back testing, will update the feedback soon

    #69110 quote
    rama
    Participant
    Senior

    I have back tested even modified code is not working

    it strange.

    #69118 quote
    Leo
    Participant
    Veteran
    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 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

     

    Try this.

    #69120 quote
    Madrosat
    Participant
    Master

    Hello Léo

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

    could you explain me  well detailed ??

    #69128 quote
    rama
    Participant
    Senior

    back testing is on , collecting sample data before conclude whether the code works or not.

Viewing 15 posts - 1 through 15 (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...