    MetaTrader 5.       MQL5  Python.  3-,   
 


       MetaQuotes Language 5 (MQL5)   ,                MetaTrader 5.   MQL5 ,    ,   - .         ,      MQL5      ,    .       .                   Python   .





 

    MetaTrader 5.       MQL5  Python.  3-,   





 


           https://github.com/novts/MetaTrader-5-Creating-Trading-Robots-and-Indicators-with-MQL5







,      MQL5   https://www.mql5.com/ru/docs.








      ,      .         .

     :

        MQL5-     .

   : ,  , ,    .

     ,     ,       .

     ,           .

           .       MQL5,  , , ,      .

      MQL5     - ,     MQL5-             .

           ,  - .      .




 


    - ,                MQL5 .








       ,  ,   ,                           .

,   ?

   .

  ,       ,   ,      .

         .

   ?

FOREX       Foreign Exchange,    .

    ,     ,           -  .

      ,  ,  ,   ,  ,  ,    . .

,                     - .

      .      1    ,   5  10  .

       -   ,   ,   -   .

        ,     .

     ?

 , ,  ,       ,      (    ),            ,     .

       ,               .

        ,      .

    ,  ,        ,      ,      , ,  .

    Forex          .

       ,  ,   .

        ,      (),     ,      ,      .

      ,  ,       .

         (Reuters, Bloomberg, Dow Jones  .),     ,      .

 ,     ,      ,      .

 ,      ,    ,      .

     ,        ,        ,   ,    .

   ,            1-2 ,      ,         - , ,               .

,     ?

     ,               .

 ,     ,       , ,  , ,     .

,  ,                 .

    ,          ,     ,   .         ,    .

  ,  ,              ,   ,    ,      . ,       .

        ,    .

   ,    - ,                MQL5 .

      ,     ,          - ,      .








 , ,   Forex Club.

     ,     .

    , , - .








   -   MetaTrader 5.

Forex Club    :

  (Instant Execution)

         .     ,       .

    (Market Execution)

                 .

      (Instant Execution).








     MetaTrader 5.








    Forex Club,      .

,          ,    ,   .








  MetaTrader 5      Forex,    .

  MetaTrader 5      ,         .








    MetaTrader 5         .

     ,           ,     .








   MetaTrader 5,    MQL5,       ,      MetaTrader 5.

MetaEditor       ,    MetaTrader.

  MetaEditor    ,  , ,      .








  MetaEditor    ,      .

     .




  


       MetaEditor.








          .

 ,    ,     ,          .








      .

          ,  ,     ,  ,  ,    , .

       MetaTrader 5       .

    ,    ,     ,       ,      ,   ,    ,     .

         OnInit(), OnDeinit(), OnCalculate()  OnChartEvent().

  OnInit() ,  ,         ,    ,   ,    ,       .  ,   OnInit()            .

  OnDeinit() ,  ,       ,       .

  OnCalculate()      ,       ,    OnInit()      ,        .  ,   OnCalculate()         .

  OnChartEvent()   ,     ,          ,      .

    ,        ,       OnInit(), OnDeinit(), OnCalculate()  OnChartEvent().








       ,        .








        ,         .




 


     .








  :

  (#property).   mql5-      #property,            .        . ,    ,  .      mq5-: #property  .

       #include,       .

       .        , ,       .     ,   , -       .

       ,    ,      #include   .         <_>\MQL5\Include,      #include   .

    ,  ,   , :

#property copyright

     :

#property link

    ,        description, :

#property description "Average Directional Movement Index"

   :

#property version "1.00"

 ,  ,     .

                  .

:

#property indicator_chart_window

     .

 :

#property indicator_separate_window

     .

            , :

#property indicator_buffers 6

                .

       ,  .

,   ADX:

#property indicator_plots 3

     ()    +DI,   DI    ADX.

       ,     .

,   ADX:

#property indicator_type1 DRAW_LINE

#property indicator_type2 DRAW_LINE

#property indicator_type3 DRAW_LINE

 ,    ADX   .

          ,   indicator_type.

       indicator_colorN.

,   ADX:

#property indicator_color1 LightSeaGreen

#property indicator_color2 YellowGreen

#property indicator_color3 Wheat

         ,   indicator_color.








  MQL5   Web-     .








       .

            ,        ,      .

   ,    ,   ,      .

      OnInit()     SetIndexBuffer.

,   ADX:

SetIndexBuffer(0,ExtADXBuffer);

SetIndexBuffer(1,ExtPDIBuffer);

SetIndexBuffer(2,ExtNDIBuffer);

  ,    .

 ,     ,        .

      .

     ,     .

  ?

 ,   ,   ,      ,    .

,   ADX:

SetIndexBuffer(3,ExtPDBuffer,INDICATOR_CALCULATIONS);

SetIndexBuffer(4,ExtNDBuffer,INDICATOR_CALCULATIONS);

SetIndexBuffer(5,ExtTmpBuffer,INDICATOR_CALCULATIONS);

       INDICATOR_CALCULATIONS.

  :

     .

 ,    SetIndexBuffer,  , ..    ,          SetIndexBuffer,      ,       .

     ADX.








  MQL5,   Navigator (),   Indicators->Examples       ADX.

  OnInit()  :

// SetIndexBuffer(5,ExtTmpBuffer,INDICATOR_CALCULATIONS);

  ExtTmpBuffer    .

          MetaTrader 5.








    .

array out of range

  ,                 .

      ,      - .

       , ..      ,            OnCalculate      OnCalculate  ,    open[], high[], low[],  close[].

    open[], high[], low[],  close[] ,     rates_total.








,      OnCalculate   ArrayResize,    :

ArrayResize(ExtTmpBuffer,rates_total);

       rates_total     ,    .

      .

   ,    OnCalculate        , ..  rates_total ,         ,     OnCalculate,                   .

     ,             .

  ,            SetIndexBuffer       .








  ,          CopyBuffer,         .

 CopyBuffer        .

    ,         INDICATOR_CALCULATIONS .

         ,  CopyBuffer      1,           -,         .       ArrayResize      .








   ,              ?

-,   ,         , :

#property indicator_type1 DRAW_COLOR_LINE

      COLOR.

   #property indicator_buffers           .








 SetIndexBuffer        , :

SetIndexBuffer(1,ExtColorsBuffer,INDICATOR_COLOR_INDEX);

  #property indicator_color,   ,   , :

#property indicator_color1 Red,Green,Blue








, ,   ,    ,   ,    #property indicator_color.

  ,  0, 1  2.

    ,     ,         ,     .








  #property indicator_color,       :

         :

PlotIndexSetInteger(0,PLOT_COLOR_INDEXES,3);

        :

PlotIndexSetInteger(0,PLOT_LINE_COLOR,0,Red);

      ,       0.

  :

#property indicator_color1 Red,Green,Blue








    .

      indicator_widthN,  N    , :

#property indicator_width1 1

         , , , -,      indicator_styleN,  N    , :

#property indicator_style1 STYLE_SOLID

, ,  indicator_labelN      DataWindow   , :

#property indicator_label1 "ADX"

#property indicator_label2 "+DI"

#property indicator_label3 "-DI"








      .

      ,         , :








#property indicator_level1 30.0

#property indicator_levelcolor Red

#property indicator_levelstyle STYLE_SOLID

#property indicator_levelwidth 2

        ADX,     .








,    ADX,       MetaTrader 5, -,    ,        copyright, link  description.








       indicator_label, indicator_color, indicator_width, indicator_style.

       .

  ,           ,    ,          .








        Navigator   ,   copyright.








   :

#property indicator_label1 "ADX"

  ,     OnInit()    :

string short_name="ADX("+string(ExtADXPeriod)+")";

IndicatorSetString(INDICATOR_SHORTNAME,short_name);

    ADX(14)   .








  :

PlotIndexSetString(0,PLOT_LABEL,short_name);

      ,      .

  :

#property indicator_label2 "+DI"

#property indicator_label3 "-DI"

,    ,            .








   ADX     ,    .

 indicator_buffers  6

  indicator_plots  3

   ,        .

  ExtPDBuffer, ExtNDBuffer  ExtTmpBuffer.

  OnCalculate ,   ExtPDBuffer, ExtNDBuffer, ExtTmpBuffer      ,          ExtADXBuffer, ExtPDIBuffer, ExtNDIBuffer,      .

   ,          INDICATOR_CALCULATIONS,        .








,    ADX , :

    ,  +DI    DI     ADX .

 ,  +DI    DI,   ADX  ,     ,       .

    ,  +DI    DI    ADX .

 ,  +DI    DI,   ADX  ,     ,       .

,    ADX  ,    ADX   ,       .








      indicator_type1  DRAW_COLOR_LINE.

      indicator_buffers   7.

     ExtColorsBuffer.








   OnInit()          SetIndexBuffer.

             .

, ,   ExtColorsBuffer     6,      .








  indicator_color1  .

       indicator_width1.








  OnCalculate       for          .








            :








  MQL5      Examples  RSI.

     ,      .

       :

#property indicator_level1 30

#property indicator_level2 70

    ,     .








   :

#property indicator_levelcolor Red

#property indicator_levelstyle STYLE_SOLID

#property indicator_levelwidth 1

     .











    


      ,              .








,   MACD         .

       ,         .

          ,          .








      input    input,     .  , input      .

,   MACD    

       ,        ,           ,    .

   ,            ,    .

  ,     .








    .

  , ,  ,    ,      .

  ,         ,   ,      .








  MACD    ENUM_APPLIED_PRICE,       .

    .








    #property script_show_inputs   ,     .

  input        ,           .

        ,    .








,          ,    .








 input  MQL5-   ,  ,    extern .








      ,     , ,    ,   , ,    , ,       , .

   ,    ,     new,        delete   .

 ,  ,    ,      ,  .

      ,           ,       ,    .

 ,  input       ,              .

        const              .

    static,     .

     ,     ,        .

 ,  ,   ,    ,      .

 ,       static.

  ,    , ,    ,  .        ,      .

           ,     .

extern      .       extern.

 extern           MACD.








 MACD    MovingAverages,     #include     Include.

   MovingAverages   MACD   extern-:

extern int a=0;

       ,     .

    MovingAverages   MACD     :

static int a=0;

      .








  #include     #define,       , :








#define PI 3.14




 


  :

HANDLE  ,    .   "Windows  ".








  handle             ,    .

 ,    ,         .

      int  ,  ,     ,    ,    MACD:








    int ExtFastMaHandle  int ExtSlowMaHandle.

             12  26.

  , , ,    ,    ,     ,   .

                 .

   ,               .








        iMA.

   MACD          iMA   OnInit().








     InpFastEMA, InpSlowEMA  InpAppliedPrice.

,      ,   .








  Indicators/Examples  MQL5        Custom Moving Average.mq5.

      iCustom.








  OnInit()  MACD  ,       ,   iCustom.








    ,      .








      ,    IndicatorCreate.








  OnInit()  MACD  ,       IndicatorCreate.








     ,      .

   ,       ,       IndicatorRelease.








        .

,    .      ?

    OnCalculate    CopyBuffer.








   CopyBuffer()        .

,   ,       .

       ,       ,       ,    .

  MACD   .








  ExtFastMaBuffer  ExtSlowMaBuffer        SetIndexBuffer.








        Moving Average        CopyBuffer.








    ExtFastMaBuffer  ExtSlowMaBuffer   ,     .

  ,      to_copy    ,   to_copy=1       ExtFastMaBuffer  ExtSlowMaBuffer,       1.

     ArrayResize   ,    CopyBuffer        1.

, ,    -,     .     -     ,   , ,       .




 OnInit


  ,  OnInit(), OnDeinit(), OnCalculate()       .








 OnInit()           .

         ,   ,     ,      .

       .

   ,          SetIndexBuffer.








 data_type   INDICATOR_DATA (   ,  ,   ), INDICATOR_COLOR_INDEX ( ), INDICATOR_CALCULATIONS (   ).

   SetIndexBuffer   ,       ,    .

    INDICATOR_COLOR_INDEX     INDICATOR_DATA,      INDICATOR_COLOR_INDEX       INDICATOR_DATA.

    INDICATOR_COLOR_INDEX,   ,    #property indicator_colorN     .

   INDICATOR_COLOR_INDEX       INDICATOR_DATA.

                , ..     0      .       ArraySetAsSeries.








   ArraySetAsSeries      ,  , ,   ,         .

 ArraySetAsSeries                .

  OnInit()        ,      ,  .

         ,         .

,   ADX   :








 ExtADXPeriod   ,  InpPeriodADX   .

   ,    ( ),     .

      .

  OnInit()        .








,    MACD    :

input string symbol=" ";

  :

string name=symbol;

   OnInit()            StringTrimRight,       name ,    ,    .








        IndicatorSetDouble, IndicatorSetInteger, IndicatorSetString, PlotIndexSetDouble, PlotIndexSetInteger, PlotIndexSetString.








 IndicatorSetDouble         indicator_minimum, indicator_maximum  indicator_levelN, :

IndicatorSetDouble(INDICATOR_LEVELVALUE, 0, 50)

 :

property indicator_level1 50








 IndicatorSetInteger         indicator_height, indicator_levelcolor, indicator_levelwidth, indicator_levelstyle.

       ,   IndicatorSetInteger. ,   RSI    .








 ,   ,   ,   IndicatorSetInteger.

 IndicatorSetInteger     , :

IndicatorSetInteger(INDICATOR_DIGITS,2);

          .

  IndicatorSetString      property.








   IndicatorSetString     ,    MACD:








   .

         :

MACD (12, 26, 9)

 ,  IndicatorSetString      ,    RSI:








     Oversold  Overbought.








   PlotIndexSetDouble ,             .

            ,   .  ,     "",       PLOT_EMPTY_VALUE. ,       ,           :

PlotIndexSetDouble(_,PLOT_EMPTY_VALUE,0);








 PlotIndexSetInteger   , ,     ,      DRAW_ARROW,       DRAW_ARROW,          ,   ,       ,         ,   ,   ,  ,  ,   .

           Custom Moving Average.




  .


   .

   ,     (https://www.litres.ru/pages/biblio_book/?art=68635601)  .

      Visa, MasterCard, Maestro,    ,   ,     ,  PayPal, WebMoney, ., QIWI ,       .


