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

 
bstone писал(а) >>

Then the author says about trailing stops on equity, and Combat says that stops to the ass - give them tokens. In short, the enemy camp is a mess :)

"War is war, lunch is routine..."

It's lunchtime now... :))) and that means peace...

*

First of all, "trailing stops", or more accurately "trailing stops" refers to certain

trading moments when it is inefficient to use the regular one for each position in the basket.

And when you need it, especially for single independent positions, the staff t-c goes full speed...

So don't make an 'enemy of t-c's' out of me... :))) is the wrong conclusion to the question.

*

If you approach the author's question formally, you can guess a lot of things for him...

For example, he needs it to control investments that are held in trust.

In general, he knows best what he wants... ;)

*

I was only hooked on the similarity of what I myself am interested in and need...

As I described above for trading "packages" (portfolios, baskets) on ru-share.

The pledges there are miserable, that's why the most stable, albeit with a small percentage, tactic was chosen.

trading in mixed stocks by sectors, e.g. banks, gasprom and oil companies with some telecoms...

*

So opening a dozen or two or three positions it is difficult to choose t-c level for each of them.

One requires 20, the other 200, the third one moves like a fan back and forth...

Plus the aggravation of the situation by the lack of standard t-cs, and the use of self-written

is not possible fully because of dragging stops with a single level for all positions,

which, alas, is not suitable for the above reasons...

So, it would be quite logical to use a profit trawl or equity that is almost the same...

*

...

 

For equity trailing, you can use the principle of position scanning as in this script to calculate the break-even level. Not mine, I stole it somewhere, may the author forgive me.

//+------------------------------------------------------------------+
//|                                                    Bezubytok.mq4 |
//+------------------------------------------------------------------+
#include <WinUser32.mqh>
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
int Spr= MarketInfo(Symbol(),MODE_SPREAD);
//------------ Безубыток  ---------------------------------------------------
double B2_B=0, B2_S=0, B2_LB=0, B2_LS=0, BSw=0, SSw=0;
      for(int b2=0; b2<OrdersTotal(); b2++) //  
      {
      if(OrderSelect( b2, SELECT_BY_POS, MODE_TRADES)==false)    continue;
      if(OrderSymbol()==Symbol())
      {
           if (OrderType()==OP_BUY)
           {
           B2_B=(( B2_B* B2_LB)+(OrderOpenPrice()*OrderLots()))/( B2_LB+OrderLots());
           B2_LB= B2_LB+OrderLots();
           BSw= BSw+OrderSwap();
            }
                if (OrderType()==OP_SELL)
                {
           B2_S=(( B2_S* B2_LS)+(OrderOpenPrice()*OrderLots()))/( B2_LS+OrderLots());
           B2_LS= B2_LS+OrderLots();
           SSw= SSw+OrderSwap();
               }
            }}
double M2B=0, M2S=0 , M5;           
    if ( B2_LB> B2_LS)   // Идём вверх
{
for(int J2=0; J2<10000; J2++)
    {
    M2B= J2* B2_LB*10;
    M2S=(( B2_B- B2_S+ Spr*Point)/Point+ J2)*( B2_LS*(-10));
    if ( M2B+ M2S+ BSw+ SSw>=0) 
        {
        M5=NormalizeDouble( B2_B+ J2*Point,Digits);
        break;
        }}} 
if ( B2_LS> B2_LB)  //  Идём вниз
{
for(int J3=0; J3<10000; J3++)
    {
    M2S= J3* B2_LS*10;
    M2B=(( B2_B- B2_S+ Spr*Point)/Point+ J3)*( B2_LB*(-10));
    if ( M2S+ M2B+ BSw+ SSw>=0) 
        {
        M5=NormalizeDouble( B2_S- J3*Point,Digits);
        break;
        }}}
  string Message;      
       if ( B2_LS== B2_LB && B2_LB!=0 ) Message="Залокированные позиции" ;
       else           
       Message="Уровень без убытка  "+"\n"+"          "+DoubleToStr( M5,Digits)+"\n"+
       " Надо пройти  "+DoubleToStr(( M5-Bid)/Point,0);
MessageBox( Message,Symbol(), MB_OK);                 
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
kombat >> :

No, I didn't call anyone an enemy. It was just a joke to spice up the prose.


Otherwise I got your point. However I am confused by one point: it appears that you trade by portfolio equity but not by the instruments included into it. Is it easier to predict the equity of a portfolio consisting of dozens of instruments than of individual ones?

 
bstone писал(а) >>

No, I didn't call anyone an enemy. It was just a joke to spice up the prose.


Otherwise I understood your point. But I am confused by one point: it appears that you trade on the portfolio equity, not on the instruments included into it. Isn't it easier to predict the equity of a portfolio consisting of dozens of instruments than of individual ones?

I see... ;)

*

As for the idea of "trading equity", it was noticed long ago that "opening

of lots of instruments, quite often "islands of profit" with a good % have appeared.

I wanted to close them all at once... but the toad kept saying: not yet, not yet

Then I lost control, because I wouldn't sit staring at the monitor for hours, and...

Catching a fat moose... cursing myself, you know, you could have closed on it...

*

And putting that control on a mechanical miracle

that doesn't know the word greed will only win this battle...

In all seriousness, just automate the process for maximum efficiency.

*

As for forecasting...

Erm... there's a slightly different approach to portfolio construction...

A classic portfolio tends to be built for the long term and it's more of an investment than a speculation,

and there are more points than intraday trades or trades of a few days at most...

The basis for the suggested approach is: a variety of instruments

*

By the way, the same can be seen in currencies and in currency+futures pairing

*

It's more informative, of course, if you use a demo...

try it ;)))

 
YuraZ писал (а) >>

the author meant rather the opposite when equity went too fast upwards from the balance line

to pull up the stops to Breakeven

If I'm reading the author's mind correctly.

Yes, Yura, I was interested (in general I was only interested in a ready-made equity trawl function if anyone has one, but it seems I'm again the first to need something outside of the conventional framework/stamps/classics of market trading, etc.) in the equity trawl function purely out of greed.) Equity trawl function solely out of greed, like that Khokhol from the anecdote who was told to take as much land as he could, so he got on his horse, galloped and galloped, galloped and galloped, the horse ran, ran and galloped, fell, crawled and crawled, crawled and crawled, tired to gallop, took his hat off, threw it and said: "...and ocee to tomatoes!" :)))


As a rule, equity goes up very quickly in the middle of a move but rolls back very quickly as well, and this is where one would like to turn on a trall, make a maximum of the movement and close everything in peace.

you understand that stops may be used not only to take a loss but also to protect a profit

You can also increase equity ;) it turns out you can do a lot with stops :)

i think this is what the author meant

some TS have jumps of equity from the balance line

If you have an indicator, you may try to use it to breakeven, at least.

As for the rest parameters you have stelepated incorrectly) about breakeven, I do not breakeven, I do not need it, it's useless, as Roman correctly said - it's evil :)

bstone wrote (a) >>

No, it does not. The author himself said that his religion does not allow him to use standard stops.


Looks like it :)

I, as a Soviet-born atheist, religion allows me to do everything, but TC forbids it, because the feet are engaged, clearly fulfil their purpose and there is no need to interfere with them, they are at work and cope with their task perfectly.


But "virtual" stops by equity, please. I'm a slowpoke, but I don't see the difference. Whether you close with regular or virtual stops, the result is the same.

It is not about retardedness, you are not retarded, believe me, you will not understand the difference, because you do not have the input data to see it.


Then the author talks about trailing stops on equity, and Combat says that stops to the ass - give tees. In short, the enemy camp is in disarray :)

Well ... I do not know Kombat TC, maybe he overdid it with stops in the * ass, and maybe not :) who knows

And I'm sure I've fucked the tags, there are no goals, it's all for the sake of evil, IMHO :)

The author's general thought is quite clear, but as I said, I do not see it as a rational basis. The author would like to save his profit and exit the market when the equity has increased, say, by 20% at first and then began to decrease to 10%. So, the virtual stop loss was 10%. Yes, we earned 10% and we are rejoicing.

Oh, Roman, that's the point, the author's thought is not clear to you :) not-so-understood.

I am interested in trawling after 150-200%. (it's all demo, calm, real next week, according to the signal).



But again, why didn't the TS close with standard stops? If it didn't close, it means that market analysis implied a possibility of some short-term unfavourable developments. Stops are the stops for exiting the market, if it is obvious that the working hypothesis about its conditions is not correct. And if not a virtual stop, the market would have slightly frightened by a pullback and would have gone upwards. The regular stops would have performed their job perfectly, but the virtual stop would have bitten off all the profits. So, you can guess what would be better.

If I'm not going to repeat myself, I've just written above, they do their job properly... Stops allow not only to exit, but also to enter.

And with regard to "why the TC..." and so on in the text - it's not her business to do what she shouldn't, and what she should do - she's doing fine :)

kombat wrote (a) >>

"War is war, dinner is routine..."

It's lunchtime right now... :))) and that means peace...

*

First of all, "trailing stops", or more accurately "trailing stops" refers to certain

trading moments when it's inefficient to use the regular one for every position in the basket.

Well, the *butt* is solved, so it's good :)

Yes, the regular trailing stops are really fucked, as using them on every position in the basket can be not only inefficient but killer in general, for me and for my TS

If we are to deal with the author's question formally, we can think of many things for him...

.

No need to guess anything for the author, he manages to guess for himself :))

For example, he needs it to control investments that are under trust management.

In general, he knows best what he wants... ;)

Combat, I'll think in two or three months on it, DU... beautiful letters, and in Aglitsk va - IBO :) but maybe do not even think will ... ;) I mean I won't even think about it :))

Really all trivial - I need it, as correctly said Comrade Kombat :)

Seriously, just automate the process to be as efficient as possible.

ZS: In general, airing the body today in nature, I thought it would be nice to trall by equity trendline, and to screw something else into it...

 
FION писал (а) >>

For equity trailing, you can use the principle of position scanning as in this script to calculate the breakeven level. Not mine, I stole it somewhere, may the author forgive me.

Thank you, Sergey, but it is not quite suitable.

 
alexx_v писал(а) >>

...( I was actually only interested in a ready-made funds trawl function if anyone has one, but it looks like I'm once again the first to need something outside of the conventional framework/stamps/classics of market trading etc.)

...

Here's a look, it might work.

Files:
 
Talex писал (а) >>

Take a look at this, it might work.

I will definitely have a look, thanks.

ZS: this is actually what I was talking about, about "on the breath of motion", and just at such moments it's good to have a trall handy...


 
How did it all end, I wonder?
 
OZ0 >> :
How did it end, I wonder?
extern bool   VirtualTrayling=true;
extern int    VirtualTraylingDistance=200;
int Distance=0;

////////////////////////////////////
if ( VirtualTrayling==true)
      {
         if ( CurrentProfitInPips()> VirtualTraylingDistance && CurrentProfitInPips()> Distance+ VirtualTraylingDistance)
            {
            Distance= CurrentProfitInPips()- VirtualTraylingDistance;
            }
         
         if ( CurrentProfitInPips()< Distance && CurrentProfitInPips()>0)
            {
            Distance=0;
            CloseAllPosition();
            }   
      }
/////////////////////////////////////

int CurrentProfitInPips()
{
   int pr=0;
   double pnt=0;
   
   for(int cnt=OrdersTotal()-1; cnt>=0; cnt--)
   {
     OrderSelect( cnt, SELECT_BY_POS, MODE_TRADES);
     if(OrderMagicNumber()!= MagicNumber)
     continue;
     pnt=MarketInfo(OrderSymbol(), MODE_POINT); 
          if(OrderMagicNumber()== MagicNumber)
          {
               if (OrderType()==OP_SELL) 
               pr= pr+(OrderOpenPrice()-OrderClosePrice())/ pnt;
               
               if (OrderType()==OP_BUY) 
               pr= pr+(OrderClosePrice()-OrderOpenPrice())/ pnt;
             
          }
   }
return( pr);   
}