PowerLine_Strategy_v7

Author: Copyright 2020, Sergey Grigorovich
3 Views
0 Downloads
0 Favorites
PowerLine_Strategy_v7
ÿþ//+------------------------------------------------------------------+

//|                                           PowerLine_Strategy.mq5 |

//|                               Copyright 2020, Sergey Grigorovich |

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

//==================================================================================================================

// 5@5< :>B8@>2:C 8 ?>4AG8BK205< A:>;L:> @07 F5=0(10@K) ?5@5A5:0;0 5Q.                                           //

// 0 >A=>20=88 MB8E 40==KE @8AC5< @0D8: !8;K.                                                                   //

// ?@545;O5< %(8<C<) @0D8:0 !8;K - MB> 7=0G8<K9 C@>25=L, &5;L(Target)!                                        //

// &5;L(Target) - MB> :>B8@>2:0 : :>B>@>9 @K=>:(B@5945@K) AB@5<8BAO!.                                             //

// A;8 &5;L(Target) 2KH5 =K=5H=59 F5=K(Ask), 7=0G8B =04> >:C?0BL(BUY),                                          //

// 5A;8 &5;L(Target) =865 =K=5H=59 F5=K(Bid), 7=0G8B =04> @>4020BL(SELL).                                        //

// ;O A8BC0F88 5A;8 @K=>: ?>H5; ?@>B82 0A(CE>48< 2 <8=CA),                                                      //

// 8I5< =>2K5 %(8<C<K) =0 @82>9 !8;K 4;O >B:@KB8O 4>?>;=8B5;L=KE ?>78F89(>@45@>2).                             //

// (#A8;8205< =0H5 =0?@02;5=85 B>@3>2;8, C25;8G820O >1J5< 4>?>;=8B5;L=KE >@45@>2 242>5!) > ?@8=F8?C 0@B8=359;0. //

//  0AAG8BK205< =0G0;L=K9 >1J5< ?>78F88(Lot), 0E ?@>A04:C(Loss), 0E ?@81K;L(Profit).                            //

//  0AAG8BK205< @8A:8 (Profit/Loss).                                                                              //

// 0 >A=>20=88 MB8E 40==KE ?@8=8<05< @5H5=85 ">@3>20BL 8;8 5B!                                                  //

//==================================================================================================================



#property copyright "Copyright 2020, Sergey Grigorovich"

#property version   "7.0"



#property description "5@5< :>B8@>2:C 8 ?>4AG8BK205< A:>;L:> @07 F5=0(10@K) ?5@5A5:0;0 5Q."

#property script_show_inputs



//  8AC5< 3@0D8: A8;K (0/5B)

enum power_line_

  {

   Y=0,   // Yes

   N=1,   // No

  };

// >:07K205< C@>2=8 &5;8(Target), B:@KB8O 4>?.?>78F89 0@B8=359; (0/5B)

enum buy_sell_

  {

   Y=0,   // Yes

   N=1,    // No

  };

//(4>102;5=> ?> ?@>AL15 ?>;L7>20B5;59)

input datetime datetime_=D'1970.01.01';      // 22>4 =0G0;L=>9 40BK 4;O 0=0;870 D'2018.12.03'

input power_line_ power_line=0;              // @0D8: A8;K (0/5B)

input buy_sell_ buy_sell=0;                  // #@>2=8 4;O B>@3>2;8 (0/5B)

input double account=10000;                  // !G5B ($, Eur, ...)





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

//| 0G0;> DC=:F88 A0<>3> A:@8?B0                                    |

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

void OnStart()

  {

   if(_Period<PERIOD_D1)

     {

      MessageBox("5@8>4 40==KE(3@0D8:0) 4>;65= 1KBL(C25;8G5=): 5=L, 545;O 8;8 5AOF !!!", "Alert");

      return;

     }

   int bars=iBarShift(_Symbol, _Period, datetime_, false);

   int error=GetLastError();

   if(error!=0)

     {

      PrintFormat("0?@0H8205<0O 40B0 %s "+

                  "4;O %s %s 2 4>ABC?=>9 8AB>@88 =5 =0945=0! H81:0: ",

                  error);

      return;

     }

   color color_power=clrMediumSpringGreen;   //  &25B ;8=88 A8;K

   color color_buy=clrDodgerBlue;            //  &25B BUY

   color color_sell=clrOrangeRed;            //  &25B SELL

   color color_text=clrWhiteSmoke;           //  &25B LABEL (B5:AB0)





   int digits=(int)SymbolInfoInteger(_Symbol, SYMBOL_DIGITS);

   double step=SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_SIZE);

   double higest=iHigh(_Symbol, Period(), iHighest(NULL, 0, MODE_HIGH, bars, 0));

   double lowest=iLow(_Symbol, Period(), iLowest(NULL, 0, MODE_LOW, bars, 0));

   double ask=SymbolInfoDouble(_Symbol, SYMBOL_ASK);

   double bid=SymbolInfoDouble(_Symbol, SYMBOL_BID);

   double account_my=account;



   int n_martingale=2;                       // % :>;;8G5AB2> ;8=89 A8;K ?> 0@B8=359;(C)

   int martingale=2;                         // 0 A:>;L:> C25;8G820BL(C<=>60BL) ?>A;54CNI85 >@45@0 ?> 0@B8=359;(C)

   double window_for_avg=0.02;               // @>F5=B A3;06820=8O ;8=89 A8;K





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

//

//******************** "  $ ****************************

//

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





//--- G8I05< 3@0D8:

   ObjectsDeleteAll(0, 0, -1);

//--- 0HB01 3@0D8:0 (5A;8 >H81:0, B> 2K2545< A>>1I5=85 2 6C@=0; "-:A?5@BK"!)

   if(!ChartSetInteger(0, CHART_SCALE, 0, 1))

     {

      Print(__FUNCTION__+", Error Code = ", GetLastError());

     }

   if(!ChartSetInteger(0, CHART_SCALEFIX, 0, true))

     {

      Print(__FUNCTION__+", Error Code = ", GetLastError());

     }

   if(!ChartSetDouble(0, CHART_FIXED_MAX, higest))

     {

      Print(__FUNCTION__+", Error Code = ", GetLastError());

     }

   if(!ChartSetDouble(0, CHART_FIXED_MIN, lowest))

     {

      Print(__FUNCTION__+", Error Code = ", GetLastError());

     }

   ChartRedraw(0);





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

//

//********************  !!'"+ (# ) !+ ***************

//

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





// --- !>7405< 8 :>?8@C5< High,Low 2 <0AA82K high,low

   double high[], low[];

   ArrayResize(high, bars);

   ArrayResize(low, bars);

   int n_high=CopyHigh(_Symbol, _Period, 0, bars, high);

   int n_low=CopyLow(_Symbol, _Period, 0, bars, low);

   if(n_high<0 || n_low<0)                         //(5A;8 >H81:0, B> 2K2545< A>>1I5=85 2 6C@=0; "-:A?5@BK" 8 7025@H05< ?@>3@0<<C!)

     {

      Print("Copy Data ERROR!");

      return;

     }

// --- !>7405< <0AA82K ?> >AO<(H:0;0<) X/Y

   int            power[];

   double         quote[];

   int n_line=(int)(MathRound((higest-lowest)/step)+1);

   ArrayResize(power, n_line);

   ArrayResize(quote, n_line);

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

     {

      quote[i]=lowest+step*i;

      power[i]=0;

      for(int ii=0; ii<n_high; ii++)

        {

         if(high[ii]>=quote[i] && quote[i]>=low[ii])

            power[i]+=1;

        }

     }

   ArrayFree(high);                                // A2>1>6405< ?0<OBL >B <0AA820 high

   ArrayFree(low);                                 // A2>1>6405< ?0<OBL >B <0AA820 low



   int i_target=ArrayMaximum(power, 0, WHOLE_ARRAY); // 0:A8<C<



//---  8AC5< :@82CN ;8=89 A8;K

   if(power_line==0)

     {

      for(int ii=0; ii<n_line-1; ii++)

         DrawText(DoubleToString(quote[ii], digits)+" "+IntegerToString(power[ii], 0, ' '), "*", 8, iTime(_Symbol, _Period, power[ii]), quote[ii], color_power);

     }

//---  8AC5< C@>2=L F5;8 70:@KB8O ?>78F89

   if(buy_sell==0)

     {

      if(quote[i_target]>ask)  // BUY

        {

         //         trade="BUY";

         DrawLine("BUY (Target) ", 0, quote[i_target], power[i_target], quote[i_target], color_buy);

         DrawText("Buy Target", "BUY (Target) "+DoubleToString(quote[i_target], digits), 20, TimeCurrent(), quote[i_target], color_buy);

         Print("BUY (Target)= "+DoubleToString(quote[i_target], digits));

         Comment("PowerLine: ", power[i_target], "    Price: ", NormalizeDouble(quote[i_target], digits), "     BUY");

        }

      if(quote[i_target]<bid)  // SELL

        {

         //         trade="SELL";

         DrawLine("SELL (Target) ", 0, quote[i_target], power[i_target], quote[i_target], color_sell);

         DrawText("Sell Target", "SELL (Target) "+DoubleToString(quote[i_target], digits), 20, TimeCurrent(), quote[i_target], color_sell);

         Print("SELL (Target)= "+DoubleToString(quote[i_target], digits));

         Comment("PowerLine: ", power[i_target], "    Price: ", NormalizeDouble(quote[i_target], digits), "     SELL");

        }

     }





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

//

//******************** !  #. !+ ************************

//

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





   int window=(int)MathRound(n_line*window_for_avg);    // ?@545;O5< >:=> 4;O A3;06820=8O 2~5%

   int window_2=(int)MathRound(window/2);

   int n_window=(int)MathRound(n_line/window);          // >;;8G5AB2> >:>=

//------ ?@545;O5< A3;065==K9(CA@54=5==K9) <0AA82

   int avg_power[];

   ArrayResize(avg_power, n_window+1);

   ArrayInitialize(avg_power, 0);

   double avg_quote[];

   ArrayResize(avg_quote, n_window+1);

   ArrayInitialize(avg_quote, 0.0);



   int i_avg=0;

   for(int ii=0; ii<n_line; ii++)

     {

      if(ii==(i_avg+1)*window)

        {

         avg_power[i_avg]=(int)MathRound(avg_power[i_avg]/window);

         avg_quote[i_avg]=quote[ii-window_2];

         i_avg=i_avg+1;

        }

      else

        {

         avg_power[i_avg]+=power[ii];

        }

     }

   i_avg=i_avg-1;





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

//

//*** ) # , / " +"/ . & (! #%  #!+) (0@B8=359;) ***

//

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





   if(buy_sell==0)

     {

      int pik_power[];

      ArrayResize(pik_power, n_window+1);

      ArrayInitialize(pik_power, 0);

      double pik_quote[];

      ArrayResize(pik_quote, n_window+1);

      ArrayInitialize(pik_quote, 0.0);



      int pik_power_=0;

      double pik_quote_=0;



      if(quote[i_target]>ask)                                                 // BUY

        {

         int i_pik=i_avg-2;

         int ii_pik=0;

         for(int iii=0; iii<=n_martingale-1; iii++)                           // 2(0,1) @070, 8=0G5 <>65B =5 E20B8BL 45=53!

           {

            pik_power_=0;

            pik_quote_=0;

            for(int ii=0; ii<=i_pik; ii++)                                    // 8I5< A=87C

              {

               if(avg_power[ii]<avg_power[ii+1] && avg_power[ii+1]>avg_power[ii+2] && avg_quote[ii+1]<bid && pik_power_<=avg_power[ii+1])  // ?8:

                 {

                  pik_power_=avg_power[ii+1];

                  pik_quote_=avg_quote[ii+1];

                  ii_pik=ii+1;

                 }

              }

            pik_power[iii]=pik_power_;

            pik_quote[iii]=pik_quote_;

            i_pik=ii_pik-2;

           }

         //--- #B>G=O5< ;8=88 A8;K

         int ii_perfect=-1;

         int ii_perfect_start=-1;

         for(int iii=0; iii<=n_martingale-1; iii++)

           {

            if(pik_power[iii]>0)

              {

               ii_perfect=(int)((pik_quote[iii]-lowest)/step+1);

               if(quote[ii_perfect+window]<bid)

                 {

                  ii_perfect_start=ii_perfect-window;

                  int ii_max=ArrayMaximum(power, ii_perfect_start, window*2); // <0:A8<C<

                  pik_power[iii]=power[ii_max];

                  pik_quote[iii]=quote[ii_max];

                 }

              }

           }

        }

      if(quote[i_target]<bid)                                                 // SELL

        {

         int i_pik=2;

         int ii_pik=i_avg;

         for(int iii=0; iii<=n_martingale-1; iii++)                           // 2(0,1) @070, 8=0G5 <>65B =5 E20B8BL 45=53!

           {

            pik_power_=0;

            pik_quote_=0;

            for(int ii=i_avg; ii>=i_pik; ii--)                                // 8I5< A25@EC

              {

               if(avg_power[ii]<avg_power[ii-1] && avg_power[ii-1]>avg_power[ii-2] && avg_quote[ii-1]>ask && pik_power_<=avg_power[ii-1])  // ?8:

                 {

                  pik_power_=avg_power[ii-1];

                  pik_quote_=avg_quote[ii-1];

                  ii_pik=ii-1;

                 }

              }

            pik_power[iii]=pik_power_;

            pik_quote[iii]=pik_quote_;

            i_pik=ii_pik+2;

           }

         //--- #B>G=O5< ;8=88 A8;K

         int ii_perfect=-1;

         int ii_perfect_start=-1;

         for(int iii=0; iii<=n_martingale-1; iii++)

           {

            if(pik_power[iii]>0)

              {

               ii_perfect=(int)((pik_quote[iii]-lowest)/step+1);

               if(quote[ii_perfect-window]>ask)

                 {

                  ii_perfect_start=ii_perfect-window;

                  int ii_max=ArrayMaximum(power, ii_perfect_start, window*2); // <0:A8<C<

                  pik_power[iii]=power[ii_max];

                  pik_quote[iii]=quote[ii_max];

                 }

              }

           }

        }



      //---  8AC5< ;8=8N >B:@KB8O 4>?. ?>78F88 (0@B8=359;)

      string text_martingale="";

      if(quote[i_target]>ask)                                                 //BUY

        {

         for(int ii=0; ii<=n_martingale-1; ii++)

           {

            if(pik_power[ii]>0)

              {

               text_martingale=IntegerToString((ii+1)*martingale)+"*BUY (Limit) "+DoubleToString(pik_quote[ii], digits);

               DrawLine(text_martingale, 0, pik_quote[ii], pik_power[ii], pik_quote[ii], color_buy);

               DrawText(text_martingale, text_martingale, 20, TimeCurrent(), pik_quote[ii], color_buy);

               Print(text_martingale);

              }

           }

        }

      if(quote[i_target]<bid)                                                 //SELL

        {

         for(int ii=0; ii<=n_martingale-1; ii++)

           {

            if(pik_power[ii]>0)

              {

               text_martingale=IntegerToString((ii+1)*martingale)+"*SELL (Limit) "+DoubleToString(pik_quote[ii], digits);

               DrawLine(text_martingale, 0, pik_quote[ii], pik_power[ii], pik_quote[ii], color_sell);

               DrawText(text_martingale, text_martingale, 20, TimeCurrent(), pik_quote[ii], color_sell);

               Print(text_martingale);

              }

           }

        }





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

      //

      //********************  0AG5B % >1J5<0 4;O >B:@KB8O (") **********

      //

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





      double tik_value_profit=SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_VALUE_PROFIT);

      double tik_value_loss=SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_VALUE_LOSS);

      double contract=SymbolInfoDouble(_Symbol, SYMBOL_TRADE_CONTRACT_SIZE);

      double lot=0;



      int top=40;

      int indent=20;



      if(quote[i_target]>ask)                                                 // BUY

        {

         // #1KB:8 (Loss)

         double loss=lowest-ask;                                              // 1-O >B:@KB0O ?>78F8O

         for(int ii=0; ii<=n_martingale-1; ii++)

           {

            if(pik_power[ii]>0)

               loss+=(lowest-pik_quote[ii])*((ii+1)*martingale);              // ?>A;54CNI85 >B:@KBK5 ?>78F88 (1,2... n)

           }

         loss*=tik_value_loss;

         loss*=contract;                                                      // @>A04:0 2 20;NB5

         lot=MathAbs(account_my/loss);

         lot=NormalizeDouble(lot, 2);

         loss*=lot;

         loss=NormalizeDouble(loss, 2);



         // @81K;L (Profit)

         double profit=quote[i_target]-ask;                                   // 1-O >B:@KB0O ?>78F8O

         for(int ii=0; ii<=n_martingale-1; ii++)

           {

            if(pik_power[ii]>0)

               profit+=(quote[i_target]-pik_quote[ii])*((ii+1)*martingale);   // ?>A;54CNI85 >B:@KBK5 ?>78F88 (1,2... n)

           }

         profit*=tik_value_profit;

         profit*=contract*lot;                                                // @81K;L 2 20;NB5

         profit=NormalizeDouble(profit, 2);



         //--- K2>4 =0 M:@0=

         if((lot>0 && profit-MathAbs(loss)>=0))

           {

            DrawLabel("Lots= "+DoubleToString(lot, 2), 10, 5, top, 0.0, color_text);

            DrawLabel("MAX Profit= "+DoubleToString(profit, 2), 10, 5, top+indent, 0.0, color_text);

            DrawLabel("MAX Loss= "+DoubleToString(loss, 2), 10, 5, top+indent*2, 0.0, color_text);

            DrawLabel("Profit/Loss= "+DoubleToString(MathAbs(NormalizeDouble(profit/loss, 2)), 2), 10, 5, top+indent*3, 0.0, color_text);



            Print("Lots= ", lot);

            Print("MAX Profit= ", profit);

            Print("MAX Loss= ", loss);

            Print("Profit/Loss= ", MathAbs(NormalizeDouble(profit/loss, 2)));

           }

         else

            DrawLabel("Don't Trade! BIG RISK!!!", 70, 300, 700, 45.0, color_text);

        }

      if(quote[i_target]<bid)                                                 // SELL

        {

         // #1KB:8 (Loss)

         double loss=bid-higest;                                              // 1-O >B:@KB0O ?>78F8O

         for(int ii=0; ii<=n_martingale-1; ii++)

           {

            if(pik_power[ii]>0)

               loss+=(pik_quote[ii]-higest)*((ii+1)*martingale);              // ?>A;54CNI85 >B:@KBK5 ?>78F88 (1,2... n)

           }

         loss*=tik_value_loss;

         loss*=contract;                                                      // @>A04:0 2 20;NB5

         lot=MathAbs(account_my/loss);

         lot=NormalizeDouble(lot, 2);

         loss*=lot;

         loss=NormalizeDouble(loss, 2);



         // @81K;L (Profit)

         double profit=bid-quote[i_target];                                   // 1-O >B:@KB0O ?>78F8O

         for(int ii=0; ii<=n_martingale-1; ii++)

           {

            if(pik_power[ii]>0)

               profit+=(pik_quote[ii]-quote[i_target])*((ii+1)*martingale);   // ?>A;54CNI85 >B:@KBK5 ?>78F88 (1,2... n)

           }

         profit*=tik_value_profit;

         profit*=contract*lot; // @81K;L 2 20;NB5

         profit=NormalizeDouble(profit, 2);



         //--- K2>4 =0 M:@0=

         if(lot>0 && profit-MathAbs(loss)>=0)

           {

            DrawLabel("Lots= "+DoubleToString(lot, 2), 10, 5, top, 0.0, color_text);

            DrawLabel("MAX Profit= "+DoubleToString(profit, 2), 10, 5, top+indent, 0.0, color_text);

            DrawLabel("MAX = "+DoubleToString(loss, 2), 10, 5, top+indent*2, 0.0, color_text);

            DrawLabel("Profit/Loss= "+DoubleToString(MathAbs(NormalizeDouble(profit/loss, 2)), 2), 10, 5, top+indent*3, 0.0, color_text);



            Print("Lots= ", lot);

            Print("MAX Profit= ", profit);

            Print("MAX Loss= ", loss);

            Print("Profit/Loss= ", MathAbs(NormalizeDouble(profit/loss, 2)));

           }

         else

            DrawLabel("Don't Trade! BIG RISK!!!", 70, 300, 700, 45.0, color_text);

        }

     }

  }

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





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

//| !>7405< >1,5:B ;8=8N A8;K                                        |

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

bool DrawLine(string name_, int n, double price, int n1, double price1, color color_line)

  {

   string name=name_+" "+IntegerToString(n1)+" "+DoubleToString(price, (int)SymbolInfoInteger(_Symbol, SYMBOL_DIGITS));

   ObjectCreate(0, name, OBJ_TREND, 0, iTime(NULL, 0, n), price, iTime(NULL, 0, n1), price1);

   ObjectSetInteger(0, name, OBJPROP_STYLE, STYLE_SOLID);

   ObjectSetInteger(0, name, OBJPROP_COLOR, color_line);

   ObjectSetInteger(0, name, OBJPROP_WIDTH, 2);

   ObjectSetInteger(0, name, OBJPROP_BACK, true);

   ObjectSetInteger(0, name, OBJPROP_SELECTABLE, true);

   ObjectSetInteger(0, name, OBJPROP_SELECTED, false);

   ObjectSetInteger(0, name, OBJPROP_RAY_LEFT, false);

   ObjectSetInteger(0, name, OBJPROP_RAY_RIGHT, false);

   ObjectSetInteger(0, name, OBJPROP_HIDDEN, true);

   ObjectSetInteger(0, name, OBJPROP_ZORDER, 0);

   ObjectSetInteger(0, name, OBJPROP_TIMEFRAMES, OBJ_ALL_PERIODS);

   return(true);

  }

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

//|  !>7405< >1,5:B "5:AB (@5:><5=40F88 : B>@3>2;5)                  |

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

bool DrawText(string name_text, string text, int fontsize, datetime x, double y, color color_text)

  {

   string name=name_text;

//--- A>74048< >1J5:B ""5:AB"

   ObjectCreate(0, name, OBJ_TEXT, 0, x, y);

//--- CAB0=>28< B5:AB

   ObjectSetString(0, name, OBJPROP_TEXT, text);

//--- CAB0=>28< H@8DB B5:AB0

   ObjectSetString(0, name, OBJPROP_FONT, "Arial");

//--- CAB0=>28< @07<5@ H@8DB0

   ObjectSetInteger(0, name, OBJPROP_FONTSIZE, fontsize);

//--- CAB0=>28< C3>; =0:;>=0 B5:AB0

   ObjectSetDouble(0, name, OBJPROP_ANGLE, 0.0);

//--- CAB0=>28< A?>A>1 ?@82O7:8

   ObjectSetInteger(0, name, OBJPROP_ANCHOR, ANCHOR_RIGHT_UPPER);

//--- CAB0=>28< F25B

   ObjectSetInteger(0, name, OBJPROP_COLOR, color_text);

//--- >B>1@078< =0 ?5@54=5< (false) 8;8 704=5< (true) ?;0=5

   ObjectSetInteger(0, name, OBJPROP_BACK, false);

//--- 2:;NG8< (true) 8;8 >B:;NG8< (false) @568< ?5@5<5I5=8O >1J5:B0 <KHLN

   ObjectSetInteger(0, name, OBJPROP_SELECTABLE, false);

   ObjectSetInteger(0, name, OBJPROP_SELECTED, false);

//--- A:@>5< (true) 8;8 >B>1@078< (false) 8<O 3@0D8G5A:>3> >1J5:B0 2 A?8A:5 >1J5:B>2

   ObjectSetInteger(0, name, OBJPROP_HIDDEN, true);

//--- CAB0=>28< ?@8>@8B5B =0 ?>;CG5=85 A>1KB8O =060B8O <KH8 =0 3@0D8:5

   ObjectSetInteger(0, name, OBJPROP_ZORDER, 0);

   return(true);

  }

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

//|  !>7405< >1,5:B 591; (@5:><5=40F88 : B>@3>2;5)                  |

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

bool DrawLabel(string text, int fontsize, int x, int y, double angle, color color_text)

  {

   string name=text;

//--- A>74048< >1J5:B ""5:AB"

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

//--- CAB0=>28< :>>@48=0BK <5B:8

   ObjectSetInteger(0, name, OBJPROP_XDISTANCE, x);

   ObjectSetInteger(0, name, OBJPROP_YDISTANCE, y);

//--- CAB0=>28< B5:AB

   ObjectSetString(0, name, OBJPROP_TEXT, text);

//--- CAB0=>28< H@8DB B5:AB0

   ObjectSetString(0, name, OBJPROP_FONT, "Arial");

//--- CAB0=>28< @07<5@ H@8DB0

   ObjectSetInteger(0, name, OBJPROP_FONTSIZE, fontsize);

//--- CAB0=>28< C3>; =0:;>=0 B5:AB0

   ObjectSetDouble(0, name, OBJPROP_ANGLE, angle);

//--- CAB0=>28< A?>A>1 ?@82O7:8

   ObjectSetInteger(0, name, OBJPROP_ANCHOR, ANCHOR_LEFT_UPPER);

//--- CAB0=>28< F25B

   ObjectSetInteger(0, name, OBJPROP_COLOR, color_text);

//--- >B>1@078< =0 ?5@54=5< (false) 8;8 704=5< (true) ?;0=5

   ObjectSetInteger(0, name, OBJPROP_BACK, false);

//--- 2:;NG8< (true) 8;8 >B:;NG8< (false) @568< ?5@5<5I5=8O >1J5:B0 <KHLN

   ObjectSetInteger(0, name, OBJPROP_SELECTABLE, false);

   ObjectSetInteger(0, name, OBJPROP_SELECTED, false);

//--- A:@>5< (true) 8;8 >B>1@078< (false) 8<O 3@0D8G5A:>3> >1J5:B0 2 A?8A:5 >1J5:B>2

   ObjectSetInteger(0, name, OBJPROP_HIDDEN, true);

//--- CAB0=>28< ?@8>@8B5B =0 ?>;CG5=85 A>1KB8O =060B8O <KH8 =0 3@0D8:5

   ObjectSetInteger(0, name, OBJPROP_ZORDER, 0);

   return(true);

  }



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

Comments