← К каталогу
Исходный код · ID 3156

priceaction_scaner.mq5

Вы автор или правообладатель?

Сообщите нам, если считаете, что материал размещён без разрешения.

Краткий обзор

О программе

Индикатор для MetaTrader 5, предназначенный для поиска и отображения свечных паттернов Price Action на графике цен. Он анализирует исторические данные свечей и выявляет 11 типов ценовых паттернов, отображая их в виде прямоугольников на графике.

Продукт поддерживает различные типы паттернов: двойные и тройные дно/верх, рамки (Rails), перекрывающиеся объёмные бары (OVB), PPR, пин-бары (Pin-Bar) и бары широкого диапазона (WRB). Каждый паттерн может быть окрашен в отдельный цвет и настроен индивидуально.

Индикатор предоставляет широкие возможности настройки отображения: выбор количества анализируемых баров, управление наложением паттернов, стиль и толщина линий прямоугольников, а также цветовая дифференциация бычьих и медвежьих паттернов. Все параметры сгруппированы по категориям для удобства настройки.

Индикатор работает в рамках стандартного обработчика OnCalculate, пересчитывая данные при поступлении нового бара, и не содержит торговой логики.

Настройки программы

НастройкаОписание
A8 Разделитель группы общих настроек индикатора.
Number of History Bar to Display Patterns (indBarsCount) Количество баров истории для отображения паттернов.
Is Display Overlaped Paterns? (OverlapingPattern) Определяет, отображаются ли наложенные друг на друга паттерны.
Fill Rectangle by Color (FillRectangle) Определяет, заполняются ли прямоугольники паттернов цветом.
Rectangle Line Style (LineStyle) Стиль линий прямоугольников паттернов.
Rectangle Line Thickness (LineWidth) Толщина линий прямоугольников паттернов.
A1 Разделитель группы настроек для паттернов DBHLC и DBLHC.
Is Display DB Patterns? (showDBpattern) Включает или отключает отображение паттернов DB (Double Bottom/Top).
Valid diviation of Hi/Lo equal, point (equalPipsDB) Допустимое отклонение равенства максимумов или минимумов для паттернов DB, в пунктах.
Bull Rails Color (colorDBLHC) Цвет бычьего паттерна DB (Double Bottom).
Bear Rails Color (colorDBHLC) Цвет медвежьего паттерна DB (Double Bottom).
A2 Разделитель группы настроек для паттернов TBH и TBL.
Is Display TB Patterns? (showTBpattern) Включает или отключает отображение паттернов TB (Triple Bottom/Top).
Valid diviation of Hi/Lo to equal, point (equalPipsTB) Допустимое отклонение равенства максимумов или минимумов для паттернов TB, в пунктах.
Color TB Patterns (colorTB) Цвет паттернов TB (Triple Bottom/Top).
A3 Разделитель группы настроек для паттернов Rails.
Is Display Rails Pattern? (IsShowRailsPattern) Включает или отключает отображение паттернов Rails.
Max. Candles Body Ratio, % (bodyGreatPercents) Максимальный процент соотношения тела свечи к общему размеру для паттернов Rails.
Min. Ratio of Candles Body to It Height, % (bodyToHeightPercents) Минимальный процент соотношения тела свечи к её полной высоте для паттернов Rails.
Bull Rails Color (colorBullsRails) Цвет бычьего паттерна Rails.
Bear Rails Color (colorBearsRails) Цвет медвежьего паттерна Rails.
A4 Разделитель группы настроек для паттернов OVB.
Is Display OVB Pattern? (IsShowOVBPattern) Включает или отключает отображение паттернов OVB (Overlapping Volume Bar).
Bull OVB Color (colorBUOVB) Цвет бычьего паттерна OVB.
Bear OVB Color (colorBEOVB) Цвет медвежьего паттерна OVB.
A5 Разделитель группы настроек для паттернов PPR.
Is Display PPR Pattern? (IsShowPPRPattern) Включает или отключает отображение паттернов PPR.
Bull PRP Color (colorBullsPPR) Цвет бычьего паттерна PPR.
Bear PPR Color (colorBearsPPR) Цвет медвежьего паттерна PPR.
A6 Разделитель группы настроек для паттерна Pin-Bar.
Is Display Pin-Bar? (IsShowPINBARpattern) Включает или отключает отображение паттернов Pin-Bar.
Affinity Close Price to Candle Hi-Lo, point (closeToHighLowPoints) Допустимое отклоние цены закрытия от максимума или минимума свечи для паттерна Pin-Bar, в пунктах.
Minimum of Shadow to Body Candle Ratio (shadowToBodyKoef) Минимальный коэффициент соотношения тени к телу свечи для паттерна Pin-Bar.
Minimum Part of Shadow Outsiding for Previous Bar, % (noseOutsidePercent) Минимальная доля тени Pin-Bar, выходящая за пределы предыдущего бара, в процентах.
Bull Pin-Bar Color (colorBullsPINBAR) Цвет бычьего паттерна Pin-Bar.
Bear Pin-Bar Color (colorBearsPINBAR) Цвет медвежьего паттерна Pin-Bar.
A7 Разделитель группы настроек для паттернов WRB.
Is Display WRB Pattern? (IsShowWRBPattern) Включает или отключает отображение паттернов WRB (Wide Range Bar).
Ratio of Body 1 to 2 & 3 to 2 Candles, % (BodyRatio) Коэффициент соотношения тела первой свечи к телу второй и третьей свечей в паттерне WRB, в процентах.
Сlearence between Hi First & Lo Third Candles, % (HighLowClearance) Процентный зазор между максимумом первой и минимумом третьей свечей в паттерне WRB.
Bull WRB Color (colorBullsWRB) Цвет бычьего паттерна WRB.
Bear WRB Color (colorBearsWRB) Цвет медвежьего паттерна WRB.
Получить полный код

Поиск по коду файла

#property version "1.0"

#property description "Indicator looking for 11 сandle patterns of Price Action\n"
                      "Индикатор ищет 11 свечных паттернов Price Action" 

#property indicator_chart_window
#property strict
#define BULL_BAR        1
#define BEAR_BAR        -1
#define MODE_LOW 1
#define MODE_HIGH 2
#define FIRST_PART     "_1_"  

#define PREFIX         "PRACTION_"         
#define  ARRAY_RESERVE_SIZE      10                                                
enum ENUM_YESNO
  {
   NO,           
   YES           
  };
enum ENUM_STYLE
  {
   Solid,        
   Dash,         
   Dot,          
   DashDot,      
   DashDotDot    
  };
input string      A8="==== COMMON SETUP'S / ОБЩИЕ НАСТРОЙКИ ====";
input int         indBarsCount         = 1000;           //Number of History Bar to Display Patterns
input ENUM_YESNO  OverlapingPattern     = NO;            //Is Display Overlaped Paterns?
input ENUM_YESNO  FillRectangle        = YES;            //Fill Rectangle by Color
input ENUM_STYLE  LineStyle;                             //Rectangle Line Style
input int         LineWidth            = 1;              //Rectangle Line Thickness

input string      A1 = "======= DBHLC & DBLHC =======";
input ENUM_YESNO  showDBpattern = true;                  //Is Display DB Patterns?         
input int         equalPipsDB = 3;                       //Valid diviation of Hi/Lo equal, point           
input color       colorDBLHC = clrBlue;                  //Bull Rails Color    
input color       colorDBHLC = clrRed;                   //Bear Rails Color   
input string      A2 = "======= TBH & TBL =======";
input ENUM_YESNO  showTBpattern = true;                  //Is Display TB Patterns?     
input int         equalPipsTB = 3;                       //Valid diviation of Hi/Lo to equal, point         
input color       colorTB = clrGoldenrod;                //Color TB Patterns       
input string      A3="======= RAIL'S =======";
input ENUM_YESNO  IsShowRailsPattern   = YES;            //Is Display Rails Pattern?
input double      bodyGreatPercents    = 10;             //Max. Candles Body Ratio, %
input double      bodyToHeightPercents = 20;             //Min. Ratio of Candles Body to It Height, %
input color       colorBullsRails = clrDodgerBlue;       //Bull Rails Color
input color       colorBearsRails = clrFireBrick;        //Bear Rails Color
input string      A4="======= OVB  =======";
input ENUM_YESNO  IsShowOVBPattern     = YES;            //Is Display OVB Pattern?
input color       colorBUOVB = clrRoyalBlue;             //Bull OVB Color
input color       colorBEOVB = clrCrimson;               //Bear OVB Color
input string      A5="======= PPR  =======";
input ENUM_YESNO  IsShowPPRPattern     = YES;            //Is Display PPR Pattern?
input color       colorBullsPPR = clrDeepSkyBlue;        //Bull PRP Color
input color       colorBearsPPR = clrMediumVioletRed;    //Bear PPR Color
input string      A6="======= PIN_BAR  =======";
input bool        IsShowPINBARpattern = true;             //Is Display Pin-Bar?
input int         closeToHighLowPoints = 3;               //Affinity Close Price to Candle Hi-Lo, point
input double      shadowToBodyKoef = 3.0;                 //Minimum of Shadow to Body Candle Ratio
input double      noseOutsidePercent = 75.0;              //Minimum Part of Shadow Outsiding for Previous Bar, %
input color       colorBullsPINBAR = clrCadetBlue;        //Bull Pin-Bar Color
input color       colorBearsPINBAR = clrTomato;           //Bear Pin-Bar Color
input string      A7="======= WIDE RANGE BAR =======";
input ENUM_YESNO  IsShowWRBPattern  = YES;               //Is Display WRB Pattern?
input double      BodyRatio            = 1.5;            //Ratio of Body 1 to 2 & 3 to 2 Candles, %
input double      HighLowClearance     = 20;             //Сlearence between Hi First & Lo Third Candles, %
input color       colorBullsWRB = clrSkyBlue;            //Bull WRB Color
input color       colorBearsWRB = clrIndianRed;          //Bear WRB Color 

bool   g_isRussianLang,
       g_bIsActivate;
MqlRates rates[];
int ratesCnt = 0;
datetime BARflag  = 0;           //Для побарового режима

enum ENUM_PATTERN_TYPE
  {
   NONE_TYPE,      //0 - No pattern
   BULL_TYPE,     
   BEAR_TYPE,      
  };

enum ENUM_PATTEN_NAME
  {
   NONE_INDEX =-1, //No index
   DB_PATTERN_,
   TB_PATTERN_,
   RAILS_PATTERN_,
   OVB_PATTERN_,
   PPR_PATTERN_,
   PINBAR_PATTERN_,
   WRB_PATTERN_ 
  };

struct Pattern
  {
   ENUM_PATTERN_TYPE patternType;
   ENUM_PATTEN_NAME  patternName;
   datetime          leftTime;
   datetime          rightTime;
   double            patternLowPrice;
   double            patternHighPrice;
   color             patternColor;

                     Pattern()
     {
      Init();
     }

   void Init()
     {
      patternType      = NONE_TYPE;
      patternName      = NONE_INDEX;
      leftTime         = -1;
      rightTime        = -1;
      patternLowPrice  = 0.0;
      patternHighPrice = 0.0;
      patternColor     = clrNONE;
     }
  };
Pattern           g_patterns[];     //Pattern Array

int OnInit()
{
      // код доступен только после оплаты
   }

void OnDeinit(const int reason)
{
   ArrayResize(rates,0);
   ObjectsDeleteAll(0, PREFIX);
   Comment("");
}

bool IsTuningParametersCorrect()
{
   g_isRussianLang=(TerminalInfoString(TERMINAL_LANGUAGE)=="Russian");

   return(true);
}

int GetRecalcIndex(int& total, const int ratesTotal, const int prevCalculated)
{
   total = ratesTotal-4;                                                                         

   if (indBarsCount > 0 && indBarsCount < total)
      total = MathMin(indBarsCount, total);                      

   if (prevCalculated < ratesTotal - 1)                     
    {       
      ObjectsDeleteAll(0, PREFIX);
      ArrayResize(g_patterns,0);
      return (total);
    }

   return (MathMin(ratesTotal - prevCalculated, total));                            
}

ENUM_TIMEFRAMES TFMigrate(int tf)
{
   switch(tf)
   {
      case 0: return(PERIOD_CURRENT);
      case 1: return(PERIOD_M1);
      case 5: return(PERIOD_M5);
      case 15: return(PERIOD_M15);
      case 30: return(PERIOD_M30);
      case 60: return(PERIOD_H1);
      case 240: return(PERIOD_H4);
      case 1440: return(PERIOD_D1);
      case 10080: return(PERIOD_W1);
      case 43200: return(PERIOD_MN1);

      case 2: return(PERIOD_M2);
      case 3: return(PERIOD_M3);
      case 4: return(PERIOD_M4);      
      case 6: return(PERIOD_M6);
      case 10: return(PERIOD_M10);
      case 12: return(PERIOD_M12);
      case 16385: return(PERIOD_H1);
      case 16386: return(PERIOD_H2);
      case 16387: return(PERIOD_H3);
      case 16388: return(PERIOD_H4);
      case 16390: return(PERIOD_H6);
      case 16392: return(PERIOD_H8);
      case 16396: return(PERIOD_H12);
      case 16408: return(PERIOD_D1);
      case 32769: return(PERIOD_W1);
      case 49153: return(PERIOD_MN1);      

      default: return(PERIOD_CURRENT);
   }
}
int iLowest_(string symbol, int tf, int type=MODE_LOW, int count=WHOLE_ARRAY, int start=0)
{
   if(start <0) return(-1);
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);

   if(count==0) count=Bars(symbol,timeframe);   

   if(type==MODE_LOW)
   {         
      double Arr[];
      if(CopyLow(symbol,timeframe,start,count,Arr)>0)  
         return((count-ArrayMinimum(Arr)-1)+start);
      else return(-1);
   }
  else return(-1);
}
int iHighest_(string symbol, int tf, int type=MODE_HIGH, int count=WHOLE_ARRAY, int start=0)
{
   if(start <0) return(-1);
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);

   if(count==0) count=Bars(symbol,timeframe);

   if(type==MODE_HIGH)
   {
      double ArrMH[];
      if(CopyHigh(symbol,timeframe,start,count,ArrMH)>0)  
         return((count-ArrayMaximum(ArrMH)-1)+start);
      else return(-1);
   } 
   else return(-1);
}

void ShowRectangle(string name,datetime time1,double price1,datetime time2,
                   double price2,string toolTip, color clr)
{
   if(ObjectFind(0,name)<0)                         
     {
      ObjectCreate(0,name,OBJ_RECTANGLE,0,time1,price1,time2,price2);
      ObjectSetInteger(0,name,OBJPROP_SELECTABLE,false);
      ObjectSetInteger(0,name,OBJPROP_HIDDEN,true);
      ObjectSetInteger(0,name,OBJPROP_WIDTH,LineWidth);
      ObjectSetInteger(0,name,OBJPROP_STYLE,LineStyle);
      ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
      ObjectSetInteger(0,name,OBJPROP_BACK,FillRectangle);
      ObjectSetInteger(0,name,OBJPROP_FILL,FillRectangle);
      ObjectSetString(0,name,OBJPROP_TOOLTIP,toolTip);
      return;
    }
}

int PD(double greater, double less)
{
   return(int)MathRound((greater - less)/_Point);
}

bool IsBullsPINBAR(int index)
{
   if (rates[index].open < rates[index+1].low) 
      return(false);

   if (rates[index].close < rates[index+1].low)
      return(false); 

   if (rates[index].low >= rates[index+1].low)
      return(false);

   if (PD(rates[index].high, rates[index].close) > closeToHighLowPoints)
      return(false);                               

   double shadow = MathMin(rates[index].open, rates[index].close) - rates[index].low;
   double body = MathAbs(rates[index].open - rates[index].close);
   if (body == 0)
      body = _Point;
   if (shadow/body < shadowToBodyKoef)
       return(false);

   double noseOutside = rates[index+1].low - rates[index].low;
   if (noseOutside/shadow < noseOutsidePercent/100)
      return(false);

   return (true);
}

bool IsBearsPINBAR(int index)
{
   if (rates[index].open > rates[index+1].high)
      return(false);

   if (rates[index].close > rates[index+1].high)
      return(false);

   if (rates[index].high <= rates[index+1].high)
      return(false);

   if (PD(rates[index].close, rates[index].low) > closeToHighLowPoints)
      return(false);

   double shadow = rates[index].high - MathMax(rates[index].open, rates[index].close);
   double body = MathAbs(rates[index].open - rates[index].close);
   if (body == 0)
      body = _Point;
   if (shadow/body < shadowToBodyKoef)
       return(false);

   double noseOutside = rates[index].high - rates[index+1].high;
   if (noseOutside/shadow < noseOutsidePercent/100)
      return(false);

   return (true);
}

bool IsRails(int index,double body1,double body2)
{
   if(body1<=0)
      return(false);

   if(body2<=0)
      return(false);

   double height1=rates[index].high-rates[index].low;
   if(body1/height1<bodyToHeightPercents/100)
      return(false);

   double height2=rates[index+1].high-rates[index+1].low;
   if(body2/height2<bodyToHeightPercents/100)
      return(false);

   double ratio=100*(1-MathMin(body1,body2)/MathMax(body1,body2));
   if(ratio>bodyGreatPercents)
      return(false);

   return(true);
}

bool IsBullsRailsPattern(int index)
{
   double body1 = rates[index].close - rates[index].open;
   double body2 = rates[index+1].open - rates[index+1].close;

   return(IsRails(index,body1,body2));
}

bool IsBearsRailsPattern(int index)
{
   double body1 = rates[index].open - rates[index].close;
   double body2 = rates[index+1].close - rates[index+1].open;

   return(IsRails(index,body1,body2));
}

bool IsOVBPattern(int index,int type)
{
   if(rates[index].high < rates[index+1].high)
      return(false);

   if(rates[index].low > rates[index+1].low)
      return(false);

   double body1 = rates[index].close - rates[index].open;
   double body2 = rates[index+1].close - rates[index+1].open;

   return ((body1 > 0 && type == BULL_BAR) ||
           (body1 < 0 && type == BEAR_BAR));

}

bool IsBUOVBPattern(int index)
{
   if(rates[index].close <= rates[index+1].high)
      return(false);

   return(IsOVBPattern(index,BULL_BAR));
}

bool IsBEOVBPattern(int index)
{
   if(rates[index].close >= rates[index+1].low)
      return(false);

   return(IsOVBPattern(index,BEAR_BAR))

Показано первые 50% кода (символов: 16982)

Открыть по тарифу

Купите тариф с пакетом открытий или войдите, если тариф уже есть. Открытый файл останется в вашем кабинете навсегда.

Разовая покупка файла

На этой странице откроется полный исходный код файла вместо ознакомительного фрагмента.

Чтобы оформить заказ, введите email и перейдите к оплате.

Стоимость полного кода
1 698,20₽ ≈ $20.76