Interceptor

Author: Sergey
Price Data Components
Series array that contains tick volumes of each bar
Indicators Used
Stochastic oscillatorMoving average indicator
Miscellaneous
It opens Message Boxes to the user
0 Views
0 Downloads
0 Favorites
Interceptor
ÿþ//+------------------------------------------------------------------+

//|                         Interceptor(barabashkakvn's edition).mq5 |

//|                                                           Sergey |

//|                                                mserega@yandex.ru |

//+------------------------------------------------------------------+

#property copyright "Sergey"

#property link      "mserega@yandex.ru"

#property version   "1.001"

//---

#define MODE_LOW 1

#define MODE_HIGH 2

//---

#include <Trade\PositionInfo.mqh>

#include <Trade\Trade.mqh>

#include <Trade\SymbolInfo.mqh>  

#include <Trade\AccountInfo.mqh>

#include <Trade\DealInfo.mqh>

#include <Trade\OrderInfo.mqh>

#include <Expert\Money\MoneyFixedMargin.mqh>

CPositionInfo  m_position;                   // trade position object

CTrade         m_trade;                      // trading object

CSymbolInfo    m_symbol;                     // symbol info object

CAccountInfo   m_account;                    // account info wrapper

CDealInfo      m_deal;                       // deals object

COrderInfo     m_order;                      // pending orders object

CMoneyFixedMargin *m_money;

//--- input parameters

input double   OrdinaryLot                   = 0.01;  // ;>B ?@8 >1KG=>< >B:@KB88 ?>78F88 (5A;8 =5B A>2?045=8O A83=0;>2)

input double   CoefFlatnessM5                = 0.35;  // :>MDD8F85=B D;5B0 =0 5 (:>;8G5AB2> ?C=:B>2 =0 1 10@)

input int      StopLoss                      = 500;   // =0G0;L=K9 AB>? ;>AA  (5A;8 <5=LH5 100, B> AB>? ;>AA =5 AB028BAO)

input int      TakeProfit                    = 0;     // B59: ?@>D8B (5A;8 <5=LH5 100, B> B59: ?@>D8B =5 AB028BAO)

input int      TakeProfitAfterBreakeven      = 0;     // <8=8<0;L=0O ?@81K;L 2 ?C=:B0E ?>A;5 ?5@52>40 2 157C1KB>:

input int      StopLossAfterBreakeven        = 450;   // AB>?-;>AA ?>A;5 ?5@52>40 2 157C1KB>: (?5@52>48< 2 1/C, 5A;8 ?0@0<5B@ 1>;LH5 9)

input int      MaxFanDistanceM5              = 250;   // <0:A8<0;L=> 4>?CAB8<>5 @0AAB>O=85 <564C  4;O 255@0 =0 3@0D8:5  5 (B>;L:> 2 A83=0; 1)

input int      MaxFanDistanceM15             = 200;   // <0:A8<0;L=> 4>?CAB8<>5 @0AAB>O=85 <564C  4;O 255@0 =0 3@0D8:5 15 (B>;L:> 2 A83=0; 4)

input int      MaxFanDistanceH1              = 600;   // <0:A8<0;L=> 4>?CAB8<>5 @0AAB>O=85 <564C  4;O 255@0 =0 3@0D8:5 15 (B>;L:> 2 A83=0; 6)

input int      StochasticKperiodM5           = 24;    // ?5@8>4 AB>E0AB8:0 (4;O 5)

input int      StochasticUpM5                = 85;    // 25@E=89 C@>25=L AB>E0AB8:0 (4;O 5)

input int      StochasticDownM5              = 15;    // =86=89 C@>25=L AB>E0AB8:0 (4;O 5)

input int      StochasticKperiodM15          = 24;    // ?5@8>4 AB>E0AB8:0 (4;O 15)

input int      StochasticUpM15               = 85;    // 25@E=89 C@>25=L AB>E0AB8:0 (4;O 15)

input int      StochasticDownM15             = 15;    // =86=89 C@>25=L AB>E0AB8:0 (4;O 15)

input int      MinBody                       = 150;   // <8=8<0;L=K9 @07<5@ B5;0 A25G8 (B>;L:> 2 A83=0; 1)

input int      MinFlatInBars                 = 10;    // <0;5=L:89 D;5B (<8=8<0;L=0O 4;8=0 D;5B0 2 10@0E)

input int      MaxFlatInPoints               = 150;   // 2KA>:89 D;5B (<0:A8<0;L=0O 2KA>B0 D;5B0 2 ?C=:B0E)

input int      MinDivergencesInBarsM5        = 75;    // <8=8<0;L=>5 @0AAB>O=85 2 10@0E <564C ?8:0<8 8=48:0B>@0 4;O 4825@35=F88 =0 5

input int      HammerMinPercentageLongShadow = 80;    // <8=8<0;L=K9  ?@>F5=B 4;8==>9  B5=8 <>;>B0

input int      HammerMaxPercentageShortShadow= 10;    // <0:A8<0;L=K9 ?@>F5=B :>@>B:>9 B5=8 <>;>B0

input int      HammerMinSizeInPoints         = 11;    // <8=8<0;L=K9  @07<5@  <>;>B0 2 ?C=:B0E (=0 3@0D8:5 5)

input int      HammerBarHowLongAgo           = 8;     // :0: 402=> 1K; <>;>B (<0:A8<0;L=K9 =><5@ 53> 10@0)

input int      HammerPeriodOnBars            = 15;    // =0 A:>;L:8E 10@0E <>;>B O2;O5BAO <0:A8<C<>< (B>;L:> 2 A83=0; 6)

input int      MaxFanWidthAtNarrowestM5      = 30;    // C7:89 8AB>G=8: (<0:A8<0;L=0O H8@8=0 255@0 =0 5 2 A0<>9 C7:>9 B>G:5)

input int      FanConvergedToPointIinBars    = 5;     // A:>;L:> 10@>2 =0704 255@ AE>48;AO 2 "C7:89 8AB>G=8:" (?@0:B8G5A:8 2 B>G:C)

input int      RangeMaxOrMinBreaksThrough    = 10;    // 480?07>= <0:A8<C<0 8;8 <8=8<C<0, :>B>@K9 ?@>18205BAO ("C7:89 8AB>G=8:" 2 10@0E)

input ulong    m_magic                       = 1214;  // ?><5B:0 A2>8E ?>78F89 B0:8< =><5@><

input int      StepTral                      = 500;   // <8=8<0;L=K9 A4283 B@59;8=3-AB>?0

input int      DistTral                      = 3000;  // @0AAB>O=85 >B B@59;8=3-AB>?0 4> F5=K (5A;8 <5=LH5 100, B> B@0; =5 @01>B05B)

//--- ;>BK >B:@KBKE ?>78F89

double lot_buy,lot_sel;

//--- 255@K A:>;L7OI8E A@54=8E, :>MDD8F8M=B ;>B0 (5A;8 A>2?0;8 =5A:>;L:> A83=0;>2 A@07C, B> >B:@K205< 42>9=>9 ;>B)

int veer_m5,veer_15,veer_h1,lt_koef;

//--- ?5@5A5G5=85 AB>E0AB8:0 8 A83=0;L=>9 ;8=88 =0 3@0D8:5 5, =0 3@0D8:5 15, 10@ 4;O F8:;0

int stoch_crosM5,stoh_per15;

//--- ?@>1>9 A:>;L7OI8E A@54=8E M5 8 M15, ?@>1>9 D;5B0 =0 5, 3>@= (C;CGH5==0O 25@A8O 255@0 )

int prob_m5,prob_15,prb_flt,hrn_bull,hrn_bear,prb_yz;

//--- 4825@35=F8O =0 AB>E0AB8:5 5, 10@ 345 5ABL <>;>B, 7=0G5=85 <>;>B0

int div_buy,div_sel,mltbr,molot;

//--- A83=0;K C?@02;5=8O >@45@0<8

int zakr_buy=-1,zakr_sel=-1,otkr_buy=-1,otkr_sel=-1;

//--- 2@5<O >B:@KB8O 10@0 1 =0 B5:CI5< 8 ?@54K4CI5< B8:5

datetime vrem_new,vrem_old;

//--- :><<5=B0@89 : >@45@C (?@8G8=0 >B:@KB8O)

string signal_name;

//---

int    handle_iMA_34_M5;                     // variable for storing the handle of the iMA indicator 

int    handle_iMA_55_M5;                     // variable for storing the handle of the iMA indicator 

int    handle_iMA_89_M5;                     // variable for storing the handle of the iMA indicator 

int    handle_iMA_144_M5;                    // variable for storing the handle of the iMA indicator 

int    handle_iMA_233_M5;                    // variable for storing the handle of the iMA indicator 



int    handle_iMA_34_M15;                    // variable for storing the handle of the iMA indicator 

int    handle_iMA_55_M15;                    // variable for storing the handle of the iMA indicator 

int    handle_iMA_89_M15;                    // variable for storing the handle of the iMA indicator 

int    handle_iMA_144_M15;                   // variable for storing the handle of the iMA indicator 

int    handle_iMA_233_M15;                   // variable for storing the handle of the iMA indicator 



int    handle_iMA_34_H1;                     // variable for storing the handle of the iMA indicator 

int    handle_iMA_55_H1;                     // variable for storing the handle of the iMA indicator 

int    handle_iMA_89_H1;                     // variable for storing the handle of the iMA indicator 

int    handle_iMA_144_H1;                    // variable for storing the handle of the iMA indicator 

int    handle_iMA_233_H1;                    // variable for storing the handle of the iMA indicator 



int    handle_iStochastic_M5;                // variable for storing the handle of the iStochastic indicator 

int    handle_iStochastic_M15;               // variable for storing the handle of the iStochastic indicator 

//+------------------------------------------------------------------+

//| Expert initialization function                                   |

//+------------------------------------------------------------------+

int OnInit()

  {

   if(!m_symbol.Name(Symbol())) // sets symbol name

      return(INIT_FAILED);

   RefreshRates();



   string err_text="";

   if(!CheckVolumeValue(OrdinaryLot,err_text))

     {

      Print(__FUNCTION__,", ERROR: ",err_text);

      return(INIT_PARAMETERS_INCORRECT);

     }

//---

   m_trade.SetExpertMagicNumber(m_magic);

   m_trade.SetMarginMode();

   m_trade.SetTypeFillingBySymbol(m_symbol.Name());

//---

   Comment("\n#! !"");



   if(Period()!=PERIOD_M5)

      MessageBox("C6=> 2K1@0BL ?5@8>4 M5");



   if(Symbol()!="GBPUSD")

      MessageBox("C6=> 2K1@0BL 20;NBC GBP/USD");



   vrem_old=iTime(m_symbol.Name(),Period(),2);



   if(!CreateMA(handle_iMA_34_M5,PERIOD_M5,34))

      return(INIT_FAILED);

   if(!CreateMA(handle_iMA_55_M5,PERIOD_M5,55))

      return(INIT_FAILED);

   if(!CreateMA(handle_iMA_89_M5,PERIOD_M5,89))

      return(INIT_FAILED);

   if(!CreateMA(handle_iMA_144_M5,PERIOD_M5,144))

      return(INIT_FAILED);

   if(!CreateMA(handle_iMA_233_M5,PERIOD_M5,233))

      return(INIT_FAILED);



   if(!CreateMA(handle_iMA_34_M15,PERIOD_M15,34))

      return(INIT_FAILED);

   if(!CreateMA(handle_iMA_55_M15,PERIOD_M15,55))

      return(INIT_FAILED);

   if(!CreateMA(handle_iMA_89_M15,PERIOD_M15,89))

      return(INIT_FAILED);

   if(!CreateMA(handle_iMA_144_M15,PERIOD_M15,144))

      return(INIT_FAILED);

   if(!CreateMA(handle_iMA_233_M15,PERIOD_M15,233))

      return(INIT_FAILED);



   if(!CreateMA(handle_iMA_34_H1,PERIOD_H1,34))

      return(INIT_FAILED);

   if(!CreateMA(handle_iMA_55_H1,PERIOD_H1,55))

      return(INIT_FAILED);

   if(!CreateMA(handle_iMA_89_H1,PERIOD_H1,89))

      return(INIT_FAILED);

   if(!CreateMA(handle_iMA_144_H1,PERIOD_H1,144))

      return(INIT_FAILED);

   if(!CreateMA(handle_iMA_233_H1,PERIOD_H1,233))

      return(INIT_FAILED);

//--- create handle of the indicator iStochastic

   handle_iStochastic_M5=iStochastic(m_symbol.Name(),PERIOD_M5,StochasticKperiodM5,4,3,MODE_SMA,STO_LOWHIGH);

//--- if the handle is not created 

   if(handle_iStochastic_M5==INVALID_HANDLE)

     {

      //--- tell about the failure and output the error code 

      PrintFormat("Failed to create handle of the iStochastic indicator for the symbol %s/%s, error code %d",

                  m_symbol.Name(),

                  EnumToString(PERIOD_M5),

                  GetLastError());

      //--- the indicator is stopped early 

      return(INIT_FAILED);

     }

//--- create handle of the indicator iStochastic

   handle_iStochastic_M15=iStochastic(m_symbol.Name(),PERIOD_M15,StochasticKperiodM15,4,3,MODE_SMA,STO_LOWHIGH);

//--- if the handle is not created 

   if(handle_iStochastic_M15==INVALID_HANDLE)

     {

      //--- tell about the failure and output the error code 

      PrintFormat("Failed to create handle of the iStochastic indicator for the symbol %s/%s, error code %d",

                  m_symbol.Name(),

                  EnumToString(PERIOD_M15),

                  GetLastError());

      //--- the indicator is stopped early 

      return(INIT_FAILED);

     }

//---

   return(INIT_SUCCEEDED);

  }

//+------------------------------------------------------------------+

//| Expert deinitialization function                                 |

//+------------------------------------------------------------------+

void OnDeinit(const int reason)

  {

//---



  }

//+------------------------------------------------------------------+

//| Expert tick function                                             |

//+------------------------------------------------------------------+

void OnTick()

  {

//--- @0AAB>O=8O <564C :@09=8<8 A:>;L7OI8<8 A@54=8<8

   int dist_m5,dist_15,dist_h1;

//--- 2@5<O >B:@KB8O 10@0 1 =0 B5:CI5< B8:5

   vrem_new=iTime(m_symbol.Name(),Period(),1);

//--- 5A;8 MB> =>2K9 10@

   if(vrem_new!=vrem_old)

     {

      //--- >1=C;O5< A83=0;K C?@02;5=8O >@45@0<8, 2K?>;=O5< 0=0;87 8 @0AG5BK

      zakr_buy=0; zakr_sel=0; otkr_buy=0; otkr_sel=0; signal_name="!  +"; lt_koef=0;



      TimeframeAnalysisM5(veer_m5,dist_m5,prob_m5);



      TimeframeAnalysisM15(veer_15,dist_15,prob_15);



      TimeframeAnalysisH1(veer_h1,dist_h1);



      stoch_crosM5=StochasticAnalysis();



      prb_flt=IsBreakdownFlat();



      hrn_bull=IsGornBull(1);



      hrn_bear=IsGornBear(1);



      prb_yz=BreaksThrough(1);



      div_buy=DivergenceBull(4);



      div_sel=DivergenceBear(4);

      //--- ?5@5A5G5=85 AB>E0AB8:0 8 A83=0;L=>9 ;8=88 2 :@09=59 7>=5 =0 15

      stoh_per15=!rossingStochasticM15(1);

      //--- =0E>48< 1;8609H89 10@, 345 5ABL <>;>B 8 =0?@02;5=85 <>;>B0

      //--- 5A;8 C =0A 5ABL 420 <>;>B0, 70AG8BK205BAO B>;L:> 1;8609H89

      molot=0; mltbr=0;



      for(mltbr=1; mltbr<20; mltbr++)

        {

         molot=IsHammer(mltbr);



         if(molot!=0)

            break;

        }

      MqlRates rates[1];

      if(CopyRates(m_symbol.Name(),PERIOD_M5,1,1,rates)!=1)

         return;

      //--- A83=0; 1 : C7:89 255@ =0 5, 1>;LH0O A25G0, ?5@5A5G5=85 AB>E0AB8:0 2 :@09=59 7>=5

      if(dist_m5<MaxFanDistanceM5)

        {

         if((veer_m5>0) && (veer_15>0) && (veer_h1>0) && (stoch_crosM5>0))

           {

            if((rates[0].open+MinBody*Point())<rates[0].close)

              {

               otkr_buy=1;

               lt_koef++;

               signal_name="veer and stoch";

              }

           }

         //--- 

         if((veer_m5<0) && (veer_15<0) && (veer_h1<0) && (stoch_crosM5<0))

           {

            if((rates[0].open-MinBody*Point())>rates[0].close)

              {

               otkr_sel=1;

               lt_koef++;

               signal_name="veer and stoch";

              }

           }

        }

      //--- A83=0; 2 : ?@>1>9 255@0 A@54=8E =0 5, C A25G8 =5B 704=59 B5=8

      if(prob_m5>0)

        {

         if((veer_m5>0) && (veer_15>0) && (veer_h1>0) && (rates[0].open==rates[0].low))

           {

            otkr_buy=1;

            lt_koef++;

            signal_name="proboy m5";

           }

        }

      //--- 

      if(prob_m5<0)

        {

         if((veer_m5<0) && (veer_15<0) && (veer_h1<0) && (rates[0].open==rates[0].high))

           {

            otkr_sel=1;

            lt_koef++;

            signal_name="proboy m5";

           }

        }

      //--- A83=0; 3 : ?@>1>9 C7:>3> D;5B0 ?> B@5=4C =0 3@0D8:5 5

      if(prb_flt>0)

        {

         if((veer_m5>0) && (veer_15>0) && (veer_h1>0))

           {

            otkr_buy=1;

            lt_koef++;

            signal_name="proboy fleta";

           }

        }

      //--- 

      if(prb_flt<0)

        {

         if((veer_m5<0) && (veer_15<0) && (veer_h1<0))

           {

            otkr_sel=1;

            lt_koef++;

            signal_name="proboy fleta";

           }

        }

      //--- A83=0; 4 : ?@>1>9 A:>;L7OI8E A@54=8E =0 5 8 =0 15, C7>ABL  =0 15

      if(prob_15>0)

        {

         if((prob_m5>0) && (veer_15>0) && (veer_h1>0) && (dist_15<MaxFanDistanceM15))

           {

            otkr_buy=1;

            lt_koef++;

            signal_name="proboy 3x";

           }

        }

      //--- 

      if(prob_15<0)

        {

         if((prob_m5<0) && (veer_15<0) && (veer_h1<0) && (dist_15<MaxFanDistanceM15))

           {

            otkr_sel=1;

            lt_koef++;

            signal_name="proboy 3x";

           }

        }

      //--- A83=0; 5 : 4825@35=F8O AB>E0AB8:0 =0 5

      if(div_buy>0)

        {

         if((veer_m5>0) && (veer_15>0) && (veer_h1>0))

           {

            otkr_buy=1;

            lt_koef++;

            signal_name="diver stoch";

           }

        }

      //--- 

      if(div_sel>0)

        {

         if((veer_m5<0) && (veer_15<0) && (veer_h1<0))

           {

            otkr_sel=1;

            lt_koef++;

            signal_name="diver stoch";

           }

        }

      //--- A83=0; 6 : <>;>B =0 5 ?> B@5=4C

      if((mltbr<=HammerBarHowLongAgo) && (dist_h1<MaxFanDistanceH1))

        {

         int      bar_highest=-1;

         double   price_highest  = 0.0;

         int      bar_lowest     = -1;

         double   price_lowest   = 0.0;



         if(Highest(bar_highest,price_highest,m_symbol.Name(),PERIOD_M5,MODE_HIGH,HammerPeriodOnBars,1) && 

            Lowest(bar_lowest,price_lowest,m_symbol.Name(),PERIOD_M5,MODE_LOW,HammerPeriodOnBars,1))

           {

            if((molot>0) && (mltbr==bar_lowest) && (rates[0].open<rates[0].close))

              {

               if((veer_m5>0) && (veer_15>0) && (veer_h1>0))

                 {

                  otkr_buy=1;



                  lt_koef++;



                  signal_name="molot";

                 }

              }

            //--- 

            if((molot<0) && (mltbr==bar_highest) && (rates[0].open>rates[0].close))

              {

               if((veer_m5<0) && (veer_15<0) && (veer_h1<0))

                 {

                  otkr_sel=1;



                  lt_koef++;



                  signal_name="molot";

                 }

              }

           }

        }

      //--- A83=0; 7 : ?5@5A5G5=85 AB>E0AB8:0 =0 15 2 :@09=59 7>=5 ?> B@5=4C

      if(stoh_per15>0)

        {

         if((veer_m5>0) && (veer_15>0) && (veer_h1>0))

           {

            otkr_buy=1;



            lt_koef++;



            signal_name="stoh15";

           }

        }

      //--- 

      if(stoh_per15<0)

        {

         if((veer_m5<0) && (veer_15<0) && (veer_h1<0))

           {

            otkr_sel=1;



            lt_koef++;



            signal_name="stoh15";

           }

        }

      //--- A83=0; 8 : 3>@= (>G5=L C7:89 255@ =0 5), F5=0 ?@>18205B 480?07>=

      if(prb_yz>0)

        {

         if((hrn_bull>0) && (veer_15>0) && (veer_h1>0) && (hrn_bull<FanConvergedToPointIinBars))

           {

            otkr_buy=1;



            lt_koef++;



            signal_name="horn_bull";

           }

        }

      //--- 

      if(prb_yz<0)

        {

         if((hrn_bear>0) && (veer_15<0) && (veer_h1<0) && (hrn_bear<FanConvergedToPointIinBars))

           {

            otkr_sel=1;



            lt_koef++;



            signal_name="horn_bear";

           }

        }

      //--- 5A;8 >B:@K205< ?>78F8N, B> 70:@K205< ?@>B82>?>;>6=CN

      if(otkr_buy==1)

         zakr_sel=2;



      if(otkr_sel==1)

         zakr_buy=2;

      //--- 5A;8 70:@K205< ?>78F8N, B> >B<5=O5< A83=0; : >B:@KB8N

      if(zakr_buy==2)

         otkr_buy=0;



      if(zakr_sel==2)

         otkr_sel=0;

      //--- 2K2>4 =0 M:@0= @57C;LB0B>2 @0AG5B>2

      Comment("\nVEER_M5 = ",veer_m5,"   DIST_M5 = ",dist_m5,

              "\n\nVEER_15 = ",veer_15,"   DIST_15 = ",dist_15,

              "\n\nVEER_h1 = ",veer_h1,"   dist_h1 = ",dist_h1,

              "\n\nPRB_FLT = ",prb_flt,

              "\n\nSTOCH_CROSM5 = ",stoch_crosM5);



      //--- @0AG5BK 2K?>;=5=K, B5?5@L MB> =5 =>2K9 10@

      vrem_old=vrem_new;

     }

//--- 70:@K205< 8 <>48D8F8@C5< 8<5NI85AO >@45@0

   perebor_orderov(zakr_buy,zakr_sel);

//--- ?>4AG8BK205< ;>BK >B:@KBKE ?>78F89

   CalculateVolumePositions(lot_buy,lot_sel);

//--- CAB0=>2:0 10O

   if((otkr_buy==1) && (lot_buy<0.01))

      if(RefreshRates())

         ystanovit_buy(signal_name,lt_koef);

//--- CAB0=>2:0 A5;0

   if((otkr_sel==1) && (lot_sel<0.01))

      if(RefreshRates())

         ystanovit_sel(signal_name,lt_koef);

  }

//+------------------------------------------------------------------+

//| TradeTransaction function                                        |

//+------------------------------------------------------------------+

void OnTradeTransaction(const MqlTradeTransaction &trans,

                        const MqlTradeRequest &request,

                        const MqlTradeResult &result)

  {

//---



  }

//+------------------------------------------------------------------+

//| =0;87 A:>;L7OI8E A@54=8E =0 3@0D8:5 5 (=0 B5:CI5< 3@0D8:5)     |

//+------------------------------------------------------------------+

void TimeframeAnalysisM5(int &veer,int &dist,int &prob)

  {

   double ma[5];

   int v,n;

   double vma,nma,rast;

   veer=0;  prob=0;

//--- AG8BK205< A:>;L7OI85 A@54=85 =0 10@5 1

   ma[0] = iMAGet(handle_iMA_34_M5,1);

   ma[1] = iMAGet(handle_iMA_55_M5,1);

   ma[2] = iMAGet(handle_iMA_89_M5,1);

   ma[3] = iMAGet(handle_iMA_144_M5,1);

   ma[4] = iMAGet(handle_iMA_233_M5,1);

   for(int i=0;i<5;i++)

      if(ma[i]==0.0)

         return;

//--- 25@E=OO A:>;L7OI0O A@54=OO

   v=ArrayMaximum(ma);

   vma=ma[v];

//--- =86=OO A:>;L7OI0O A@54=OO

   n=ArrayMinimum(ma);

   nma=ma[n];

//--- @0AAB>O=85 <564C 25@E=59 8 =86=59  2 ?C=:B0E

   rast = (vma-nma)/Point();

   dist = (int)NormalizeDouble(rast, 0);

//--- >:@C3;8< B@8 ;53:85  4> ... 7=0:>2 ?>A;5 70?OB>9

   ma[0] = NormalizeDouble(ma[0], m_symbol.Digits());

   ma[1] = NormalizeDouble(ma[1], m_symbol.Digits());

   ma[2] = NormalizeDouble(ma[2], m_symbol.Digits());

//--- 255@ 225@E

   if((ma[4]<ma[3]) && (ma[3]<ma[2]) && (ma[2]<=ma[1]) && (ma[1]<=ma[0]))

      veer=1;

//--- 255@ 2=87

   if((ma[4]>ma[3]) && (ma[3]>ma[2]) && (ma[2]>=ma[1]) && (ma[1]>=ma[0]))

      veer=-1;



   MqlRates rates[1];

   if(CopyRates(m_symbol.Name(),PERIOD_M5,1,1,rates)!=1)

      return;

//--- ?@>1>9 225@E

   if((rates[0].open<nma) && (rates[0].close>vma))

      prob=1;

//---?@>1>9 2=87

   if((rates[0].open>vma) && (rates[0].close<nma))

      prob=-1;

   return;

  }

//+------------------------------------------------------------------+

//| =0;87 A:>;L7OI8E A@54=8E =0 3@0D8:5 15                         |

//+------------------------------------------------------------------+

void TimeframeAnalysisM15(int &veer,int &dist,int &prob)

  {

   double ma[5];

   int v,n;

   double vma,nma,rast,op_15,cl_15;

   veer=0; prob=0;

//--- AG8BK205< A:>;L7OI85 A@54=85 =0 10@5 1

   ma[0] = iMAGet(handle_iMA_34_M15,1);

   ma[1] = iMAGet(handle_iMA_55_M15,1);

   ma[2] = iMAGet(handle_iMA_89_M15,1);

   ma[3] = iMAGet(handle_iMA_144_M15,1);

   ma[4] = iMAGet(handle_iMA_233_M15,1);

   for(int i=0;i<5;i++)

      if(ma[i]==0.0)

         return;

//--- 25@E=OO A:>;L7OI0O A@54=OO

   v=ArrayMaximum(ma);

   vma=ma[v];

//--- =86=OO A:>;L7OI0O A@54=OO

   n=ArrayMinimum(ma);

   nma=ma[n];

//--- @0AAB>O=85 <564C 25@E=59 8 =86=59  2 ?C=:B0E

   rast = (vma-nma)/Point();

   dist = (int)NormalizeDouble(rast, 0);

//--- >:@C3;8< 425 ;53:85  4> ... 7=0:>2 ?>A;5 70?OB>9

   ma[0] = NormalizeDouble(ma[0], m_symbol.Digits());

   ma[1] = NormalizeDouble(ma[1], m_symbol.Digits());

//--- 255@ 225@E

   if((ma[4]<ma[3]) && (ma[3]<ma[2]) && (ma[2]<ma[1]) && (ma[1]<=ma[0]))

      veer=1;

//--- 255@ 2=87

   if((ma[4]>ma[3]) && (ma[3]>ma[2]) && (ma[2]>ma[1]) && (ma[1]>=ma[0]))

      veer=-1;

//--- >?@545;5=85 ?@>1>O B@5E 1KAB@KE A:>;L7OI8E A@54=8E =0 3@0D8:5 15

   MqlRates rates[1];

   if(CopyRates(m_symbol.Name(),PERIOD_M15,1,1,rates)!=1)

      return;

   op_15=rates[0].open;

   cl_15=rates[0].close;

   if((op_15>0) && (cl_15>0))

     {

      if((op_15<ma[0]) && (op_15<ma[1]) && (op_15<ma[2]))

        {

         if((cl_15>ma[0]) && (cl_15>ma[1]) && (cl_15>ma[2]))

            prob=1;

        }



      if((op_15>ma[0]) && (op_15>ma[1]) && (op_15>ma[2]))

        {

         if((cl_15<ma[0]) && (cl_15<ma[1]) && (cl_15<ma[2]))

            prob=-1;

        }

     }

//---

   return;

  }

//+------------------------------------------------------------------+

//| =0;87 A:>;L7OI8E A@54=8E =0 3@0D8:5 H1                          |

//+------------------------------------------------------------------+

void TimeframeAnalysisH1(int &veer,int &dist)

  {

   double ma[5];

   int v,n;

   double vma,nma,rast;

   veer=0;

//--- AG8BK205< A:>;L7OI85 A@54=85 =0 10@5 1

   ma[0] = iMAGet(handle_iMA_34_H1,1);

   ma[1] = iMAGet(handle_iMA_55_H1,1);

   ma[2] = iMAGet(handle_iMA_89_H1,1);

   ma[3] = iMAGet(handle_iMA_144_H1,1);

   ma[4] = iMAGet(handle_iMA_233_H1,1);

   for(int i=0;i<5;i++)

      if(ma[i]==0.0)

         return;

//--- 25@E=OO A:>;L7OI0O A@54=OO

   v=ArrayMaximum(ma);

   vma=ma[v];

//--- =86=OO A:>;L7OI0O A@54=OO

   n=ArrayMinimum(ma);

   nma=ma[n];

//--- @0AAB>O=85 <564C 25@E=59 8 =86=59  2 ?C=:B0E

   rast = (vma-nma)/Point();

   dist = (int)NormalizeDouble(rast, 0);

//--- 255@ 225@E

   if((ma[4]<ma[3]) && (ma[3]<ma[2]) && (ma[2]<ma[1]) && (ma[1]<ma[0]))

      veer=1;

//--- 255@ 2=87

   if((ma[4]>ma[3]) && (ma[3]>ma[2]) && (ma[2]>ma[1]) && (ma[1]>ma[0]))

      veer=-1;

//---

   return;

  }

//+------------------------------------------------------------------+

//| A;8 ?@028;L=K9 255@ @0AH8@O5BAO 87 >G5=L C7:>3> 8AB>G=8:0,      |

//| B> MB> "3>@="                                                    |

//+------------------------------------------------------------------+

int IsGornBull(int b)

  {

   double ma5=0.0,ma4=0.0,ma3=0.0,ma2=0.0,ma1=0.0;

   double rast_i=0.0,rast_b=0.0;

//--- AG8BK205< A:>;L7OI85 A@54=85 =0 10@5 b

   double ma[5];

   ma[0] = iMAGet(handle_iMA_34_M5,b);

   ma[1] = iMAGet(handle_iMA_55_M5,b);

   ma[2] = iMAGet(handle_iMA_89_M5,b);

   ma[3] = iMAGet(handle_iMA_144_M5,b);

   ma[4] = iMAGet(handle_iMA_233_M5,b);

   for(int i=0;i<5;i++)

      if(ma[i]==0.0)

         return(-1);

//--- 5A;8 MB> ?@028;L=K9 255@ 225@E

   if((ma5<ma4) && (ma4<ma3) && (ma3<ma2) && (ma2<ma1))

     {

      rast_b=ma1-ma5;

      double array_iMA_34_M5[];

      double array_iMA_55_M5[];

      double array_iMA_89_M5[];

      double array_iMA_144_M5[];

      double array_iMA_233_M5[];

      ArraySetAsSeries(array_iMA_34_M5,true);

      ArraySetAsSeries(array_iMA_55_M5,true);

      ArraySetAsSeries(array_iMA_89_M5,true);

      ArraySetAsSeries(array_iMA_144_M5,true);

      ArraySetAsSeries(array_iMA_233_M5,true);

      int start_pos  = b;

      int count      = 300;

      if(!iMAGetArray(handle_iMA_34_M5,start_pos,count,array_iMA_34_M5) && 

         !iMAGetArray(handle_iMA_55_M5,start_pos,count,array_iMA_55_M5) && 

         !iMAGetArray(handle_iMA_89_M5,start_pos,count,array_iMA_89_M5) && 

         !iMAGetArray(handle_iMA_144_M5,start_pos,count,array_iMA_144_M5) && 

         !iMAGetArray(handle_iMA_233_M5,start_pos,count,array_iMA_233_M5))

         return(-1);

      //--- =0G8=05< ?@>A<>B@ ?CG:0 A:>;L7OI8E A@54=8E =0704 >B B>G:8 b

      //for(i=(b+1); i<(b+300); i++)

      for(int i=0;i<count;i++)

        {

         //--- AG8BK205< 7=0G5=8O 

         ma1 = NormalizeDouble(array_iMA_34_M5[i],m_symbol.Digits());

         ma2 = NormalizeDouble(array_iMA_55_M5[i],m_symbol.Digits());

         ma3 = NormalizeDouble(array_iMA_89_M5[i],m_symbol.Digits());

         ma4 = NormalizeDouble(array_iMA_144_M5[i],m_symbol.Digits());

         ma5 = NormalizeDouble(array_iMA_233_M5[i],m_symbol.Digits());

         //--- 5A;8 ?>GB8 ?@028;L=K9 255@ A>E@0=O5BAO

         if(((ma5<=ma3) && (ma4<=ma3) && (ma3<=ma2) && (ma2<=ma1)) || ((ma5<=ma4) && (ma4<=ma3) && (ma3<=ma2) && (ma3<=ma1)))

           {

            rast_i=MathMax(ma2,ma1)-MathMin(ma5,ma4);

            //--- 5A;8 255@ AB0=>28BAO H8@5, G5< 2 B>G:5 bx >= =0< =5 ?>4E>48B

            if(rast_i>(rast_b+2*Point()))

               return(0);

            //--- 8I5< 10@, 345 255@ AE>48BAO 2 C7:89 8AB>G=8: 8 2>72@0I05< 53>   

            if((rast_i<(MaxFanWidthAtNarrowestM5*Point())) && (rast_i<rast_b))

               return(i);

           }

         else

            return(0);

        }

     }

//---

   return(0);

  }

//+------------------------------------------------------------------+

//| A;8 ?@028;L=K9 255@ @0AH8@O5BAO 87 >G5=L C7:>3> 8AB>G=8:0,      |

//| B> MB> "3>@="                                                    |

//+------------------------------------------------------------------+

int IsGornBear(int b)

  {

   double ma5=0.0,ma4=0.0,ma3=0.0,ma2=0.0,ma1=0.0;

   double rast_i=0.0,rast_b=0.0;

//--- AG8BK205< A:>;L7OI85 A@54=85 =0 10@5 b

   double ma[5];

   ma[0] = iMAGet(handle_iMA_34_M5,b);

   ma[1] = iMAGet(handle_iMA_55_M5,b);

   ma[2] = iMAGet(handle_iMA_89_M5,b);

   ma[3] = iMAGet(handle_iMA_144_M5,b);

   ma[4] = iMAGet(handle_iMA_233_M5,b);

   for(int i=0;i<5;i++)

      if(ma[i]==0.0)

         return(-1);

//--- 5A;8 MB> ?@028;L=K9 255@ 2=87

   if((ma5>ma4) && (ma4>ma3) && (ma3>ma2) && (ma2>ma1))

     {

      rast_b=ma5-ma1;

      double array_iMA_34_M5[];

      double array_iMA_55_M5[];

      double array_iMA_89_M5[];

      double array_iMA_144_M5[];

      double array_iMA_233_M5[];

      ArraySetAsSeries(array_iMA_34_M5,true);

      ArraySetAsSeries(array_iMA_55_M5,true);

      ArraySetAsSeries(array_iMA_89_M5,true);

      ArraySetAsSeries(array_iMA_144_M5,true);

      ArraySetAsSeries(array_iMA_233_M5,true);

      int start_pos  = b;

      int count      = 300;

      if(!iMAGetArray(handle_iMA_34_M5,start_pos,count,array_iMA_34_M5) && 

         !iMAGetArray(handle_iMA_55_M5,start_pos,count,array_iMA_55_M5) && 

         !iMAGetArray(handle_iMA_89_M5,start_pos,count,array_iMA_89_M5) && 

         !iMAGetArray(handle_iMA_144_M5,start_pos,count,array_iMA_144_M5) && 

         !iMAGetArray(handle_iMA_233_M5,start_pos,count,array_iMA_233_M5))

         return(-1);

      //--- =0G8=05< ?@>A<>B@ ?CG:0 A:>;L7OI8E A@54=8E =0704 >B B>G:8 b

      //for(i=(b+1); i<(b+300); i++)

      for(int i=0;i<count;i++)

        {

         //--- AG8BK205< 7=0G5=8O 

         ma1 = NormalizeDouble(array_iMA_34_M5[i],m_symbol.Digits());

         ma2 = NormalizeDouble(array_iMA_55_M5[i],m_symbol.Digits());

         ma3 = NormalizeDouble(array_iMA_89_M5[i],m_symbol.Digits());

         ma4 = NormalizeDouble(array_iMA_144_M5[i],m_symbol.Digits());

         ma5 = NormalizeDouble(array_iMA_233_M5[i],m_symbol.Digits());

         //--- 5A;8 ?>GB8 ?@028;L=K9 255@ A>E@0=O5BAO

         if(((ma5>=ma3) && (ma4>=ma3) && (ma3>=ma2) && (ma2>=ma1)) || ((ma5>=ma4) && (ma4>=ma3) && (ma3>=ma2) && (ma3>=ma1)))

           {

            rast_i=MathMax(ma5,ma4)-MathMin(ma2,ma1);

            //--- 5A;8 255@ AB0=>28BAO H8@5, G5< 2 B>G:5 b >= =0< =5 ?>4E>48B

            if(rast_i>(rast_b+2*Point()))

               return(0);

            //--- 8I5< 10@, 345 255@ AE>48BAO 2 C7:89 8AB>G=8: 8 2>72@0I05< 53>   

            if((rast_i<(MaxFanWidthAtNarrowestM5*Point())) && (rast_i<rast_b))

               return(i);

           }

         else

            return(0);

        }

     }

//---

   return(0);

  }

//+------------------------------------------------------------------+

//| ?@545;5=85 ?@>1>O 480?07>=0 4;O A83=0;0 C7>AB8 =0 10@5 b        |

//+------------------------------------------------------------------+

int BreaksThrough(int b)

  {

   int      bar_highest    = -1;

   double   price_highest  = 0.0;

   int      bar_lowest     = -1;

   double   price_lowest   = 0.0;

   if(!Highest(bar_highest,price_highest,m_symbol.Name(),PERIOD_M5,MODE_HIGH,RangeMaxOrMinBreaksThrough,b+1) || 

      !Lowest(bar_lowest,price_lowest,m_symbol.Name(),PERIOD_M5,MODE_LOW,RangeMaxOrMinBreaksThrough,b+1))

      return(0);



   MqlRates rates[1];

   if(CopyRates(m_symbol.Name(),PERIOD_M5,1,1,rates)!=1)

      return(0);



   if((rates[0].open<price_highest) && (rates[0].close>price_highest))

      return(1);

   if((rates[0].open>price_lowest) && (rates[0].close<price_lowest))

      return(-1);

//---

   return(0);

  }

//+------------------------------------------------------------------+

//| ABL ;8 4825@35=F8O A83=0; : ?>:C?:5 =0 10@5 b                   |

//|   (?@02K9 <8=8<C< 8=48:0B>@0)                                    |

//+------------------------------------------------------------------+

int DivergenceBull(int b)

  {

   double stoh_min,yama1,lw2,lw1;



   if(b<4)

      return(0);



   double array_iStochastic_M5[];

   ArraySetAsSeries(array_iStochastic_M5,true);

   int start_pos  = 0;

   int count      = 321;

   if(!iStochasticGetArray(handle_iStochastic_M5,MAIN_LINE,start_pos,count,array_iStochastic_M5))

      return(0);



   double st1 = array_iStochastic_M5[b-3];

   double st2 = array_iStochastic_M5[b-2];

   double st3 = array_iStochastic_M5[b-1];

   double st4 = array_iStochastic_M5[b];

   double st5 = array_iStochastic_M5[b+1];

   double st6 = array_iStochastic_M5[b+2];

   double st7 = array_iStochastic_M5[b+3];

//--- 5A;8 B>G:0 b MB> O<0 =0 8=48:0B>@5 AB>E0AB8:

   if((st7>st4) && (st6>st4) && (st5>st4))

     {

      if((st4<st3) && (st3<st2) && (st2<st1))

        {

         //--- >1JO2;O5< 55 <8=8<C<><

         yama1    = st4;

         stoh_min = st4;

         //--- <8=8<0;L=0O F5=0 2 MB>9 >1;0AB8

         int      bar_lowest     = -1;

         double   price_lowest   = 0.0;

         if(!Lowest(bar_lowest,price_lowest,m_symbol.Name(),PERIOD_M5,MODE_LOW,7,b-3))

            return(0);

         lw1=price_lowest;//Low[iLowest(NULL,0,MODE_LOW,7,(b-3))];



         double Low[];

         ArraySetAsSeries(Low,true);

         if(CopyLow(m_symbol.Name(),PERIOD_M5,start_pos,count,Low)!=count)

            return(0);



         for(int i=(b+4); i<300; i++)

           {

            //--- F5=0 =5 4>;6=0 >?CA:0BLAO =865 ?5@2>3> <8=8<C<0

            if(Low[i]<lw1)

               return(0);



            st1 = array_iStochastic_M5[i-3];

            st2 = array_iStochastic_M5[i-2];

            st3 = array_iStochastic_M5[i-1];

            st4 = array_iStochastic_M5[i];

            st5 = array_iStochastic_M5[i+1];

            st6 = array_iStochastic_M5[i+2];

            st7 = array_iStochastic_M5[i+3];



            if((st7>st4) && (st6>st4) && (st5>st4))

              {

               if((st4<st3) && (st4<st2) && (st4<st1))

                 {

                  if((st4<stoh_min) && (i>(b+MinDivergencesInBarsM5)))

                    {

                     if(!Lowest(bar_lowest,price_lowest,m_symbol.Name(),PERIOD_M5,MODE_LOW,7,i-3))

                        return(0);

                     lw2=price_lowest;//Low[iLowest(NULL,0,MODE_LOW,7,(i-3))];



                     if(lw2>lw1)

                        return(i);

                    }

                  //--- ?@02K9 <8=8<C< 4>;65= 1KBL =865 2A5E, :@><5 ;52>3>

                  if(st4<yama1)

                     return(0);

                 }

              }

            if(st4<stoh_min)

               stoh_min=st4;

           }

        }

     }

//---

   return(0);

  }

//+------------------------------------------------------------------+

//| ABL ;8 4825@35=F8O A83=0; : ?@>4065 =0 10@5 b                   |

//| (?@02K9 <0:A8<C< 8=48:0B>@0)                                     |

//+------------------------------------------------------------------+

int DivergenceBear(int b)

  {

   double stoh_max,xolm1,hi2,hi1;



   if(b<4)

      return(0);



   double array_iStochastic_M5[];

   ArraySetAsSeries(array_iStochastic_M5,true);

   int start_pos  = 0;

   int count      = 321;

   if(!iStochasticGetArray(handle_iStochastic_M5,MAIN_LINE,start_pos,count,array_iStochastic_M5))

      return(0);



   double st1 = array_iStochastic_M5[b-3];

   double st2 = array_iStochastic_M5[b-2];

   double st3 = array_iStochastic_M5[b-1];

   double st4 = array_iStochastic_M5[b];

   double st5 = array_iStochastic_M5[b+1];

   double st6 = array_iStochastic_M5[b+2];

   double st7 = array_iStochastic_M5[b+3];

//--- 5A;8 B>G:0 b MB> E>;< =0 8=48:0B>@5 AB>E0AB8:

   if((st7<st4) && (st6<st4) && (st5<st4))

     {

      if((st4>st3) && (st3>st2) && (st2>st1))

        {

         //--- >1JO2;O5< 55 <0:A8<C<><

         xolm1    = st4;

         stoh_max = st4;

         //--- <0:A8<0;L=0O F5=0 2 MB>9 >1;0AB8

         int      bar_highest    = -1;

         double   price_highest  = 0.0;

         if(!Highest(bar_highest,price_highest,m_symbol.Name(),PERIOD_M5,MODE_HIGH,7,b-3))

            return(0);

         hi1=price_highest;//High[iHighest(NULL,0,MODE_HIGH,7,(b-3))];



         double High[];

         ArraySetAsSeries(High,true);

         if(CopyHigh(m_symbol.Name(),PERIOD_M5,start_pos,count,High)!=count)

            return(0);



         for(int i=(b+4); i<300; i++)

           {

            //--- F5=0 =5 4>;6=0 ?>4=8<0BLAO 2KH5 ?5@2>3> <0:A8<C<0

            if(High[i]>hi1)

               return(0);



            st1 = array_iStochastic_M5[i-3];

            st2 = array_iStochastic_M5[i-2];

            st3 = array_iStochastic_M5[i-1];

            st4 = array_iStochastic_M5[i];

            st5 = array_iStochastic_M5[i+1];

            st6 = array_iStochastic_M5[i+2];

            st7 = array_iStochastic_M5[i+3];



            if((st7<st4) && (st6<st4) && (st5<st4))

              {

               if((st4>st3) && (st4>st2) && (st4>st1))

                 {

                  if((st4>stoh_max) && (i>(b+MinDivergencesInBarsM5)))

                    {

                     if(!Highest(bar_highest,price_highest,m_symbol.Name(),PERIOD_M5,MODE_LOW,7,i-3))

                        return(0);

                     hi2=price_highest;//High[iHighest(NULL,0,MODE_HIGH,7,(i-3))];



                     if(hi2<hi1)

                        return(i);

                    }

                  //--- ?@02K9 <0:A8<C< 4>;65= 1KBL 2KH5 2A5E, :@><5 ;52>3>

                  if(st4>xolm1)

                     return(0);

                 }

              }

            if(st4>stoh_max)

               stoh_max=st4;

           }

        }

     }

//---

   return(0);

  }

//+------------------------------------------------------------------+

//| =0;87 AB>E0AB8:0 =0 3@0D8:5 5 (=0 B5:CI5< 3@0D8:5)             |

//+------------------------------------------------------------------+

int StochasticAnalysis()

  {

   double array_iStochastic_MAIN_M5[];

   ArraySetAsSeries(array_iStochastic_MAIN_M5,true);

   int start_pos  = 0;

   int count      = 3;

   if(!iStochasticGetArray(handle_iStochastic_M5,MAIN_LINE,start_pos,count,array_iStochastic_MAIN_M5))

      return(0);



   double array_iStochastic_SIGNAL_M5[];

   ArraySetAsSeries(array_iStochastic_SIGNAL_M5,true);

   start_pos=0;

   count=3;

   if(!iStochasticGetArray(handle_iStochastic_M5,SIGNAL_LINE,start_pos,count,array_iStochastic_SIGNAL_M5))

      return(0);

//--- AB>E0AB8: =0 10@0E 2, 1

   double st2 = array_iStochastic_MAIN_M5[2];

   double st1 = array_iStochastic_MAIN_M5[1];

//--- A83=0;L=0O ;8=8O =0 10@0E 2, 1

   double si2 = array_iStochastic_SIGNAL_M5[2];

   double si1 = array_iStochastic_SIGNAL_M5[1];

//--- ?5@5A5G5=85 A=87C 225@E

   if((st2<si2) && (st2<StochasticDownM5) && (st1>si1))

      return(1);

//--- ?5@5A5G5=85 A25@EC 2=87

   if((st2>si2) && (st2>StochasticUpM5) && (st1<si1))

      return(-1);

//---

   return(0);

  }

//+------------------------------------------------------------------+

//| =0;87 AB>E0AB8:0 =0 3@0D8:5 15 (?>8A: ?5@5A5G5=8O              |

//| A A83=0;L=>9 ;8=859 + ?>4B25@645=85 42865=85< F5=K)              |

//| ?@>25@O5BAO D0:B =0;8G8O ?5@5A5G5=8O =0 10@5 b 15 2 :@09=59 7>=5|

//+------------------------------------------------------------------+

int !rossingStochasticM15(int b)

  {

   double array_iStochastic_MAIN_M15[];

   ArraySetAsSeries(array_iStochastic_MAIN_M15,true);

   int start_pos  = b;

   int count      = 3;

   if(!iStochasticGetArray(handle_iStochastic_M15,MAIN_LINE,start_pos,count,array_iStochastic_MAIN_M15))

      return(0);



   double array_iStochastic_SIGNAL_M5[];

   ArraySetAsSeries(array_iStochastic_SIGNAL_M5,true);

   start_pos  = b;

   count      = 3;

   if(!iStochasticGetArray(handle_iStochastic_M15,SIGNAL_LINE,start_pos,count,array_iStochastic_SIGNAL_M5))

      return(0);

//--- AB>E0AB8: =0 10@0E 3, 2, 1 (10@ 1 MB> 10@ b)

   double st3 = array_iStochastic_MAIN_M15[2];

   double st2 = array_iStochastic_MAIN_M15[1];

   double st1 = array_iStochastic_MAIN_M15[0];

//--- A83=0;L=0O ;8=8O =0 10@0E 2, 1

   double si2 = array_iStochastic_SIGNAL_M5[1];

   double si1 = array_iStochastic_SIGNAL_M5[0];

//--- >B:@KB85 8 70:@KB85 10@0 1 =0 15

   MqlRates rates[1];

   if(CopyRates(m_symbol.Name(),PERIOD_M15,1,0,rates)!=1)

      return(0);



   double op1=rates[0].open;

   double cl1=rates[0].close;



   if((op1==0.0) || (cl1==0.0))

      return(0);



//--- A83=0; : ?>:C?:5

   if((st2<si2) && (st1>si1) && (op1<cl1))

     {

      if((st3<StochasticDownM15) || (st2<StochasticDownM15))

         return(1);

     }

//--- A83=0; : ?@>4065

   if((st2>si2) && (st1<si1) && (op1>cl1))

     {

      if((st3>StochasticUpM15) || (st2>StochasticUpM15))

         return(-1);

     }

//---

   return(0);

  }

//+------------------------------------------------------------------+

//| >8A: D;5B0 =0 7040==>< 10@5 (2>72@0I05B :>;8G5AB2>              |

//| 10@>2, 25@E, =87 D;5B0)                                          |

//+------------------------------------------------------------------+

void SearchFlat(int b,int &flt_kl,double &flt_up,double &flt_dn)

  {

   double ver_fl,niz_fl,nash_razm;

   int kol;

   flt_kl=0; flt_up=0; flt_dn=0;

   kol=1;



   MqlRates rates[];

   ArraySetAsSeries(rates,true);

   if(CopyRates(m_symbol.Name(),PERIOD_M5,b,500,rates)!=500)

      return;



   ver_fl=rates[0].high;

   niz_fl=rates[0].low;

//--- 8I5< 4;8==K9 8 C7:89 CG0AB>:

   for(int i=1; i<500; i++)

     {

      if(rates[i].high>ver_fl)

         ver_fl=rates[i].high;

      if(rates[i].low<niz_fl)

         niz_fl=rates[i].low;

      //--- 5A;8 ?@52KA8;8 <0:A8<0;L=CN 2KA>BC 2KE>48<

      if((ver_fl-niz_fl)>(MaxFlatInPoints*Point()))

         return;

      kol++;



      if(kol>MinFlatInBars)

        {

         //--- =0H @07<0E D;5B0 (4;O 40==>3> :>;8G5AB20 10@>2)

         nash_razm=NormalizeDouble(((kol*CoefFlatnessM5)*Point()),m_symbol.Digits());



         if((ver_fl-niz_fl)<nash_razm)

           {

            flt_kl=kol;

            flt_up=ver_fl;

            flt_dn=niz_fl;

            return;

           }

        }

     }

//---

   return;

  }

//+------------------------------------------------------------------+

//| ABL ;8 ?@>1>9 D;5B0 =0 3@0D8:5 5 (=0 B5:CI5< 3@0D8:5)          |

//+------------------------------------------------------------------+

int IsBreakdownFlat()

  {

//--- 25@E=OO 8 =86=OO 3@0=8F0 D;5B0

   double v_gr,n_gr;

//--- :>;8G5AB2> 10@>2 2> D;5B5

   int fk;

//--- 8I5< D;5B =0 10@5 2 (?@>1>9 10@>< 1)

   SearchFlat(2,fk,v_gr,n_gr);



   MqlRates rates[];

   ArraySetAsSeries(rates,true);

   if(CopyRates(m_symbol.Name(),PERIOD_M5,0,3,rates)!=3)

      return(0);



   if(fk>0)

     {

      if((rates[1].open<v_gr) && (rates[1].close>v_gr))

         return(1);

      if((rates[1].open>n_gr) && (rates[1].close<n_gr))

         return(-1);

     }

//--- 8I5< D;5B =0 10@5 3, ?@>1>9 42C<O 10@0<8 (2 8 1)

   SearchFlat(3,fk,v_gr,n_gr);



   if(fk>0)

     {

      if((rates[1].open<v_gr) && (rates[2].close>v_gr) && (rates[1].open<rates[1].close) && (rates[2].open<rates[2].close))

         return(1);

      if((rates[1].open>n_gr) && (rates[2].close<n_gr) && (rates[1].open>rates[1].close) && (rates[2].open>rates[2].close))

         return(-1);

     }

//---

   return(0);

  }

//+------------------------------------------------------------------+

//| @>25@:0, 5ABL ;8 <>;>B =0 10@5 br                               |

//+------------------------------------------------------------------+

int IsHammer(int br)

  {

   double razm_br,ver_ten,niz_ten;



   MqlRates rates[1];

   if(CopyRates(m_symbol.Name(),PERIOD_M5,br,1,rates)!=1)

      return(0);



   razm_br=rates[0].high-rates[0].low;



   ver_ten=rates[0].high-MathMax(rates[0].open,rates[0].close);



   niz_ten=MathMin(rates[0].open,rates[0].close)-rates[0].low;



   if(razm_br>(HammerMinSizeInPoints*Point()))

     {

      if((100*niz_ten)>(HammerMinPercentageLongShadow*razm_br))

        {

         if((100*ver_ten)<(HammerMaxPercentageShortShadow*razm_br))

           {

            return(1);

           }

        }

      if((100*ver_ten)>(HammerMinPercentageLongShadow*razm_br))

        {

         if((100*niz_ten)<(HammerMaxPercentageShortShadow*razm_br))

           {

            return(-1);

           }

        }

     }

//---

   return(0);

  }

//+------------------------------------------------------------------+

//| >4AG5B ;>B>2 1052 8 A5;>2  (?5@52545==K5 2 1/C =5 AG8B05<)      |

//+------------------------------------------------------------------+

void CalculateVolumePositions(double &volume_buys,double &volume_sells)

  {

   volume_buys=0.0;

   volume_sells=0.0;



   for(int i=PositionsTotal()-1;i>=0;i--)

      if(m_position.SelectByIndex(i)) // selects the position by index for further access to its properties

         if(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==m_magic)

           {

            if(m_position.PositionType()==POSITION_TYPE_BUY)

              {

               if((m_position.StopLoss()==0) || (m_position.StopLoss()<m_position.PriceOpen()))

                  volume_buys+=m_position.Volume();

              }

            if(m_position.PositionType()==POSITION_TYPE_SELL)

              {

               if((m_position.StopLoss()==0) || (m_position.StopLoss()>m_position.PriceOpen()))

                  volume_sells+=m_position.Volume();

              }

           }

//---

   return;

  }

//+------------------------------------------------------------------+

//| 59AB28O A >@45@>< BUY                                           |

//+------------------------------------------------------------------+

void obr_open_buy(int cl_b)

  {

//--- 70:@KB85 2> 871560=85 ?>B5@L

   if(cl_b==2)

     {

      m_trade.PositionClose(m_position.Ticket());

      return;

     }

//--- ?5@52>4 AB>?-;>AA0 2 157C1KB>:

   if(StopLossAfterBreakeven>99)

     {

      if((m_position.StopLoss()==0) || (m_position.StopLoss()<m_position.PriceOpen()))

        {

         if((m_symbol.Bid()-StopLossAfterBreakeven*Point())>(m_position.PriceOpen()+TakeProfitAfterBreakeven*Point()))

           {

            if(!m_trade.PositionModify(m_position.Ticket(),

               m_symbol.NormalizePrice(m_symbol.Bid()-StopLossAfterBreakeven*Point()),

               m_position.TakeProfit()))

               Print("Modify ",m_position.Ticket(),

                     " Position -> false. Result Retcode: ",m_trade.ResultRetcode(),

                     ", description of result: ",m_trade.ResultRetcodeDescription());

            return;

           }

        }

     }

//--- ?5@542865=85 B@59;8=3-AB>?0

   if(DistTral>99)

     {

      if((m_symbol.Bid()-DistTral*Point())>m_position.PriceOpen())

        {

         if((m_symbol.Bid()-DistTral*Point())>(m_position.StopLoss()+StepTral*Point()))

           {

            if(!m_trade.PositionModify(m_position.Ticket(),

               m_symbol.NormalizePrice(m_symbol.Bid()-DistTral*Point()),

               m_position.TakeProfit()))

               Print("Modify ",m_position.Ticket(),

                     " Position -> false. Result Retcode: ",m_trade.ResultRetcode(),

                     ", description of result: ",m_trade.ResultRetcodeDescription());

            return;

           }

        }

     }

//---

   return;

  }

//+------------------------------------------------------------------+

//| 59AB28O A >@45@>< SELL                                          |

//+------------------------------------------------------------------+

void obr_open_sell(int cl_s)

  {

//--- 70:@KB85 2> 871560=85 ?>B5@L

   if(cl_s==2)

     {

      m_trade.PositionClose(m_position.Ticket());

      return;

     }

//--- ?5@52>4 2 AB>?-;>AA0 157C1KB>:

   if(StopLossAfterBreakeven>99)

     {

      if((m_position.StopLoss()==0) || (m_position.StopLoss()>m_position.PriceOpen()))

        {

         if((m_symbol.Ask()+StopLossAfterBreakeven*Point())<(m_position.PriceOpen()-TakeProfitAfterBreakeven*Point()))

           {

            if(!m_trade.PositionModify(m_position.Ticket(),

               m_symbol.NormalizePrice(m_symbol.Ask()+StopLossAfterBreakeven*Point()),

               m_position.TakeProfit()))

               Print("Modify ",m_position.Ticket(),

                     " Position -> false. Result Retcode: ",m_trade.ResultRetcode(),

                     ", description of result: ",m_trade.ResultRetcodeDescription());

            return;

           }

        }

     }

//--- ?5@542865=85 B@59;8=3-AB>?0

   if(DistTral>99)

     {

      if((m_symbol.Ask()+DistTral*Point())<m_position.PriceOpen())

        {

         if((m_symbol.Ask()+DistTral*Point())<(m_position.StopLoss()-StepTral*Point()))

           {

            if(!m_trade.PositionModify(m_position.Ticket(),

               m_symbol.NormalizePrice(m_symbol.Ask()+DistTral*Point()),

               m_position.TakeProfit()))

               Print("Modify ",m_position.Ticket(),

                     " Position -> false. Result Retcode: ",m_trade.ResultRetcode(),

                     ", description of result: ",m_trade.ResultRetcodeDescription());

            return;

           }

        }

     }

//---

   return;

  }

//+------------------------------------------------------------------+

//| 0:@KB85 8 <>48D8:0F8O                                           |

//+------------------------------------------------------------------+

void perebor_orderov(int zak_b,int zak_s)

  {

   if(!RefreshRates())

      return;

   for(int i=PositionsTotal()-1;i>=0;i--)

      if(m_position.SelectByIndex(i)) // selects the position by index for further access to its properties

         if(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==m_magic)

           {

            if(m_position.PositionType()==POSITION_TYPE_BUY)

               obr_open_buy(zak_b);



            if(m_position.PositionType()==POSITION_TYPE_SELL)

               obr_open_sell(zak_s);

           }

//---

   return;

  }

//+------------------------------------------------------------------+

//| B:@KB85 BUY                                                     |

//+------------------------------------------------------------------+

void ystanovit_buy(string prich,int kf)

  {

   double sl=0.0;

   if(StopLoss>99)

      sl=m_symbol.Bid()-StopLoss*Point();



   double tp=0.0;

   if(TakeProfit>99)

      tp=m_symbol.Ask()+TakeProfit*Point();



   double lt=OrdinaryLot;



   if(kf>1)

     {

      //--- 5A;8 A>2?0;> =5A:>;L:> A83=0;>2 - >B:@K205< 42>9=>9 ;>B

      lt=LotCheck(lt*2);

     }

   if(lt>0.0)

      OpenBuy(sl,tp,lt,prich);

  }

//+------------------------------------------------------------------+

//| B:@KB85 SELL                                                    |

//+------------------------------------------------------------------+

void ystanovit_sel(string prich,int kf)

  {

   double sl=0.0;

   if(StopLoss>99)

      sl=m_symbol.Ask()+StopLoss*Point();



   double tp=0;

   if(TakeProfit>99)

      tp=m_symbol.Bid()-TakeProfit*Point();



   double lt=OrdinaryLot;



   if(kf>1)

     {

      //--- 5A;8 A>2?0;> =5A:>;L:> A83=0;>2 - >B:@K205< 42>9=>9 ;>B

      lt=LotCheck(lt*2);

     }

   if(lt>0.0)

      OpenSell(sl,tp,lt,prich);

  }

//+------------------------------------------------------------------+

//| Create Moving Average                                            |

//+------------------------------------------------------------------+

bool CreateMA(int &handle_iMA,const ENUM_TIMEFRAMES timeframe,const int ma_period)

  {

//--- create handle of the indicator iMA

   handle_iMA=iMA(m_symbol.Name(),timeframe,ma_period,0,MODE_EMA,PRICE_CLOSE);

//--- if the handle is not created 

   if(handle_iMA==INVALID_HANDLE)

     {

      //--- tell about the failure and output the error code 

      PrintFormat("Failed to create handle of the iMA indicator for the symbol %s/%s, error code %d",

                  m_symbol.Name(),

                  EnumToString(timeframe),

                  GetLastError());

      //--- the indicator is stopped early 

      return(false);

     }

//---

   return(true);

  }

//+------------------------------------------------------------------+

//| Get value of buffers for the iMA                                 |

//+------------------------------------------------------------------+

double iMAGet(int handle_iMA,const int index)

  {

   double MA[1];

//--- reset error code 

   ResetLastError();

//--- fill a part of the iMABuffer array with values from the indicator buffer that has 0 index 

   if(CopyBuffer(handle_iMA,0,index,1,MA)<0)

     {

      //--- if the copying fails, tell the error code 

      PrintFormat("Failed to copy data from the iMA indicator, error code %d",GetLastError());

      //--- quit with zero result - it means that the indicator is considered as not calculated 

      return(0.0);

     }

   return(MA[0]);

  }

//+------------------------------------------------------------------+

//| Get value of buffers for the iMA in the array                    |

//+------------------------------------------------------------------+

bool iMAGetArray(const int handle_iMA,const int start_pos,const int count,double &arr_buffer[])

  {

//---

   bool result=true;

   if(!ArrayIsDynamic(arr_buffer))

     {

      Print("This a no dynamic array!");

      return(false);

     }

   ArrayFree(arr_buffer);

   int       buffer_num=0;          // indicator buffer number 

//--- reset error code 

   ResetLastError();

//--- fill a part of the iMABuffer array with values from the indicator buffer that has 0 index 

   int copied=CopyBuffer(handle_iMA,buffer_num,start_pos,count,arr_buffer);

   if(copied<0)

     {

      //--- if the copying fails, tell the error code 

      PrintFormat("Failed to copy data from the iMA indicator, error code %d",GetLastError());

      //--- quit with zero result - it means that the indicator is considered as not calculated 

      return(false);

     }

   else if(copied<count)

     {

      PrintFormat("Moving Average indicator: %d elements from %d were copied",copied,count);

      DebugBreak();

      return(false);

     }

//---

   return(result);

  }

//+------------------------------------------------------------------+

//| Get value of buffers for the iStochastic                         |

//|  the buffer numbers are the following:                           |

//|   0 - MAIN_LINE, 1 - SIGNAL_LINE                                 |

//+------------------------------------------------------------------+

bool iStochasticGetArray(const int handle_iStochastic,const int buffer,const int start_pos,const int count,double &array[])

  {

//--- reset error code 

   ResetLastError();

//--- fill a part of the iStochastic array with values from the indicator buffer that has 0 index 

   int copy_buffer=CopyBuffer(handle_iStochastic,buffer,start_pos,count,array);

   if(copy_buffer<0)

     {

      //--- if the copying fails, tell the error code 

      PrintFormat("Failed to copy data from the iStochastic indicator, error code %d",GetLastError());

      //--- quit with false result - it means that the indicator is considered as not calculated 

      return(false);

     }

   else if(copy_buffer!=count)

     {

      //--- if it is copied less, than set 

      PrintFormat("%d elements have been requested, only %d are copied",count,copy_buffer);

      //--- quit with zero result - it means that the indicator is considered as not calculated 

      return(false);

     }

//---

   return(true);

  }

//+------------------------------------------------------------------+

//| Highest                                                          |

//+------------------------------------------------------------------+

bool Highest(int &bar_highest,double &price_highest,

             string symbol,

             ENUM_TIMEFRAMES timeframe,

             int type,

             int count=WHOLE_ARRAY,

             int start=0)

  {

   if(symbol==NULL)

      symbol=m_symbol.Name();

   if(timeframe==0)

      timeframe=Period();

   if(start<0)

      return(false);

   if(count<=0)

      count=Bars(symbol,timeframe);

   if(type==MODE_HIGH)

     {

      double High[];

      if(CopyHigh(symbol,timeframe,start,count,High)!=count)

         return(false);

      bar_highest    = ArrayMaximum(High);

      price_highest  = High[bar_highest];

      return(true);

     }

//---

   return(false);

  }

//+------------------------------------------------------------------+

//| Lowest                                                           |

//+------------------------------------------------------------------+

bool Lowest(int &bar_lowest,double &price_lowest,string symbol,

            ENUM_TIMEFRAMES timeframe,

            int type,

            int count=WHOLE_ARRAY,

            int start=0)

  {

   if(symbol==NULL)

      symbol=m_symbol.Name();

   if(timeframe==0)

      timeframe=Period();

   if(start<0)

      return(false);

   if(count<=0)

      count=Bars(symbol,timeframe);

   if(type==MODE_LOW)

     {

      double Low[];

      if(CopyLow(symbol,timeframe,start,count,Low)!=count)

         return(false);

      bar_lowest     = ArrayMinimum(Low);

      price_lowest   = Low[bar_lowest];

      return(true);

     }

//---

   return(false);

  }

//+------------------------------------------------------------------+

//| 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);

  }

//+------------------------------------------------------------------+

//| Open Buy position                                                |

//+------------------------------------------------------------------+

void OpenBuy(double sl,double tp,double lot,string comment)

  {

   sl=m_symbol.NormalizePrice(sl);

   tp=m_symbol.NormalizePrice(tp);

//--- check volume before OrderSend to avoid "not enough money" error (CTrade)

   double check_volume_lot=m_trade.CheckVolume(m_symbol.Name(),lot,m_symbol.Ask(),ORDER_TYPE_BUY);



   if(check_volume_lot!=0.0)

     {

      if(check_volume_lot>=lot)

        {

         if(m_trade.Buy(lot,m_symbol.Name(),m_symbol.Ask(),sl,tp,comment))

           {

            if(m_trade.ResultDeal()==0)

              {

               Print(__FUNCTION__,", #1 Buy -> false. Result Retcode: ",m_trade.ResultRetcode(),

                     ", description of result: ",m_trade.ResultRetcodeDescription());

               PrintResult(m_trade,m_symbol);

              }

            else

              {

               Print(__FUNCTION__,", #2 Buy -> true. Result Retcode: ",m_trade.ResultRetcode(),

                     ", description of result: ",m_trade.ResultRetcodeDescription());

               PrintResult(m_trade,m_symbol);

              }

           }

         else

           {

            Print(__FUNCTION__,", #3 Buy -> false. Result Retcode: ",m_trade.ResultRetcode(),

                  ", description of result: ",m_trade.ResultRetcodeDescription());

            PrintResult(m_trade,m_symbol);

           }

        }

      else

        {

         Print(__FUNCTION__,", ERROR: method CheckVolume (",DoubleToString(check_volume_lot,2),") ",

               "< Lot (",DoubleToString(lot,2),")");

         return;

        }

     }

   else

     {

      Print(__FUNCTION__,", ERROR: method CheckVolume returned the value of \"0.0\"");

      return;

     }

//---

  }

//+------------------------------------------------------------------+

//| Open Sell position                                               |

//+------------------------------------------------------------------+

void OpenSell(double sl,double tp,double lot,string comment)

  {

   sl=m_symbol.NormalizePrice(sl);

   tp=m_symbol.NormalizePrice(tp);

//--- check volume before OrderSend to avoid "not enough money" error (CTrade)

   double check_volume_lot=m_trade.CheckVolume(m_symbol.Name(),lot,m_symbol.Bid(),ORDER_TYPE_SELL);



   if(check_volume_lot!=0.0)

     {

      if(check_volume_lot>=lot)

        {

         if(m_trade.Sell(lot,m_symbol.Name(),m_symbol.Bid(),sl,tp,comment))

           {

            if(m_trade.ResultDeal()==0)

              {

               Print(__FUNCTION__,", #1 Sell -> false. Result Retcode: ",m_trade.ResultRetcode(),

                     ", description of result: ",m_trade.ResultRetcodeDescription());

               PrintResult(m_trade,m_symbol);

              }

            else

              {

               Print(__FUNCTION__,", #2 Sell -> true. Result Retcode: ",m_trade.ResultRetcode(),

                     ", description of result: ",m_trade.ResultRetcodeDescription());

               PrintResult(m_trade,m_symbol);

              }

           }

         else

           {

            Print(__FUNCTION__,", #3 Sell -> false. Result Retcode: ",m_trade.ResultRetcode(),

                  ", description of result: ",m_trade.ResultRetcodeDescription());

            PrintResult(m_trade,m_symbol);

           }

        }

      else

        {

         Print(__FUNCTION__,", ERROR: method CheckVolume (",DoubleToString(check_volume_lot,2),") ",

               "< Lot (",DoubleToString(lot,2),")");

         return;

        }

     }

   else

     {

      Print(__FUNCTION__,", ERROR: method CheckVolume returned the value of \"0.0\"");

      return;

     }

//---

  }

//+------------------------------------------------------------------+

//| Print CTrade result                                              |

//+------------------------------------------------------------------+

void PrintResult(CTrade &trade,CSymbolInfo &symbol)

  {

   Print("Code of request result: "+IntegerToString(trade.ResultRetcode()));

   Print("code of request result: "+trade.ResultRetcodeDescription());

   Print("deal ticket: "+IntegerToString(trade.ResultDeal()));

   Print("order ticket: "+IntegerToString(trade.ResultOrder()));

   Print("volume of deal or order: "+DoubleToString(trade.ResultVolume(),2));

   Print("price, confirmed by broker: "+DoubleToString(trade.ResultPrice(),symbol.Digits()));

   Print("current bid price: "+DoubleToString(trade.ResultBid(),symbol.Digits()));

   Print("current ask price: "+DoubleToString(trade.ResultAsk(),symbol.Digits()));

   Print("broker comment: "+trade.ResultComment());

  }

//+------------------------------------------------------------------+

//| Refreshes the symbol quotes data                                 |

//+------------------------------------------------------------------+

bool RefreshRates(void)

  {

//--- refresh rates

   if(!m_symbol.RefreshRates())

     {

      Print("RefreshRates error");

      return(false);

     }

//--- protection against the return value of "zero"

   if(m_symbol.Ask()==0 || m_symbol.Bid()==0)

      return(false);

//---

   return(true);

  }

//+------------------------------------------------------------------+

//| Check the correctness of the position volume                     |

//+------------------------------------------------------------------+

bool CheckVolumeValue(double volume,string &error_description)

  {

//--- minimal allowed volume for trade operations

   double min_volume=m_symbol.LotsMin();

   if(volume<min_volume)

     {

      if(TerminalInfoString(TERMINAL_LANGUAGE)=="Russian")

         error_description=StringFormat("1J5< <5=LH5 <8=8<0;L=> 4>?CAB8<>3> SYMBOL_VOLUME_MIN=%.2f",min_volume);

      else

         error_description=StringFormat("Volume is less than the minimal allowed SYMBOL_VOLUME_MIN=%.2f",min_volume);

      return(false);

     }

//--- maximal allowed volume of trade operations

   double max_volume=m_symbol.LotsMax();

   if(volume>max_volume)

     {

      if(TerminalInfoString(TERMINAL_LANGUAGE)=="Russian")

         error_description=StringFormat("1J5< 1>;LH5 <0:A8<0;L=> 4>?CAB8<>3> SYMBOL_VOLUME_MAX=%.2f",max_volume);

      else

         error_description=StringFormat("Volume is greater than the maximal allowed SYMBOL_VOLUME_MAX=%.2f",max_volume);

      return(false);

     }

//--- get minimal step of volume changing

   double volume_step=m_symbol.LotsStep();

   int ratio=(int)MathRound(volume/volume_step);

   if(MathAbs(ratio*volume_step-volume)>0.0000001)

     {

      if(TerminalInfoString(TERMINAL_LANGUAGE)=="Russian")

         error_description=StringFormat("1J5< =5 :@0B5= <8=8<0;L=><C H03C SYMBOL_VOLUME_STEP=%.2f, 1;8609H89 ?@028;L=K9 >1J5< %.2f",

                                        volume_step,ratio*volume_step);

      else

         error_description=StringFormat("Volume is not a multiple of the minimal step SYMBOL_VOLUME_STEP=%.2f, the closest correct volume is %.2f",

                                        volume_step,ratio*volume_step);

      return(false);

     }

   error_description="Correct volume value";

   return(true);

  }

//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---