Exp_ColorJFatl_Digit_NN3_MMRec

Author: Copyright © 2018, Nikolay Kositsin
0 Views
0 Downloads
0 Favorites
Exp_ColorJFatl_Digit_NN3_MMRec
ÿþ//+------------------------------------------------------------------+

//|                               Exp_ColorJFatl_Digit_NN3_MMRec.mq5 |

//|                               Copyright © 2018, Nikolay Kositsin | 

//|                              Khabarovsk,   farria@mail.redcom.ru | 

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

#property copyright "Copyright © 2018, Nikolay Kositsin"

#property link      "farria@mail.redcom.ru"

#property version   "1.00"

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

//  ">@3>2K5 0;3>@8B<K                           | 

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

#include <TradeAlgorithms.mqh>

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

//|  5@5G8A;5=85 4;O 20@80=B>2 @0AGQB0 ;>B0     |

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

/*enum MarginMode  - ?5@5G8A;5=85 >1JO2;5=> 2 D09;5 TradeAlgorithms.mqh

  {

   FREEMARGIN=0,     //MM >B A2>1>4=KE A@54AB2 =0 AGQB5

   BALANCE,          //MM >B 10;0=A0 A@54AB2 =0 AGQB5

   LOSSFREEMARGIN,   //MM ?> C1KB:0< >B A2>1>4=KE A@54AB2 =0 AGQB5

   LOSSBALANCE,      //MM ?> C1KB:0< >B 10;0=A0 A@54AB2 =0 AGQB5

   LOT               //>B 157 87<5=5=8O

  }; */

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

//|  >1JO2;5=85 ?5@5G8A;5=89                     |

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

enum Applied_price_ //"8? :>=AB0=BK

  {

   PRICE_CLOSE_ = 1,     //Close

   PRICE_OPEN_,          //Open

   PRICE_HIGH_,          //High

   PRICE_LOW_,           //Low

   PRICE_MEDIAN_,        //Median Price (HL/2)

   PRICE_TYPICAL_,       //Typical Price (HLC/3)

   PRICE_WEIGHTED_,      //Weighted Close (HLCC/4)

   PRICE_SIMPL_,         //Simpl Price (OC/2)

   PRICE_QUARTER_,       //Quarted Price (HLOC/4) 

   PRICE_TRENDFOLLOW0_,  //TrendFollow_1 Price 

   PRICE_TRENDFOLLOW1_,  //TrendFollow_2 Price

   PRICE_DEMARK_         //Dema

  };

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

//| E>4=K5 ?0@0<5B@K M:A?5@B0 4;O A             |

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

sinput string A_Trade="#?@02;5=85 B>@3>2;59 4;O ColorJFatl_Digit 1";    //+============== #  "   4;O ColorJFatl_Digit 1 ==============+  

input uint    A_BuyMagic=777;       //A Buy <038: =><5@

input uint    A_SellMagic=888;      //A Sell <038: =><5@

input uint    A_BuyLossMMTriger=2;  //A :>;8G5AB2> C1KB>G=KE A45;>: 2 Buy =0?@02;5=88 4;O C<5=LH5=8O MM

input uint    A_SellLossMMTriger=2; //A :>;8G5AB2> C1KB>G=KE A45;>: 2 Sell =0?@02;5=88 4;O C<5=LH5=8O MM

input double  A_SmallMM=0.01;       //A >;O D8=0=A>2KE @5AC@A>2 >B 45?>78B0 2 A45;:5 ?@8 C1KB:0E

input double  A_MM=0.1;             //A >;O D8=0=A>2KE @5AC@A>2 >B 45?>78B0 2 A45;:5 ?@8 =>@<0;L=>9 B>@3>2;5

input MarginMode A_MMMode=LOT;      //A A?>A>1 >?@545;5=8O @07<5@0 ;>B0

input uint    A_StopLoss_=3000;     //A AB>?;>AA 2 ?C=:B0E

input uint    A_TakeProfit_=10000;   //A B59:?@>D8B 2 ?C=:B0E

input uint    A_Deviation_=10;      //A <0:A. >B:;>=5=85 F5=K 2 ?C=:B0E

sinput string A_MustTrade=" 07@5H5=8O B>@3>2;8 4;O ColorJFatl_Digit 1"; //+==============   (/ "   ColorJFatl_Digit 1 ==============+  

input bool    A_BuyPosOpen=true;    //A  07@5H5=85 4;O 2E>40 2 ;>=3

input bool    A_SellPosOpen=true;   //A  07@5H5=85 4;O 2E>40 2 H>@B

input bool    A_SellPosClose=true;  //A  07@5H5=85 4;O 2KE>40 87 ;>=3>2

input bool    A_BuyPosClose=true;   //A  07@5H5=85 4;O 2KE>40 87 H>@B>2

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

//| E>4=K5 ?0@0<5B@K 8=48:0B>@0 4;O A           |

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

sinput string A_Input="0@0<5B@K 2E>40 4;O ColorJFatl_Digit 1";         //+===============  " + % 4;O ColorJFatl_Digit 1 ===============+  

input ENUM_TIMEFRAMES A_InpInd_Timeframe=PERIOD_D1; //A B09<D@59< 8=48:0B>@0

input int A_JLength=5;                              //A 3;C18=0 JMA A3;06820=8O                   

input int A_JPhase=-100;                            //A ?0@0<5B@ JMA A3;06820=8O,

//---- 87<5=ONI89AO 2 ?@545;0E -100 ... +100,

//---- 2;8O5B =0 :0G5AB2> ?5@5E>4=>3> ?@>F5AA0;

input Applied_price_ A_IPC=PRICE_CLOSE_;            //A F5=>20O :>=AB0=B0

input uint A_Digit=2;                               //A :>;8G5AB2> @07@O4>2 >:@C3;5=8O

input uint A_SignalBar=1;                           //A =><5@ 10@0 4;O ?>;CG5=8O A83=0;0 2E>40

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

//| E>4=K5 ?0@0<5B@K M:A?5@B0 4;O B             |

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

sinput string B_Trade="#?@02;5=85 B>@3>2;59 4;O ColorJFatl_Digit 2";    //+============== #  "   4;O ColorJFatl_Digit 2 ==============+  

input uint    B_BuyMagic=555;       //B Buy <038: =><5@

input uint    B_SellMagic=444;      //B Sell <038: =><5@

input uint    B_BuyLossMMTriger=2;  //B :>;8G5AB2> C1KB>G=KE A45;>: 2 Buy =0?@02;5=88 4;O C<5=LH5=8O MM

input uint    B_SellLossMMTriger=2; //B :>;8G5AB2> C1KB>G=KE A45;>: 2 Sell =0?@02;5=88 4;O C<5=LH5=8O MM

input double  B_SmallMM=0.01;       //B >;O D8=0=A>2KE @5AC@A>2 >B 45?>78B0 2 A45;:5 ?@8 C1KB:0E

input double  B_MM=0.1;             //B >;O D8=0=A>2KE @5AC@A>2 >B 45?>78B0 2 A45;:5 ?@8 =>@<0;L=>9 B>@3>2;5

input MarginMode B_MMMode=LOT;      //B A?>A>1 >?@545;5=8O @07<5@0 ;>B0

input uint    B_StopLoss_=2000;     //B AB>?;>AA 2 ?C=:B0E

input uint    B_TakeProfit_=6000;   //B B59:?@>D8B 2 ?C=:B0E

input uint    B_Deviation_=10;      //B <0:A. >B:;>=5=85 F5=K 2 ?C=:B0E

sinput string B_MustTrade=" 07@5H5=8O B>@3>2;8 4;O ColorJFatl_Digit 2"; //+==============   (/ "   ColorJFatl_Digit 2 ==============+  

input bool    B_BuyPosOpen=true;    //B  07@5H5=85 4;O 2E>40 2 ;>=3

input bool    B_SellPosOpen=true;   //B  07@5H5=85 4;O 2E>40 2 H>@B

input bool    B_SellPosClose=true;  //B  07@5H5=85 4;O 2KE>40 87 ;>=3>2

input bool    B_BuyPosClose=true;   //B  07@5H5=85 4;O 2KE>40 87 H>@B>2

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

//| E>4=K5 ?0@0<5B@K 8=48:0B>@0 4;O B           |

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

sinput string B_Input="0@0<5B@K 2E>40 4;O ColorJFatl_Digit 2";         //+===============  " + % 4;O ColorJFatl_Digit 2 ===============+  

input ENUM_TIMEFRAMES B_InpInd_Timeframe=PERIOD_H8; //B B09<D@59< 8=48:0B>@0

input int B_JLength=5;                              //B 3;C18=0 JMA A3;06820=8O                   

input int B_JPhase=-100;                            //B ?0@0<5B@ JMA A3;06820=8O,

//---- 87<5=ONI89AO 2 ?@545;0E -100 ... +100,

//---- 2;8O5B =0 :0G5AB2> ?5@5E>4=>3> ?@>F5AA0;

input Applied_price_ B_IPC=PRICE_CLOSE_;            //B F5=>20O :>=AB0=B0

input uint B_Digit=2;                               //B :>;8G5AB2> @07@O4>2 >:@C3;5=8O

input uint B_SignalBar=1;                           //B =><5@ 10@0 4;O ?>;CG5=8O A83=0;0 2E>40



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

//| E>4=K5 ?0@0<5B@K M:A?5@B0 4;O C             |

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

sinput string C_Trade="#?@02;5=85 B>@3>2;59 4;O ColorJFatl_Digit 3";    //+============== #  "   4;O ColorJFatl_Digit 3 ==============+  

input uint    C_BuyMagic=222;       //C Buy <038: =><5@

input uint    C_SellMagic=111;      //C Sell <038: =><5@

input uint    C_BuyLossMMTriger=3;  //C :>;8G5AB2> C1KB>G=KE A45;>: 2 Buy =0?@02;5=88 4;O C<5=LH5=8O MM

input uint    C_SellLossMMTriger=3; //C :>;8G5AB2> C1KB>G=KE A45;>: 2 Sell =0?@02;5=88 4;O C<5=LH5=8O MM

input double  C_SmallMM=0.01;       //C >;O D8=0=A>2KE @5AC@A>2 >B 45?>78B0 2 A45;:5 ?@8 C1KB:0E

input double  C_MM=0.1;             //C >;O D8=0=A>2KE @5AC@A>2 >B 45?>78B0 2 A45;:5 ?@8 =>@<0;L=>9 B>@3>2;5

input MarginMode C_MMMode=LOT;      //C A?>A>1 >?@545;5=8O @07<5@0 ;>B0

input uint    C_StopLoss_=1000;     //C AB>?;>AA 2 ?C=:B0E

input uint    C_TakeProfit_=3000;   //C B59:?@>D8B 2 ?C=:B0E

input uint    C_Deviation_=10;      //C <0:A. >B:;>=5=85 F5=K 2 ?C=:B0E

sinput string C_MustTrade=" 07@5H5=8O B>@3>2;8 4;O ColorJFatl_Digit 3"; //+==============   (/ "   ColorJFatl_Digit 3 ==============+  

input bool    C_BuyPosOpen=true;    //C  07@5H5=85 4;O 2E>40 2 ;>=3

input bool    C_SellPosOpen=true;   //C  07@5H5=85 4;O 2E>40 2 H>@B

input bool    C_SellPosClose=true;  //C  07@5H5=85 4;O 2KE>40 87 ;>=3>2

input bool    C_BuyPosClose=true;   //C  07@5H5=85 4;O 2KE>40 87 H>@B>2

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

//| E>4=K5 ?0@0<5B@K 8=48:0B>@0 4;O C           |

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

sinput string C_Input="0@0<5B@K 2E>40 4;O ColorJFatl_Digit 3";         //+===============  " + % 4;O ColorJFatl_Digit 3 ===============+  

input ENUM_TIMEFRAMES C_InpInd_Timeframe=PERIOD_H3; //C B09<D@59< 8=48:0B>@0

input int C_JLength=5;                              //C 3;C18=0 JMA A3;06820=8O                   

input int C_JPhase=-100;                            //C ?0@0<5B@ JMA A3;06820=8O,

//---- 87<5=ONI89AO 2 ?@545;0E -100 ... +100,

//---- 2;8O5B =0 :0G5AB2> ?5@5E>4=>3> ?@>F5AA0;

input Applied_price_ C_IPC=PRICE_CLOSE_;            //C F5=>20O :>=AB0=B0

input uint C_Digit=1;                               //C :>;8G5AB2> @07@O4>2 >:@C3;5=8O

input uint C_SignalBar=1;                           //C =><5@ 10@0 4;O ?>;CG5=8O A83=0;0 2E>40

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

//---- 1JO2;5=85 F5;KE ?5@5<5==KE 4;O E@0=5=8O ?5@8>40 3@0D8:0 2 A5:C=40E 

int A_TimeShiftSec,B_TimeShiftSec,C_TimeShiftSec;

//---- 1JO2;5=85 F5;KE ?5@5<5==KE 4;O E5=4;>2 8=48:0B>@>2

int A_InpInd_Handle,B_InpInd_Handle,C_InpInd_Handle;

//---- >1JO2;5=85 F5;KE ?5@5<5==KE =0G0;0 >BAG5B0 40==KE

int A_min_rates_total,B_min_rates_total,C_min_rates_total;

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

//| Expert initialization function                                   |

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

int OnInit()

  {

//---- ?>;CG5=85 E5=4;0 8=48:0B>@0 ColorJFatl_Digit A

   if(A_BuyPosOpen || A_SellPosOpen)

     {

      A_InpInd_Handle=iCustom(Symbol(),A_InpInd_Timeframe,"ColorJFatl_Digit","ColorJFatl_Digit_A",A_JLength,A_JPhase,A_IPC,A_Digit);

      if(A_InpInd_Handle==INVALID_HANDLE)

        {

         Print(" 5 C40;>AL ?>;CG8BL E5=4; 8=48:0B>@0 ColorJFatl_Digit A");

         return(INIT_FAILED);

        }

     }

//---- 8=8F80;870F8O ?5@5<5==>9 4;O E@0=5=8O ?5@8>40 3@0D8:0 2 A5:C=40E  

   A_TimeShiftSec=PeriodSeconds(A_InpInd_Timeframe);

//---- =8F80;870F8O ?5@5<5==KE =0G0;0 >BAGQB0 40==KE  

   A_min_rates_total=39+30+1;

   A_min_rates_total+=int(3+A_SignalBar);





//---- ?>;CG5=85 E5=4;0 8=48:0B>@0 ColorJFatl_Digit B

   if(B_BuyPosOpen || B_SellPosOpen)

     {

      B_InpInd_Handle=iCustom(Symbol(),B_InpInd_Timeframe,"ColorJFatl_Digit","ColorJFatl_Digit_B",B_JLength,B_JPhase,B_IPC,B_Digit);

      if(B_InpInd_Handle==INVALID_HANDLE)

        {

         Print(" 5 C40;>AL ?>;CG8BL E5=4; 8=48:0B>@0 ColorJFatl_Digit B");

         return(INIT_FAILED);

        }

     }

//---- 8=8F80;870F8O ?5@5<5==>9 4;O E@0=5=8O ?5@8>40 3@0D8:0 2 A5:C=40E  

   B_TimeShiftSec=PeriodSeconds(B_InpInd_Timeframe);

//---- =8F80;870F8O ?5@5<5==KE =0G0;0 >BAGQB0 40==KE  

   B_min_rates_total=39+30+1;

   B_min_rates_total+=int(3+B_SignalBar);



//---- ?>;CG5=85 E5=4;0 8=48:0B>@0 ColorJFatl_Digit C

   if(C_BuyPosOpen || C_SellPosOpen)

     {

      C_InpInd_Handle=iCustom(Symbol(),C_InpInd_Timeframe,"ColorJFatl_Digit","ColorJFatl_Digit_C",C_JLength,C_JPhase,C_IPC,C_Digit);

      if(C_InpInd_Handle==INVALID_HANDLE)

        {

         Print(" 5 C40;>AL ?>;CG8BL E5=4; 8=48:0B>@0 ColorJFatl_Digit C");

         return(INIT_FAILED);

        }

     }

//---- 8=8F80;870F8O ?5@5<5==>9 4;O E@0=5=8O ?5@8>40 3@0D8:0 2 A5:C=40E  

   C_TimeShiftSec=PeriodSeconds(C_InpInd_Timeframe);

//---- =8F80;870F8O ?5@5<5==KE =0G0;0 >BAGQB0 40==KE  

   C_min_rates_total=39+30+1;

   C_min_rates_total+=int(3+C_SignalBar);



//----

   return(INIT_SUCCEEDED);

  }

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

//| Expert deinitialization function                                 |

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

void OnDeinit(const int reason)

  {

//----

   GlobalVariableDel_(Symbol());

//----

  }

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

//| Expert tick function                                             |

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

void OnTick()

  {

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

//| ;>: C?@02;5=8O 4;O ColorJFatl_Digit A                |

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

   if(A_BuyPosOpen || A_SellPosOpen)

     {

      if(BarsCalculated(A_InpInd_Handle)<A_min_rates_total) return;

      LoadHistory(TimeCurrent()-PeriodSeconds(A_InpInd_Timeframe)-1,Symbol(),A_InpInd_Timeframe);

      

      //---- 1JO2;5=85 AB0B8G5A:8E ?5@5<5==KE  4;O SilverTrend

      static bool A_Recount=true;

      static bool A_BUY_Open=false,A_BUY_Close=false;

      static bool A_SELL_Open=false,A_SELL_Close=false;

      static datetime A_UpSignalTime,A_DnSignalTime;

      static CIsNewBar A_NB;

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

      //| ?@545;5=85 A83=0;>2 4;O ColorJFatl_Digit A  |

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

      if(!A_SignalBar || A_NB.IsNewBar(Symbol(),A_InpInd_Timeframe) || A_Recount) // ?@>25@:0 =0 ?>O2;5=85 =>2>3> 10@0

        {

         //---- >1=C;8< B>@3>2K5 A83=0;K

         A_BUY_Open=false;

         A_BUY_Close=false;

         A_SELL_Open=false;

         A_SELL_Close=false;

         A_Recount=false;

         //---- 1JO2;5=85 ;>:0;L=KE ?5@5<5==KE

         double Value[2];



         //---- :>?8@C5< 2=>2L ?>O282H85AO 40==K5 2 <0AA82K

         if(CopyBuffer(A_InpInd_Handle,1,A_SignalBar,2,Value)<=0) {A_Recount=true; return;}



         //---- >;CG8< A83=0;K 4;O ?>:C?:8

         if(Value[1]==2)

           {

            if(A_BuyPosOpen && Value[0]<2) A_BUY_Open=true;

            if(A_SellPosClose) A_SELL_Close=true;

            A_UpSignalTime=datetime(SeriesInfoInteger(Symbol(),A_InpInd_Timeframe,SERIES_LASTBAR_DATE))+A_TimeShiftSec;

           }



         //---- >;CG8< A83=0;K 4;O ?@>4068

         if(Value[1]==0)

           {

            if(A_SellPosOpen && Value[0]>0) A_SELL_Open=true;

            if(A_BuyPosClose) A_BUY_Close=true;

            A_DnSignalTime=datetime(SeriesInfoInteger(Symbol(),A_InpInd_Timeframe,SERIES_LASTBAR_DATE))+A_TimeShiftSec;

           }

        }

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

      //| !>25@H5=85 A45;>: 4;O ColorJFatl_Digit A     |

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

      //---- 0:@K205< ;>=3

      BuyPositionClose_M(A_BUY_Close,Symbol(),A_Deviation_,A_BuyMagic);



      //---- 0:@K205< H>@B   

      SellPositionClose_M(A_SELL_Close,Symbol(),A_Deviation_,A_SellMagic);



      double MM;

      //---- B:@K205< ;>=3

      if(A_BUY_Open)

        {

         MM=BuyTradeMMRecounter(A_BuyMagic,A_BuyLossMMTriger,A_SmallMM,A_MM);

         BuyPositionOpen_M1(A_BUY_Open,Symbol(),A_UpSignalTime,MM,A_MMMode,A_Deviation_,A_StopLoss_,A_TakeProfit_,A_BuyMagic);

        }



      //---- B:@K205< H>@B

      if(A_SELL_Open)

        {

         MM=SellTradeMMRecounter(A_SellMagic,A_SellLossMMTriger,A_SmallMM,A_MM);

         SellPositionOpen_M1(A_SELL_Open,Symbol(),A_DnSignalTime,MM,A_MMMode,A_Deviation_,A_StopLoss_,A_TakeProfit_,A_SellMagic);

        }

      //----

     }



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

//| ;>: C?@02;5=8O 4;O ColorJFatl_Digit B                |

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

   if(B_BuyPosOpen || B_SellPosOpen)

     {

      if(BarsCalculated(B_InpInd_Handle)<B_min_rates_total) return;

      LoadHistory(TimeCurrent()-PeriodSeconds(B_InpInd_Timeframe)-1,Symbol(),B_InpInd_Timeframe);

      

      //---- 1JO2;5=85 AB0B8G5A:8E ?5@5<5==KE  4;O SilverTrend

      static bool B_Recount=true;

      static bool B_BUY_Open=false,B_BUY_Close=false;

      static bool B_SELL_Open=false,B_SELL_Close=false;

      static datetime B_UpSignalTime,B_DnSignalTime;

      static CIsNewBar B_NB;

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

      //| ?@545;5=85 A83=0;>2 4;O ColorJFatl_Digit B  |

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

      if(!B_SignalBar || B_NB.IsNewBar(Symbol(),B_InpInd_Timeframe) || B_Recount) // ?@>25@:0 =0 ?>O2;5=85 =>2>3> 10@0

        {

         //---- >1=C;8< B>@3>2K5 A83=0;K

         B_BUY_Open=false;

         B_BUY_Close=false;

         B_SELL_Open=false;

         B_SELL_Close=false;

         B_Recount=false;

         //---- 1JO2;5=85 ;>:0;L=KE ?5@5<5==KE

         double Value[2];



         //---- :>?8@C5< 2=>2L ?>O282H85AO 40==K5 2 <0AA82K

         if(CopyBuffer(B_InpInd_Handle,1,B_SignalBar,2,Value)<=0) {B_Recount=true; return;}



         //---- >;CG8< A83=0;K 4;O ?>:C?:8

         if(Value[1]==2)

           {

            if(B_BuyPosOpen && Value[0]<2) B_BUY_Open=true;

            if(B_SellPosClose) B_SELL_Close=true;

            B_UpSignalTime=datetime(SeriesInfoInteger(Symbol(),B_InpInd_Timeframe,SERIES_LASTBAR_DATE))+B_TimeShiftSec;

           }



         //---- >;CG8< A83=0;K 4;O ?@>4068

         if(Value[1]==0)

           {

            if(B_SellPosOpen && Value[0]>0) B_SELL_Open=true;

            if(B_BuyPosClose) B_BUY_Close=true;

            B_DnSignalTime=datetime(SeriesInfoInteger(Symbol(),B_InpInd_Timeframe,SERIES_LASTBAR_DATE))+B_TimeShiftSec;

           }

        }

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

      //| !>25@H5=85 A45;>: 4;O ColorJFatl_Digit B     |

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

      //---- 0:@K205< ;>=3

      BuyPositionClose_M(B_BUY_Close,Symbol(),B_Deviation_,B_BuyMagic);



      //---- 0:@K205< H>@B   

      SellPositionClose_M(B_SELL_Close,Symbol(),B_Deviation_,B_SellMagic);



      double MM;

      //---- B:@K205< ;>=3

      if(B_BUY_Open)

        {

         MM=BuyTradeMMRecounter(B_BuyMagic,B_BuyLossMMTriger,B_SmallMM,B_MM);

         BuyPositionOpen_M1(B_BUY_Open,Symbol(),B_UpSignalTime,MM,B_MMMode,B_Deviation_,B_StopLoss_,B_TakeProfit_,B_BuyMagic);

        }



      //---- B:@K205< H>@B

      if(B_SELL_Open)

        {

         MM=SellTradeMMRecounter(B_SellMagic,B_SellLossMMTriger,B_SmallMM,B_MM);

         SellPositionOpen_M1(B_SELL_Open,Symbol(),B_DnSignalTime,MM,B_MMMode,B_Deviation_,B_StopLoss_,B_TakeProfit_,B_SellMagic);

        }

      //----

     }

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

//| ;>: C?@02;5=8O 4;O ColorJFatl_Digit C                |

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

   if(C_BuyPosOpen || C_SellPosOpen)

     {

      if(BarsCalculated(C_InpInd_Handle)<C_min_rates_total) return;

      LoadHistory(TimeCurrent()-PeriodSeconds(C_InpInd_Timeframe)-1,Symbol(),C_InpInd_Timeframe);

      

      //---- 1JO2;5=85 AB0B8G5A:8E ?5@5<5==KE  4;O SilverTrend

      static bool C_Recount=true;

      static bool C_BUY_Open=false,C_BUY_Close=false;

      static bool C_SELL_Open=false,C_SELL_Close=false;

      static datetime C_UpSignalTime,C_DnSignalTime;

      static CIsNewBar C_NB;

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

      //| ?@545;5=85 A83=0;>2 4;O ColorJFatl_Digit C  |

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

      if(!C_SignalBar || C_NB.IsNewBar(Symbol(),C_InpInd_Timeframe) || C_Recount) // ?@>25@:0 =0 ?>O2;5=85 =>2>3> 10@0

        {

         //---- >1=C;8< B>@3>2K5 A83=0;K

         C_BUY_Open=false;

         C_BUY_Close=false;

         C_SELL_Open=false;

         C_SELL_Close=false;

         C_Recount=false;

         //---- 1JO2;5=85 ;>:0;L=KE ?5@5<5==KE

         double Value[2];



         //---- :>?8@C5< 2=>2L ?>O282H85AO 40==K5 2 <0AA82K

         if(CopyBuffer(C_InpInd_Handle,1,C_SignalBar,2,Value)<=0) {C_Recount=true; return;}



         //---- >;CG8< A83=0;K 4;O ?>:C?:8

         if(Value[1]==2)

           {

            if(C_BuyPosOpen && Value[0]<2) C_BUY_Open=true;

            if(C_SellPosClose) C_SELL_Close=true;

            C_UpSignalTime=datetime(SeriesInfoInteger(Symbol(),C_InpInd_Timeframe,SERIES_LASTBAR_DATE))+C_TimeShiftSec;

           }



         //---- >;CG8< A83=0;K 4;O ?@>4068

         if(Value[1]==0)

           {

            if(C_SellPosOpen && Value[0]>0) C_SELL_Open=true;

            if(C_BuyPosClose) C_BUY_Close=true;

            C_DnSignalTime=datetime(SeriesInfoInteger(Symbol(),C_InpInd_Timeframe,SERIES_LASTBAR_DATE))+C_TimeShiftSec;

           }

        }

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

      //| !>25@H5=85 A45;>: 4;O ColorJFatl_Digit C     |

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

      //---- 0:@K205< ;>=3

      BuyPositionClose_M(C_BUY_Close,Symbol(),C_Deviation_,C_BuyMagic);



      //---- 0:@K205< H>@B   

      SellPositionClose_M(C_SELL_Close,Symbol(),C_Deviation_,C_SellMagic);



      double MM;

      //---- B:@K205< ;>=3

      if(C_BUY_Open)

        {

         MM=BuyTradeMMRecounter(C_BuyMagic,C_BuyLossMMTriger,C_SmallMM,C_MM);

         BuyPositionOpen_M1(C_BUY_Open,Symbol(),C_UpSignalTime,MM,C_MMMode,C_Deviation_,C_StopLoss_,C_TakeProfit_,C_BuyMagic);

        }



      //---- B:@K205< H>@B

      if(C_SELL_Open)

        {

         MM=SellTradeMMRecounter(C_SellMagic,C_SellLossMMTriger,C_SmallMM,C_MM);

         SellPositionOpen_M1(C_SELL_Open,Symbol(),C_DnSignalTime,MM,C_MMMode,C_Deviation_,C_StopLoss_,C_TakeProfit_,C_SellMagic);

        }

      //----

     }

  }

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

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 ---