Decreasing Profit Taking by days

johnnybegoode

Trader
Jul 19, 2016
56
0
22
47
Decreasing Profit Taking by days

Lets say I set my profit taking at $100

How could I set write profit taking decreasing by days
i.e. 10% per day

Day 1: $100
Day 2: $90
Day 3: $80
Day 4: $70
Day 5: $60
Day 6: $50
Day 7: $40
Day 8: $30
Day 9: $20
Day 10: $10
Day 11: $0
Day 12: -$10
Day 13: -$20
etc..
 

Enivid

Administrator
Staff member
Nov 30, 2008
18,617
1,366
144
Odesa
www.earnforex.com
So, you want the take-profit value to decrease by 10% every day for some specific position? For example, if you are long EUR/USD @ 1.1000 with initial TP = 1.1100, you want the TP to move to 1.1099 on the next, then to 1.1098 on the next day, and so on? Or am I misunderstanding something here?
 

johnnybegoode

Trader
Jul 19, 2016
56
0
22
47
I take profit based on the Balance.
I trying to do this:
After X numbers of days, I would accept taking less and less profit each day.
Say I wanted 1.5/100 which is 1.5% profit initially.

if ((Profit) >= (Balance*(1.5/100)))
I'm trying to modify this line into

Taking 10% less of (Balance*(1.5/100))
as each day passes.

MQL5:
#define ONEDAY 86400 //24 hours in secoonds
 
void VariTPSL()
{
   double Balance = AccountInfoDouble(ACCOUNT_BALANCE);
   double Profit = AccountInfoDouble(ACCOUNT_PROFIT);
   long delta = TimeCurrent() - PositionGetInteger(POSITION_TIME);
 
   if( delta > (VariTPSL_After_X_Days*ONEDAY) )   // Take decreasing profit after X days
   {
   if ((Profit) >= (Balance*(1.5/100)))
   {     
        {
         Ordering=false;
         CloseAll3();
        }
   }
   }
 
Last edited:

Enivid

Administrator
Staff member
Nov 30, 2008
18,617
1,366
144
Odesa
www.earnforex.com
OK. With (delta / ONEDAY), you have number of days passed. Just multiply the initial TP by 10% and number of days and subtract that amount from the initial TP:

MQL5:
 (Balance*(1.5/100)) - (delta / ONEDAY) * 0.1 * (Balance*(1.5/100))