Negro! - page 57

 
paukas:
So that the drain not from trading happen, but . Not from bad MM..

I didn't make it.

And from what?

 

account trend

red line - account drawdown

black line - spread of profits

green line - probably loss braking


 

Slightly complicated the calculations.

//+------------------------------------------------------------------+
//|                                                  sanyooooook.mq4 |
//+------------------------------------------------------------------+
#property copyright "Copyright © Mthmt, April 2012"

extern double  _deposit = 100.0;
extern double  _spread = 2.;
extern double  _tp = 30.;
extern double  _sl = 30.;
extern double  _startLot = 0.1;
extern double  _multiplier = 2.;
extern int     _howMany = 10000;

int _deathArr[ ][ 1000 ];


int start( )
{
   ArrayResize( _deathArr, _howMany );
   MathSrand( GetTickCount( ) );
   
   double depo = _deposit;
   double lot = _startLot;
   double resPips;
   int count = 0;
   
   for( int i = 0; i < _howMany; i ++ )
   {
      count = 0;
      lot = _startLot;
      depo = _deposit;
      double depoMax = depo;
      while( depo > 0 )
      {
         resPips = dealResultPips( );
         depo += resPips * lot * 10;
         _deathArr[ i ][ 2 + count ] = depo;
         
         if( depo > depoMax )          depoMax = depo;
         
         count ++;
         if( resPips < 0 )      lot *= _multiplier;
         else                   lot = _startLot; 
      }
      _deathArr[ i ][ 0 ] = count;
      _deathArr[ i ][ 1 ] = depoMax;
   } 
   
   toFile( );   
   return( 0 );
}//+------------------------------------------------------------------+

   
      double dealResultPips( )
      {
         double ratio = ( _tp + _spread ) / _sl ;
         if( MathRand( ) < 32768. * ratio / 2  )         return( - _sl );     /// fail
         else                                            return(   _tp );     /// success   
      }//+------------------------------------------------------------------+
      
      
      void toFile( )   
      {
         int h = FileOpen( "death.txt", FILE_CSV | FILE_WRITE, "," );
         FileWrite( h, "##", "Deals total", "Max deposit" );
         string sOut = "";
         for( int i = 0; i < _howMany; i ++ )
         {
            int countTot = _deathArr[ i ][ 0 ] + 2;
            for( int cnt = 0; cnt < countTot; cnt ++ )      
               sOut = sOut + _deathArr[ i ][ cnt ] + ",";
            FileWrite( h, i, sOut );
            sOut = "";
         }   
         FileClose( h );
         return;
      }//+------------------------------------------------------------------+      

The statistics are different, I was wrong. There are sequences up to tens of thousands of trades long (the last run of the script had more than 17 thousand trades at most). Everything is printed to big file with 2 megs. If trades up to 1000 (with current settings), then all trades can be seen. If more - they are cutted. Increasing this parameter does not increase the file, because there are very few successful series.

The average length of the series before the loss is about 48 trades. But 99% of the series can be up to 700 trades long.

I will introduce the bailout check a little later. But it will hardly change much.

The maximal depo is also calculated.

 
What's the matter with you, you can't even drain the deposit properly?)
 

Why don't you add the spread to st.

In my opinion, with a stop loss the loss is more on the spread, with a profit the profit is less on the spread.

 

Because there are different ways of counting here. For me - it takes more to get to the take than to the stop to get equal numbers.

And the difference between them is one spread, not two.

Just increased max series (second array dimension) to 10000. It's fine, works for less than 10 seconds.

 

I just got in and it's been spinning for two minutes.)

      double dealResultPips( )
      {
         double ratio = ( _tp - 2*_spread ) / _sl ;
         if( MathRand( ) < 32768. * ratio / 2  )         return( - _sl-2 );     /// fail
         else                                            return(   _tp-2 );     /// success   
 

It's taking a long time...

 
he hangs ))
 

changed it like this, also thinking

      double dealResultPips( )
      {
         double ratio = ( _tp - _spread ) / _sl ;
         if( MathRand( ) < 32768. * ratio / 2  )         return( - _sl-2 );     /// fail
         else                                            return(   _tp-2 );     /// success   
      }//+------------------------------------------------------------------+