cm_miner_1.00

Price Data Components
Series array that contains open prices of each bar
Orders Execution
Checks for the total of open ordersIt Closes Orders by itself It can change open orders parameters, due to possible stepping strategyIt automatically opens orders when conditions are reached
Miscellaneous
It issuies visual alerts to the screen
0 Views
0 Downloads
0 Favorites
cm_miner_1.00
ÿþ//+------------------------------------------------------------------+

#property copyright "Copyright © 2017, http://cmillion.ru"

#property link      "cmillion@narod.ru"

#property strict

#property description ">-H03C. (03 225@E   ?>:C?:0, H03 2=87   ?@>4060."

#property description "@>B82 H030. (03 225@E   ?@>4060, H03 2=87   ?>:C?:0."

#property description ">-H03C 8 ?@>B82 H030. (03 225@E   ?>:C?:0 8 ?@>4060, H03 2=87   ?@>4060 8 ?>:C?:0."

#property version   "1.00"



/*B:@KB85 >@45@>2:

"	>-H03C. (03 225@E - ?>:C?:0, H03 2=87 - ?@>4060. ;O @01>BK 2 B@5=45.

"	@>B82 H030. (03 225@E - ?@>4060, H03 2=87 - ?>:C?:0. ;O @01>BK 2> D;5B5.

"	>-H03C 8 ?@>B82 H030. (03 225@E - ?>:C?:0 8 ?@>4060, H03 2=87 - ?@>4060 8 ?>:C?:0. ;O 03@5AA82=>3> 2E>40 2 @K=>:.

(03 7040QBAO 2 ?C=:B0E.



$8;LB@K >B:@KB8O >@45@>2: 

$8;LB@>< A;C68B F5=0 >B:@KB8O A25G8 (open).  A;8 F5=0 2KH5 open - A>25B=8: ?>:C?05B, 5A;8 =865 - ?@>405B.

>6=> 2K18@0BL 2A5 4>ABC?=K5 A25G8:

M1, M5, M15, M30, H1, H4, D1, W1, MN.



B:@KB85 >@45@0

B:@KB85 ?@>8AE>48B >4=8< >@45@><, >1JQ<><  @02=K< ?@>872545=8N >1JQ<0 >@45@0 2 =0AB@>9:0E (0,01 ?>-C<>;G0=8N) =0 :>;8G5AB2> C@>2=59.

0?@8<5@, 2K1@0=K H1, H4, D1.

@8 MB>< H1-1K:, H4-<54254L, D1-<54254L

!>25B=8: ?@8 ?@>E>645=88 F5=K 225@E =0 1 H03 >B:@K205B buy = 0,01E1=0,01

?@8 ?@>E>645=88 F5=K 2=87 =0 1 H03 >B:@K205B sell = 0,01E2=0,02



3@0=8G5=85 :>;8G5AB20 548=>2@5<5==> >B:@KBKE >@45@>2 =0 1 C@>2=5.



0:@KB85 ?> ?@81K;8

"	?> 8=48284C0;L=><C 4;O :064>3> >@45@0 B59:?@>D8BC 2 ?C=:B0E.

"	Sell ?> AC<<0@=>9 ?@81K;8 2 20;NB5 45?>78B0.

"	Buy ?> AC<<0@=>9 ?@81K;8 2 20;NB5 45?>78B0.

"	A5 ?> AC<<0@=>9 ?@81K;8 2 20;NB5 45?>78B0.

*/

//--------------------------------------------------------------------

enum di 

{

   i1=1,    // >-H03C

   i2=2,    // @>B82 H030

   i3=3,    // >-H03C 8 ?@>B82 H030

};

enum tf 

{

   m1=1,    // M1

   m5=5,    // M5

   m15=15,  // M15

   m30=30,  // M30

   h1=60,   // G0A

   h4=240,  // 4 G0A0

   d1=1440, // 45=L

   w1=10080, // =545;O

   mn1=43200, // <5AOF

   t=0,     // =5 8A?>;L7>20BL

};

input bool    B>@3>2;O_>B_C@>2=59   = true;

input tf       LT1                  = 15;          //B>@3>2;O >B C@>2=O

input tf       LT2                  = 0;        //B>@3>2;O >B C@>2=O

input tf       LT3                  = 60;           //B>@3>2;O >B C@>2=O

input tf       LT4                  = 1440;           //B>@3>2;O >B C@>2=O

input tf       LT5                  = 0;           //B>@3>2;O >B C@>2=O

input tf       LT6                  = 0;           //B>@3>2;O >B C@>2=O



input string  ___            = "";

input di       DI                   = 1;           //B>@3>2;O

extern int     Step                 = 10;          //H03

extern bool    onelevel             = false;       //=5 AB028BL =0 >4=>< C@>2=5.

extern int     Takeprofit           = 0;           //B59:?@>D8B

extern double  CloseProfitB         = 50;          //70:@K20BL buy ?> AC<<0@=><C ?@>D8BC

extern double  CloseProfitS         = 50;          //70:@K20BL sell ?> AC<<0@=><C ?@>D8BC

extern double  CloseProfit          = 5;           //70:@K20BL 2A5 ?> AC<<0@=><C ?@>D8BC

extern double  Lot                  = 0.01;        //>1J5<

extern int     slippage             = 5;           // ?@>A:0;L7K20=85

extern int     Magic                = 1;



input color col = clrGreen;

//--------------------------------------------------------------------

double MINLOT,STOPLEVEL;

double Level;

//-------------------------------------------------------------------- 

int OnInit()

{ 

   string txt=NULL;

   if (DI==1) txt="B>@3>2;O ?> H03C";

   if (DI==2) txt="B>@3>2;O ?@>B82 H030";

   if (DI==3) txt=">-H03C 8 ?@>B82 H030";

   txt=StringConcatenate(txt,"\nH03 = ",Step);

   txt=StringConcatenate(txt,"\nB59:?@>D8B = ",Takeprofit);

   txt=StringConcatenate(txt,"\n70:@K20BL buy = ",CloseProfitB);

   txt=StringConcatenate(txt,"\n70:@K20BL sell = ",CloseProfitS);

   txt=StringConcatenate(txt,"\n70:@K20BL 2A5 = ",CloseProfit);

   txt=StringConcatenate(txt,"\n>1J5< = ",Lot);

   Comment(txt);

   EventSetTimer(1);

   RectLabelCreate(0,1,"cm fon",0,140,12,137,140,clrWhite,clrBlack);

   MINLOT = MarketInfo(Symbol(),MODE_MINLOT);

   Level=Bid;

   if (!B>@3>2;O_>B_C@>2=59) DrawLABEL("cm orders","157 C@>2=59",70,120,col,ANCHOR_CENTER);

   else DrawLABEL("cm orders","C@>2=8",70,125,col,ANCHOR_CENTER);

   DrawLABEL("cm Balance1","Balance",135,25,col,ANCHOR_LEFT);

   DrawLABEL("cm Equity1","Equity",135,40,col,ANCHOR_LEFT);

   DrawLABEL("cm FreeMargin1","FreeMargin",135,55,col,ANCHOR_LEFT);

   DrawLABEL("cm Profit B1","Buy",135,70,col,ANCHOR_LEFT);

   DrawLABEL("cm Profit S1","Sell",135,85,col,ANCHOR_LEFT);

   DrawLABEL("cm Profit A1","Profit",135,100,col,ANCHOR_LEFT);



   if (IsTesting())

   {

      if (LT1!=0 && LT1<Period()) {Comment(" ?0@0<5B@0E CAB0=>28B5 "$ =5 <5=55 B5:CI53>");return(INIT_FAILED);}

      if (LT2!=0 && LT2<Period()) {Comment(" ?0@0<5B@0E CAB0=>28B5 "$ =5 <5=55 B5:CI53>");return(INIT_FAILED);}

      if (LT3!=0 && LT3<Period()) {Comment(" ?0@0<5B@0E CAB0=>28B5 "$ =5 <5=55 B5:CI53>");return(INIT_FAILED);}

      if (LT4!=0 && LT4<Period()) {Comment(" ?0@0<5B@0E CAB0=>28B5 "$ =5 <5=55 B5:CI53>");return(INIT_FAILED);}

      if (LT5!=0 && LT5<Period()) {Comment(" ?0@0<5B@0E CAB0=>28B5 "$ =5 <5=55 B5:CI53>");return(INIT_FAILED);}

      if (LT6!=0 && LT6<Period()) {Comment(" ?0@0<5B@0E CAB0=>28B5 "$ =5 <5=55 B5:CI53>");return(INIT_FAILED);}

   }

   return(INIT_SUCCEEDED);

}

//-------------------------------------------------------------------

void OnTick() {OnTimer();}

void OnTimer()

{

   if (!IsTradeAllowed()) return;

   double LB=0,LS=0,Profit=0,ProfitB=0,ProfitS=0;

   double ProfitBpr=0,ProfitSpr=0,OOPminS=0,OOPmaxS=0,OOPminB=0,OOPmaxB=0,LossB=0,LossS=0;

   int TicketS=0,TicketB=0;

   STOPLEVEL=MarketInfo(Symbol(),MODE_STOPLEVEL);

   double prof,OL,OTP,OOP,StLo=0,SL=0,TP=0;

   int Ticket,i,b=0,s=0,tip;

   bool onelevelb=true;

   bool onelevels=true;

   for (i=0; i<OrdersTotal(); i++)

   {    

      if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))

      { 

         if (OrderSymbol()==Symbol())

         { 

            if (OrderMagicNumber() == Magic)

            { 

               tip = OrderType(); 

               OOP = NormalizeDouble(OrderOpenPrice(),Digits);

               Ticket=OrderTicket();

               prof=OrderProfit()+OrderSwap()+OrderCommission();

               OTP = NormalizeDouble(OrderTakeProfit(),Digits);

               OL = OrderLots();

               TP=OTP;

               if (tip==OP_BUY)             

               {  

                  ProfitB+=prof;

                  /*if (prof>0) ProfitBpr+=prof;

                  if ((OOP-Bid)/Point>MinLoss) 

                  {

                     if (TPer==2 && (OOPminB>OOP || OOPminB==0)) {OOPminB=OOP;TicketB=Ticket;LossB=prof;}

                     if (TPer==1 && (OOPmaxB<OOP || OOPmaxB==0)) {OOPmaxB=OOP;TicketB=Ticket;LossB=prof;}//40;L=89 

                  }*/

                  if (onelevel && MathAbs(OOP-Ask)/Point<Step) onelevelb=false;

                  b++; LB+=OL;

                  if (Takeprofit!=0 && Bid>=OOP + Takeprofit * Point) 

                  {

                     if (OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,Digits),slippage,clrNONE)) continue;

                  }

                  if (OTP==0 && Takeprofit>=STOPLEVEL && Takeprofit!=0)

                  {

                     TP = NormalizeDouble(OOP + Takeprofit * Point,Digits);

                  } 

                  if (TP != OTP)

                  {  

                     Print("Takeprofit buy ");

                     if (!OrderModify(Ticket,OOP,0,TP,0,clrNONE)) Print("Error OrderModify <<",Error(GetLastError()),">> ");

                  }

               }                                         

               if (tip==OP_SELL)        

               {

                  ProfitS+=prof;

                  /*if (prof>0) ProfitSpr+=prof;

                  if ((Ask-OOP)/Point>MinLoss) 

                  {

                     if (TPer==1 && (OOPminS>OOP || OOPminS==0)) {OOPminS=OOP;TicketS=Ticket;LossS=prof;}//40;L=89

                     if (TPer==2 && (OOPmaxS<OOP || OOPmaxS==0)) {OOPmaxS=OOP;TicketS=Ticket;LossS=prof;}

                  }*/

                  if (onelevel && MathAbs(OOP-Bid)/Point<Step) onelevels=false;

                  s++;LS+=OL;

                  if (Takeprofit!=0 && Ask<=OOP - Takeprofit * Point) 

                  {

                     Print("Takeprofit sell ");

                     if (OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,Digits),slippage,clrNONE)) continue;

                  }

                  if (OTP==0 && Takeprofit>=STOPLEVEL && Takeprofit!=0)

                  {

                     TP = NormalizeDouble(OOP - Takeprofit * Point,Digits);

                  }

                  if (TP != OTP)

                  {  

                     if (!OrderModify(Ticket,OOP,0,TP,0,clrNONE)) Print("Error OrderModify <<",Error(GetLastError()),">> ");

                  }

               }

            }

         }

      }

   }   

   //---

   int trendb=0;

   int trends=0;

   if (B>@3>2;O_>B_C@>2=59)

   {

      int x=10;

      if (LT1!=0) {if (Bid<iOpen(NULL,LT1,0)) trends++; else trendb++; DrawLABEL("cm orders 1",StrPer(LT1),10+x,140,Bid<iOpen(NULL,LT1,0)?clrRed:clrBlue,ANCHOR_CENTER);x+=20;}

      if (LT2!=0) {if (Bid<iOpen(NULL,LT2,0)) trends++; else trendb++; DrawLABEL("cm orders 2",StrPer(LT2),10+x,140,Bid<iOpen(NULL,LT2,0)?clrRed:clrBlue,ANCHOR_CENTER);x+=20;}

      if (LT3!=0) {if (Bid<iOpen(NULL,LT3,0)) trends++; else trendb++; DrawLABEL("cm orders 3",StrPer(LT3),10+x,140,Bid<iOpen(NULL,LT3,0)?clrRed:clrBlue,ANCHOR_CENTER);x+=20;}

      if (LT4!=0) {if (Bid<iOpen(NULL,LT4,0)) trends++; else trendb++; DrawLABEL("cm orders 4",StrPer(LT4),10+x,140,Bid<iOpen(NULL,LT4,0)?clrRed:clrBlue,ANCHOR_CENTER);x+=20;}

      if (LT5!=0) {if (Bid<iOpen(NULL,LT5,0)) trends++; else trendb++; DrawLABEL("cm orders 5",StrPer(LT5),10+x,140,Bid<iOpen(NULL,LT5,0)?clrRed:clrBlue,ANCHOR_CENTER);x+=20;}

      if (LT6!=0) {if (Bid<iOpen(NULL,LT6,0)) trends++; else trendb++; DrawLABEL("cm orders 6",StrPer(LT6),10+x,140,Bid<iOpen(NULL,LT6,0)?clrRed:clrBlue,ANCHOR_CENTER);}

   }

   else {trendb=1;trends=1;}

   

   

   bool buy=false;

   bool sell=false;

   if (((DI==2 || DI==3) && Bid<=Level-Step*Point) || ((DI==1 || DI==3) && Bid>=Level+Step*Point)) buy=true;

   if (((DI==2 || DI==3) && Bid>=Level+Step*Point) || ((DI==1 || DI==3) && Bid<=Level-Step*Point)) sell=true;

   DrawHLINE("cm Level",Level,clrGray);



   if (buy)

   {

      if (onelevelb)

      {

         if (trendb>0)

         {

            if (OrderSend(Symbol(),OP_BUY, Lot*trendb,NormalizeDouble(Ask,Digits),slippage,0,0,NULL,Magic,0,clrNONE)!=-1) {Level=Bid;}

            else Print("H81:0 >B:@KB8O >@45@0 <<",Error(GetLastError()),">>  ");

         }

         else {Level=Bid;}

      }

      else {Level=Bid;}

   }

   if (sell)

   {

      if (onelevels)

      {

         if (trends>0)

         {

            if (OrderSend(Symbol(),OP_SELL,Lot*trends,NormalizeDouble(Bid,Digits),slippage,0,0,NULL,Magic,0,clrNONE)!=-1) {Level=Bid;}

            else Print("H81:0 >B:@KB8O >@45@0 <<",Error(GetLastError()),">>  ");

         }

         else {Level=Bid;}

      }

      else {Level=Bid;}

   }

   Profit = ProfitB + ProfitS;

   DrawLABEL("cm Balance",DoubleToStr(AccountBalance(),2),10,25,col);

   DrawLABEL("cm Equity",DoubleToStr(AccountEquity(),2),10,40,col);

   DrawLABEL("cm FreeMargin",DoubleToStr(AccountFreeMargin(),2),10,55,col);

   DrawLABEL("cm Profit B",DoubleToStr(ProfitB,2),10,70,Color(ProfitB<0,clrRed,col),ANCHOR_RIGHT);

   DrawLABEL("cm Profit S",DoubleToStr(ProfitS,2),10,85,Color(ProfitS<0,clrRed,col),ANCHOR_RIGHT);

   DrawLABEL("cm Profit A",DoubleToStr(Profit,2),10,100,Color(Profit<0,clrRed,col),ANCHOR_RIGHT);

   DrawLABEL("cm Profit B1",StringConcatenate(b," Buy ",DoubleToStr(LB,2)),135,70,col,ANCHOR_LEFT);

   DrawLABEL("cm Profit S1",StringConcatenate(s," Sell ",DoubleToStr(LS,2)),135,85,col,ANCHOR_LEFT);



   if (CloseProfit!=0) 

   {

      if (Profit>=CloseProfit) 

      {

         Print("0:@KB85 2A5E ?@8 4>AB865=88 ?@81K;8 ",DoubleToStr(Profit,2));

         CloseAll(-1);

         return;

      }

   }

   if (CloseProfitS!=0) 

   {

      if (ProfitS>=CloseProfitS) 

      {

         Print("0:@KB85 sell ?@8 4>AB865=88 ?@81K;8 ",DoubleToStr(ProfitS,2));

         CloseAll(OP_SELL);

         return;

      }

   }

   if (CloseProfitB!=0) 

   {

      if (ProfitB>=CloseProfitB) 

      {

         Print("0:@KB85 buy ?@8 4>AB865=88 ?@81K;8 ",DoubleToStr(ProfitB,2));

         CloseAll(OP_BUY);

         return;

      }

   }

return;

}

//--------------------------------------------------------------------

color Color(bool P,color a,color b)

{

   if (P) return(a);

   else return(b);

}

//------------------------------------------------------------------

void DrawLABEL(string name, string Name, int X, int Y, color clr,ENUM_ANCHOR_POINT align=ANCHOR_RIGHT)

{

   if (ObjectFind(name)==-1)

   {

      ObjectCreate(name, OBJ_LABEL, 0, 0, 0);

      ObjectSet(name, OBJPROP_CORNER, 1);

      ObjectSet(name, OBJPROP_XDISTANCE, X);

      ObjectSet(name, OBJPROP_YDISTANCE, Y);

      ObjectSetInteger(0,name,OBJPROP_SELECTABLE,false);

      ObjectSetInteger(0,name,OBJPROP_SELECTED,false);

      ObjectSetInteger(0,name,OBJPROP_HIDDEN,true);

      ObjectSetInteger(0,name,OBJPROP_ANCHOR,align); 

   }

   ObjectSetText(name,Name,8,"Arial",clr);

}

//--------------------------------------------------------------------

void OnDeinit(const int reason)

{

   EventKillTimer();

   if (!IsTesting())

   {

      ObjectsDeleteAll(0,"cm");

      Comment("");

   }

}

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

bool CloseAll(int tip, bool prof=false)

{

   bool error=true;

   int OMN,j,err,nn=0,OT;

   while(true)

   {

      for (j = OrdersTotal()-1; j >= 0; j--)

      {

         if (OrderSelect(j, SELECT_BY_POS))

         {

            OMN=OrderMagicNumber();

            if (OrderSymbol() == Symbol() && OMN == Magic)

            {

               if (prof && OrderProfit()<0) continue;

               OT = OrderType();

               if (tip!=-1 && tip!=OT) continue;

               if (OT==OP_BUY) 

               {

                  error=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,Digits),slippage,Blue);

               }

               if (OT==OP_SELL) 

               {

                  error=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,Digits),slippage,Red);

               }

               if (!error) 

               {

                  err = GetLastError();

                  if (err<2) continue;

                  if (err==129) 

                  {

                     RefreshRates();

                     continue;

                  }

                  if (err==146) 

                  {

                     if (IsTradeContextBusy()) Sleep(2000);

                     continue;

                  }

                  Print("H81:0 ",err," 70:@KB8O >@45@0 N ",OrderTicket(),"     ",TimeToStr(TimeCurrent(),TIME_SECONDS));

               }

            }

         }

      }

      int n=0;

      for (j = 0; j < OrdersTotal(); j++)

      {

         if (OrderSelect(j, SELECT_BY_POS))

         {

            OMN=OrderMagicNumber();

            if (OrderSymbol() == Symbol() && OMN == Magic)

            {

               if (prof && OrderProfit()<0) continue;

               if (tip!=-1 && tip!=OrderType()) continue;

               n++;

            }

         }  

      }

      if (n==0) break;

      nn++;

      if (nn>10) 

      {

         Alert(Symbol()," 5 C40;>AL 70:@KBL 2A5 A45;:8, >AB0;>AL 5I5 ",n);

         return(0);

      }

      Sleep(1000);

      RefreshRates();

   }

   return(1);

}

//--------------------------------------------------------------------

string Error(int code)

{

   switch(code)

   {

      case 0:   return("5B >H81>:");

      case 1:   return("5B >H81:8, => @57C;LB0B =58725AB5=");                            

      case 2:   return("1I0O >H81:0");                                                   

      case 3:   return("5?@028;L=K5 ?0@0<5B@K");                                         

      case 4:   return("">@3>2K9 A5@25@ 70=OB");                                          

      case 5:   return("!B0@0O 25@A8O :;85=BA:>3> B5@<8=0;0");                            

      case 6:   return("5B A2O78 A B>@3>2K< A5@25@><");                                  

      case 7:   return("54>AB0B>G=> ?@02");                                              

      case 8:   return("!;8H:>< G0ABK5 70?@>AK");                                         

      case 9:   return("54>?CAB8<0O >?5@0F8O =0@CH0NI0O DC=:F8>=8@>20=85 A5@25@0");      

      case 64:  return("!G5B 701;>:8@>20=");                                              

      case 65:  return("5?@028;L=K9 =><5@ AG5B0");                                       

      case 128: return("AB5: A@>: >6840=8O A>25@H5=8O A45;:8");                          

      case 129: return("5?@028;L=0O F5=0");                                              

      case 130: return("5?@028;L=K5 AB>?K");                                             

      case 131: return("5?@028;L=K9 >1J5<");                                             

      case 132: return(" K=>: 70:@KB");                                                   

      case 133: return("">@3>2;O 70?@5I5=0");                                               

      case 134: return("54>AB0B>G=> 45=53 4;O A>25@H5=8O >?5@0F88");                     

      case 135: return("&5=0 87<5=8;0AL");                                                

      case 136: return("5B F5=");                                                        

      case 137: return("@>:5@ 70=OB");                                                   

      case 138: return(">2K5 F5=K");                                                     

      case 139: return("@45@ 701;>:8@>20= 8 C65 >1@010BK205BAO");                        

      case 140: return(" 07@5H5=0 B>;L:> ?>:C?:0");                                       

      case 141: return("!;8H:>< <=>3> 70?@>A>2");                                         

      case 145: return(">48D8:0F8O 70?@5I5=0, B0: :0: >@45@ A;8H:>< 1;87>: : @K=:C");    

      case 146: return(">4A8AB5<0 B>@3>2;8 70=OB0");                                     

      case 147: return("A?>;L7>20=85 40BK 8AB5G5=8O >@45@0 70?@5I5=> 1@>:5@><");         

      case 148: return(">;8G5AB2> >B:@KBKE 8 >B;>65==KE >@45@>2 4>AB83;> ?@545;0, CAB0=>2;5==>3> 1@>:5@><.");

      default:   return(StringConcatenate("H81:0 ",code," =58725AB=0 "));

   }

}

//--------------------------------------------------------------------

void DrawHLINE(string name,double p, color clr=clrGray, bool SELECTABLE=false, bool SELECTED=false)

{

   if (ObjectFind(name)!=-1) ObjectSetDouble(0,name,OBJPROP_PRICE,p);

   else

   {

      ObjectCreate(name, OBJ_HLINE, 0, 0, p);

      ObjectSetInteger(0,name,OBJPROP_STYLE,0);

      ObjectSetInteger(0,name,OBJPROP_COLOR,clr);

      ObjectSetInteger(0,name,OBJPROP_SELECTABLE,SELECTABLE);

      ObjectSetInteger(0,name,OBJPROP_SELECTED,SELECTED);

      ObjectSetInteger(0,name,OBJPROP_HIDDEN,true);

   }

}

//--------------------------------------------------------------------

string StrPer(int per)

{

   if (per == 0) per = Period();

   if (per == 1)     return("M1");

   if (per == 5)     return("M5");

   if (per == 15)    return("M15");

   if (per == 30)    return("M30");

   if (per == 60)    return("H1");

   if (per == 240)   return("H4");

   if (per == 1440)  return("D1");

   if (per == 10080) return("W1");

   return("MN1");

}

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

bool RectLabelCreate(const long             chart_ID=0,               // ID 3@0D8:0

                     const long           CORNER=CORNER_RIGHT_UPPER,         // C3>; 

                     const string           name="RectLabel",         // 8<O <5B:8

                     const int              sub_window=0,             // =><5@ ?>4>:=0

                     const long              x=0,                     // :>>@48=0B0 ?> >A8 X

                     const long              y=0,                     // :>>@48=0B0 ?> >A8 y

                     const int              width=50,                 // H8@8=0

                     const int              height=18,                // 2KA>B0

                     const color            back_clr=clrWhite,        // F25B D>=0

                     const color            clr=clrBlack,             // F25B ?;>A:>9 3@0=8FK (Flat)

                     const ENUM_LINE_STYLE  style=STYLE_SOLID,        // AB8;L ?;>A:>9 3@0=8FK

                     const int              line_width=1,             // B>;I8=0 ?;>A:>9 3@0=8FK

                     const bool             back=false,               // =0 704=5< ?;0=5

                     const bool             selection=false,          // 2K45;8BL 4;O ?5@5<5I5=89

                     const bool             hidden=true,              // A:@KB 2 A?8A:5 >1J5:B>2

                     const long             z_order=0)                // ?@8>@8B5B =0 =060B85 <KHLN

  {

   ResetLastError();

   if (ObjectFind(chart_ID,name)==-1)

   {

      ObjectCreate(chart_ID,name,OBJ_RECTANGLE_LABEL,sub_window,0,0);

      ObjectSetInteger(chart_ID,name,OBJPROP_BORDER_TYPE,BORDER_FLAT);

      ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,CORNER);

      ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style);

      ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,line_width);

      ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);

      ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);

      ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);

      ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);

      ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);

      //ObjectSetInteger(chart_ID,name,OBJPROP_ALIGN,ALIGN_RIGHT); 

   }

   ObjectSetInteger(chart_ID,name,OBJPROP_BGCOLOR,back_clr);

   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);

   ObjectSetInteger(chart_ID,name,OBJPROP_XSIZE,width);

   ObjectSetInteger(chart_ID,name,OBJPROP_YSIZE,height);

   ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);

   ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y);

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