Gamestudio Links
Zorro Links
Newest Posts
Alpaca - anyone tried using them?
by DdlV. 10/28/20 19:38
Work in Indian markets
by AndrewAMD. 10/28/20 11:14
Force chart into a y-axis range?
by ozgur. 10/27/20 18:57
Special Bars Script
by atr. 10/27/20 09:06
Optimize in a ranked asset portfolio
by dBc. 10/27/20 06:33
MT4 - use more Zorro script
by danatrader. 10/27/20 06:23
TIP: Multiply Your Trade VPS
by danatrader. 10/27/20 05:48
AUM Magazine
Latest Screens
Paradox Vector
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
Who's Online Now
3 registered members (Quad, AndrewAMD, danatrader), 464 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
xilex, exshifta, mr_T0ma5, AVL, ruins
18530 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
lock profit without trail #477605
07/14/19 15:53
07/14/19 15:53
Joined: May 2015
Posts: 319
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 319
Czech Republic
Hi,

I dont like trail function. With this TMF function you can lock profit without laugh

Code
//--------------------- TMF --------------------------------------------------------
#define VAR_LOCK TradeVar[0]
#define VAR_ACTI TradeVar[1]
#define VAR_CLOSE TradeVar[2]

int myTMF(){
  if (TradeIsEntry){
    // only one each trade?
    VAR_LOCK=-1;  // No lock
    VAR_ACTI=1*TradeLots;          // 1 USD/per LOTS ... MT4 1=0.01
    VAR_CLOSE=VAR_ACTI*0.8;        // after profit is target, profit under 80% close trade
  }
  
  if(TradeIsOpen){
    if (TradeProfit > VAR_ACTI)
      VAR_LOCK=1.0; // activate trigger

    if (VAR_LOCK > 0 )
    if (TradeProfit < VAR_CLOSE){
      exitTrade(ThisTrade);
      return 16;
    }

    if (TradeProfit > VAR_ACTI*1.05){
      // Profit > ACTI+5%
      VAR_ACTI=TradeProfit;
      VAR_CLOSE=VAR_ACTI*0.8;
    }
  }    
  
  return 0;
}

Last edited by Grat; 07/14/19 15:54.
Re: lock profit without trail [Re: Grat] #481428
09/15/20 06:05
09/15/20 06:05
Joined: Mar 2019
Posts: 299
D
danatrader Online
Member
danatrader  Online
Member
D

Joined: Mar 2019
Posts: 299
Nice, I will make use of it (potentially) laugh

Re: lock profit without trail [Re: Grat] #481437
09/16/20 08:05
09/16/20 08:05
Joined: May 2015
Posts: 319
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 319
Czech Republic
Yes,

in the original is a bug:

int myTMF(){
if (VAR_LOCK == 0){

Re: lock profit without trail [Re: Grat] #481446
09/17/20 21:05
09/17/20 21:05
Joined: Mar 2019
Posts: 299
D
danatrader Online
Member
danatrader  Online
Member
D

Joined: Mar 2019
Posts: 299
This is not Grat, this is Great laugh

Re: lock profit without trail [Re: Grat] #481469
09/18/20 13:27
09/18/20 13:27
Joined: Mar 2019
Posts: 299
D
danatrader Online
Member
danatrader  Online
Member
D

Joined: Mar 2019
Posts: 299
Is it needed in case of MaxLong = MaxShort > 1 to have a for(current_trades) loop in a TMF or does TMF automatically go through all open trades?

Re: lock profit without trail [Re: Grat] #481471
09/18/20 14:30
09/18/20 14:30
Joined: May 2015
Posts: 319
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 319
Czech Republic
TRADE* EnterTrade(int side)
{
if (side == _LONG)
return enterLong(myTMF);
else
return enterShort(myTMF);
}

Re: lock profit without trail [Re: Grat] #481517
09/24/20 09:59
09/24/20 09:59
Joined: Oct 2017
Posts: 30
Munich
K
kalmar Online
Newbie
kalmar  Online
Newbie
K

Joined: Oct 2017
Posts: 30
Munich
Thank you, Grat laugh And what is the problem with trails? Thx

Re: lock profit without trail [Re: Grat] #481528
09/25/20 06:46
09/25/20 06:46
Joined: Mar 2019
Posts: 299
D
danatrader Online
Member
danatrader  Online
Member
D

Joined: Mar 2019
Posts: 299
Trails in many times reduce profit.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1