Buy stop Sell stop Grid advisor as a class - page 4

 
Vladimir Karputov:

For step 35, extended totals:

Direction_of_trades_EURUSD_35

Here we can see that

  • practically 50% of all cases are when the length of uninterrupted trades equals "1". So we have situations of the following type: we opened Buy and then reversed the position (i.e. closed Buy with a loss and opened Sell) or this situation: we opened Sell and then reversed the position (i.e. closed Sell with a loss and opened Buy). Thus situations with uninterrupted trades of length "1" are a guaranteed loss.
  • Approximately 25% of all cases with the length of uninterrupted trades equaling "2", by the following example: we opened Buy, then opened another Buy and reversed the position (i.e. closed two Buy and opened Sell - resulting in a loss equal to zero).

I think these most numerous categories (length of uninterrupted trades equal to "1" and "2") must be thought over in more detail in order to correct the strategy of placing Stop pending orders.


Let us check the pyramiding idea (in case we open a position in the direction of the previous one):

1. Variant of increasing the lot size in geometric progression

A geometric progression is a sequence of numbersb1, b2, b3,... (Members of progression) in which each subsequent number starting from the second, is obtained from the previous one by multiplying it by a certain number q(denominator of progression), where b1!=0, q!=0: b1, b2=b1*q, b3=b2*q.

2. Variant of the lot increase in the arithmetic progression

Arithmetic progression (algebraic) is a sequence of numbers (members of progression) in which each number starting with the second is obtained from the previous one by adding to it a constant number d (step, or difference of progression).

 

With the introduction of the two regression types, it becomes necessary to check the calculated lot size. The LotCheck function will be used for this purpose. Example of using this function in the script:

//+------------------------------------------------------------------+
//|                                                     LotCheck.mq5 |
//|                              Copyright © 2017, Vladimir Karputov |
//|                                           http://wmua.ru/slesar/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2017, Vladimir Karputov"
#property link      "http://wmua.ru/slesar/"
#property version   "1.000"
#property description "Checking the volume of the lot"
#property script_show_inputs
//---
input double start_lot  = 0.85;
input double step_lot   = 0.354;
#include <Trade\SymbolInfo.mqh>  
CSymbolInfo    m_symbol;                     // symbol info object
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
   m_symbol.Name(Symbol());
   m_symbol.Refresh();
//---
   Comment("");
   Comment(StringFormat("Symbol %s. Lots Min: %.2f, Lots Max: %.2f, Lots Step %.2f",
           m_symbol.Name(),m_symbol.LotsMin(),m_symbol.LotsMax(),m_symbol.LotsStep()));
//---
   double ext_start_lot = start_lot;
   double ext_step_lot  = step_lot;
//---
   for(int i=0;i<21;i++)
     {
      Comment(ChartGetString(0,CHART_COMMENT),"\n",
              "Input lot ",ext_start_lot,", lot check: ",DoubleToString(LotCheck(ext_start_lot),2));
      ext_start_lot+=ext_step_lot;
     }
  }
//+------------------------------------------------------------------+
//| Lot Check                                                        |
//+------------------------------------------------------------------+
double LotCheck(double lots)
  {
//--- calculate maximum volume
   double volume=NormalizeDouble(lots,2);
   double stepvol=m_symbol.LotsStep();
   if(stepvol>0.0)
      volume=stepvol*MathFloor(volume/stepvol);
//---
   double minvol=m_symbol.LotsMin();
   if(volume<minvol)
      volume=0.0;
//---
   double maxvol=m_symbol.LotsMax();
   if(volume>maxvol)
      volume=maxvol;
   return(volume);
  }
//+------------------------------------------------------------------+

In order not to litter the terminal log, the whole output is organized on the chart:

LotCheck

Files:
LotCheck.mq5  5 kb
 

Geometric and arithmetic professions have been added to the EA class. Implemented lot calculation (for now) for geometric progression.

//+------------------------------------------------------------------+
//| 1.001:                                                           |
//|   when starting, sets Buy stop and sell stop                     |
//| 1.002:                                                           |
//|   OnTradeTransaction: if DEAL_ENTRY_IN delete all pending orders,|
//|   and, sets Buy stop and sell stop                               |
//| 1.003:                                                           |
//|   OnTradeTransaction: DEAL_ENTRY_IN                              |
//|      DEAL_TYPE_BUY => ClosePositions(POSITION_TYPE_SELL)         |
//|      DEAL_TYPE_SELL => ClosePositions(POSITION_TYPE_BUY)         |
//|   PlacesXXXX:                                                    |
//|      "RefreshRates()" is now inside the "PlacesXXXX"             |
//|   OnTradeTransaction:                                            |
//|      a "while" loop for "PlacesXXXX"                             |
//| 1.004:                                                           |
//|   add OnTester and save csv file                                 |
//| 1.005:                                                           |
//|   add Geometric and arithmetic progression                       |
//|      only a geometric progression is realized                    |
//+------------------------------------------------------------------+

ds

 

Comparison of trading(EURUSD symbol, step 35) with a regular lot and with geometric progression:

Buy stop Sell stop Grid advisor as a class: regular lot

Fig. 1: An Expert Advisor Buy stop Sell stop Grid as a class: a regular lot


Buy stop Sell stop Grid advisor as a class: lot in geometric progression

Fig. 2. an Expert Advisor Buy stop Sell stop Grid as a class: geometric progression lot


Buy stop Sell stop Grid advisor as a class: lot in arithmetic progression

Fig. 3: Classifier of the Buy stop Sell stop Grid Expert Advisor: arithmetic progressive lot


Let's put it this way: "Increasing lots in geometric progression or arithmetic progression when holding positions in one direction is worse than trading with a constant lot".

 

Something I have when trying to update data from Storage it writes:

2017.10.03 12:59:10.146 Storage failed to read http data (storage.mql5.com:443 read failed [12152])

In general, my work with Storage doesn't work at all... Something I'm doing wrong...
 
George Merts:

I get a message when I try to update data from the Warehouse:

2017.10.03 12:59:10.146 Storage failed to read http data (storage.mql5.com:443 read failed [12152])

In general, my work with Storage doesn't work at all... Something I'm doing wrong...

Let's Skype and then post a solution to the Storage problem here ...

 
Vladimir Karputov:

Let's Skype and then post the solution to the Warehouse problem here ...

No problem. Emailed it to you in person.

 

So.

I have Windows7 x64, account control is disabled. I have to connect to the Warehouse every time I log in to the meta-editor.


 

Vladimir, please add me to the project as well. Thank you

Reason: