Analyse the most important STATISTICAL characteristics of the pattern and choose a method of trading on it.

 

Let's say we have a piece of a chart. We need to work out (on the history) the best way to open deals on it. Where to buy, where to sell, where to buy more, where to close, and so on. But we must consider that the patterns may be different, and we must find the most effective method of calculating the position opening places for any pattern, while minimizing the risks. There can be several deals in a pattern. There is one more important condition, the pattern may vary within a certain range, say 20%. That is, at the beginning we see one pattern and on the next bar it will change somewhat, though its basic characteristics remain the same (but we will always see the whole pattern and all its future changes). That is, we need to introduce some other error factor.

Do you have any idea how best to do this? Various probabilities and price levels can be calculated, how can this be done?

 

We can start from the opposite direction:

  • we set the condition of how many points we have to take for a given number of bars
  • then search for such places
  • after the "fish" spots are found, analyze what combination of bars (pattern) was before the "fish" spot.

 
Maxim Dmitrievsky:

Any ideas on how best to do this? Different probabilities and price levels can be calculated, how can this be done?

It is possible, it is in the field of recognition of graphical images (machine vision)
 
Maybe here is what you are looking for.
Как искать паттерны в биржевых данных и использовать их в торговле?
Как искать паттерны в биржевых данных и использовать их в торговле?
  • habrahabr.ru
Сегодня предлагаю поразмышлять о том, как искать паттерны в биржевых данных и как их использовать для успешной торговли. Будем получать биржевые данные Forex от одного из брокеров, сохраним в базу данных PostgreSQL и попробуем найти закономерности при помощи алгоритмов машинного обучения. В статье есть несколько приятных бонусов в виде кода...
 
Rafael Sahibgareev:
Maybe this article has what you're looking for.
The article is nothing, but it leaves an awful aftertaste for MQL5 - it's impossible to make a useless, albeit feebly , study in MQL5.
 
Vladimir Karputov:

We can start from the opposite direction:

  • we set the condition of how many points we have to take for a given number of bars
  • then search for such places
  • after the "fish" spots are found, analyze what combination of bars (pattern) was before the "fish" spot.


Basically, yes, but profit probability will not be taken into account when the pattern goes this or that way. It is desirable to introduce these risks from the very beginning, and not to correct them in process.
 

So you want to cluster the patterns as well (calculate) ....

 
Maxim Dmitrievsky:

In principle, yes, but it will not take into account the probability of profit when the pattern moves in one direction or another

What do you mean? First of all we look for the "fish place". The second stage is analyzing the state of bars before the "fish place".
 
Igor Yeremenko:
You can, it's in the field of image recognition (machine vision).

It will take time to attach it to mql... And I'm not interested in predicting, but in searching for the best inputs and outputs
 
Vladimir Karputov:

What do you mean? After all, a 'fish place' is looked for first. The second step is to analyze the state of the bars before the fish spot.

I wanted to assign some probabilistic estimations to the patterns and their sub-waves, it seemed to me that just looking for n-point plots is too primitive. We need to describe the pattern statistically, but I haven't figured out how
 
Maxim Dmitrievsky:

I wanted to assign some probabilistic estimations to the patterns and their sub-waves. It's necessary to describe the pattern statistically, I haven't figured out how.


One should go step by step. At first, just find candles of a certain size. Visually see what we got:

Search of a pattern, version "1.000"

//+------------------------------------------------------------------+
//|                                          Search of a pattern.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 "Индикатор поиска свечей с заданным размером тела" 
#property description "Найденные свечи отмечаются символами из набора Wingdings" 

#property indicator_chart_window 
#property indicator_buffers 2 
#property indicator_plots   2 
//--- plot Arrows 
#property  indicator_label1  "Bull candle" 
#property  indicator_type1   DRAW_ARROW 
#property  indicator_color1  clrBlue 
#property  indicator_width1  1 
#property  indicator_label2  "Bear candle" 
#property  indicator_type2   DRAW_ARROW 
#property  indicator_color2  clrRed
#property  indicator_width2  1 
//--- input параметры
sinput string  __1__             = "";          // Параметр тела свечи
input ushort   min_size_candel   = 15;          // Минимальный размер тела свечи ()
input ushort   bull_code         = 226;         // Код символа бычьего бара(32-255)
input ushort   bear_code         = 225;         // Код символа медвежьего бара(32-255)
sinput string  __2__             = "";          // Параметр смещения
input uchar    vertical_shift    = 15;          // Смещение стрелок по вертикали (0-255)
//--- индикаторные буфера для построения  
double         BufferBull[];
double         BufferBear[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping 
   SetIndexBuffer(0,BufferBull,INDICATOR_DATA);
   SetIndexBuffer(1,BufferBear,INDICATOR_DATA);
//--- зададим код символа для отрисовки в PLOT_ARROW 
   PlotIndexSetInteger(0,PLOT_ARROW,bull_code);
   PlotIndexSetInteger(1,PLOT_ARROW,bear_code);
//--- зададим cмещение стрелок по вертикали в пикселях  
   PlotIndexSetInteger(0,PLOT_ARROW_SHIFT,-(int)vertical_shift);
   PlotIndexSetInteger(1,PLOT_ARROW_SHIFT,(int)vertical_shift);
//--- установим в качестве пустого значения 0 
   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0);
   PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,0);
//--- 
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   static datetime prev_time=0;
//--- работаем только в момент рождения нового бара, внутри бара не работаем
   if(prev_time==time[rates_total-1])
      return(rates_total);
//--- на новом баре запоминает время его рождения
   prev_time=time[rates_total-1];
//--- блок расчета значений индикатора 
   int start=1;
   if(prev_calculated>0)
      start=prev_calculated;
//--- цикл расчета 
   for(int i=start;i<rates_total;i++)
     {
      //--- если предыдущая свеча имеет тело больше минимального
      if(MathAbs(open[i-1]-close[i-1])/Point()>min_size_candel)
        {
         if(open[i-1]<close[i-1])
            BufferBull[i-1]=high[i-1];
         if(open[i-1]>close[i-1])
            BufferBear[i-1]=low[i-1];
        }
     }
//--- return value of prev_calculated for next call 
   return(rates_total);
  }
//+------------------------------------------------------------------+

MetaTrader Trading Platform Screenshots

EURUSD, M5, 2017.04.02

MetaQuotes Software Corp., MetaTrader 5, Demo

Search of a pattern, version "1.000".

EURUSD, M5, 2017.04.02, MetaQuotes Software Corp.


Files:
Reason: