Trailing funds function (equity) - has anyone come across a ready-made one? - page 5

[Deleted]  

Vitalya_1983 thanks, poked a blind man. =) I'll give it a try.

Although the option with percentage is not ideal: the more profit will be achieved, the less will be fixed on the rollback.

And want the solution the topicstarter was talking about:

ЗЫ: вот собственно то, о чем говорил, про "на издохе движения", и как раз в такие моменты хорошо иметь тралл под рукой..

I.e. a ratchet on the profit, so the offer to xrust stands.
[Deleted]  
ToKa_TuXa >> :

xrust - I have a suggestion to you - can you bring the code of your version of the equity trawl as a standalone EA.

It would be a very useful tool for hand traders.

I have been looking for such a tool for a long time but have not found anything suitable.

That would be great...

 

I will...

[Deleted]  

Сделаю...

Thanks in advance =)

[Deleted]  
xrust >> :

>> I will...

Waiting ...

[Deleted]  

xrust - please give me a hint about the timeline.

Maybe someone has a ready solution and is willing, out of the goodness of his heart, to share it?

 
ToKa_TuXa писал(а) >>

xrust - please give me a hint about the timeline.

Maybe someone has a solution and is kind enough to share it?

//+------------------------------------------------------------------+
//|                                           EqutyTrawlerXR_V00.mq4 |
//|                                 Copyright © 2009, XrustSolution. |
//|                                        http://www.xrust.ucoz.net |
//+------------------------------------------------------------------+
#property copyright "#Copyright © 2009, XrustSolution.#"
#property link      "#http://www.xrust.ucoz.net#"
extern double       EqutyPersent      =   1;
extern double       RepeatTimeinSec   =   1;
//+------------------------------------------------------------------+
void start(){double step=1;
  if( RepeatTimeinSec==0){ RepeatTimeinSec=0.1;}
  while(!IsStopped()&&IsExpertEnabled()){
    Sleep(1000* RepeatTimeinSec);
    if(AccountEquity()>AccountBalance()){
      if(AccountProfit()>AccountEquity()/100* EqutyPersent* step){ step++;}
      if( step>1){
        if(AccountProfit()<=AccountEquity()/100* EqutyPersent*( step-1)){
          CloseAll();
        }
      }
    }
  }
return;}
//+------------------------------------------------------------------+
// Закрывает все ордера на данном инструменте                        |
//+------------------------------------------------------------------+
void CloseAll(){
for(int n=OrdersTotal()+1; n>=0; n--){
  if(OrderSelect( n, SELECT_BY_POS, MODE_TRADES)){ 
    if(OrderType()<2){ 
      del(OrderTicket());
    }  
  }    
}  
return;    
}
//+------------------------------------------------------------------+
//Удаляет рыночный ордер с указанным ей тикетом                      |
//+------------------------------------------------------------------+
void del(int ticket){int err;
for(int i=0; i<1; i++){
   GetLastError();//обнуляем ошику
   OrderSelect( ticket, SELECT_BY_TICKET, MODE_TRADES);
   string symbol = OrderSymbol();
   if(OrderType()==OP_BUY){RefreshRates();
     double prise = MarketInfo( symbol,MODE_BID);
     if(!OrderClose( ticket,OrderLots(), prise,3,Green)){ err = GetLastError();}}
   if(OrderType()==OP_SELL){RefreshRates();
     prise = MarketInfo( symbol,MODE_ASK);
     if(!OrderClose( ticket,OrderLots(), prise,3,Green)){ err = GetLastError();}}
if( err == 0){PlaySound("expert.wav");break;} 
if( err != 0){PlaySound("timeout.wav");Print("Error for Close Funtion =", err);} 
while(!IsTradeAllowed()){Sleep(5000);}// если рынок занят то подождем 5 сек 
if ( err==146) while (IsTradeContextBusy()) Sleep(1000*11);
} 
}
[Deleted]  
Thank you, Rust, I will look into it.
 
drive it well - check it out
[Deleted]  

Thank you, we'll be testing...

Just a few suggestions:

1. Add indication: max. profit/losing profit;

2. If you want to add an option of trawl with a specified level in $, you can set not %, but distance from max profit to stop in money.

Let me try to explain the disadvantages of percentage approach: you have 20 positions with small lot - total profit for 24 hours brings $300. If we set, for example, 30% (in fact - any) level, then in case of pullback we will get $200 - $100 in passing. If we had a fix level, even 50, we would have 50$ more.

Someone may say: we would not get to 300 with a fixed level, but it is true with a small number of equally directed instruments. In the case of the packaged strategy the profit grows uniformly, without big drawdowns, and a serious change of the set character indicates a reversal. So, we should jump out of it, without waiting until the reversal (which is usually fast) eats a % of the passed.

Pardon the many gibberish, with the hope of "got it" ; )