Gamestudio Links
Zorro Links
Newest Posts
IG plugin initial release
by sodiumchloride. 09/22/20 20:53
Using STL in Zorro strategies
by AndrewAMD. 09/22/20 17:01
Rubbish data from Yahoo
by DanielX. 09/22/20 14:37
assert
by Grat. 09/22/20 12:14
MT4 - use more Zorro script
by Grat. 09/22/20 06:49
Single advise model for portfolio
by jmlocatelli. 09/21/20 19:41
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online Now
9 registered members (ozgur, AndrewAMD, ZeiX, sodiumchloride, 3run, distribution, kvm, Zheka, 1 invisible), 436 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
NewBorn, 3dvg, secretagentman, distribution, EditeY
18515 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: 302
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 302
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: 249
D
danatrader Offline
Member
danatrader  Offline
Member
D

Joined: Mar 2019
Posts: 249
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: 302
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 302
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: 249
D
danatrader Offline
Member
danatrader  Offline
Member
D

Joined: Mar 2019
Posts: 249
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: 249
D
danatrader Offline
Member
danatrader  Offline
Member
D

Joined: Mar 2019
Posts: 249
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: 302
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

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


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1