TLBIndicator

Author: Copyright 2020, MetaQuotes Software Corp.
Price Data Components
Indicators Used
Moving average indicator
2 Views
0 Downloads
0 Favorites
TLBIndicator
ÿþ//+------------------------------------------------------------------+

//|                                                 TBLIndicator.mq5 |

//|                        Copyright 2020, MetaQuotes Software Corp. |

//|                                             https://www.mql5.com |

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

#property copyright "Copyright 2020, MetaQuotes Software Corp."

#property link      "https://www.mql5.com"

#property version   "1.00"

#property indicator_chart_window

#property indicator_buffers 0

#property indicator_plots   0

//--- input parameters

input string   Info="TBLIndicator";

input string   StartTime="21:00";

input string   EndTime="01:00";

input string   SessionEndTime="20:45";

input color    SessionColor=clrLinen;

input int      NumDays=6;

input int      MinBoxSizeInPips=15;

input int      MaxBoxSizeInPips=45;

input bool     LimitBoxToMaxSize=true;

input bool     StickBoxToLatestExtreme=false;

input bool     StickBoxOusideSRlevels=false;

input double   TP1Factor=1.0;

      double TP2Factor;

input double   TP3Factor=2.618;

      double TP4Factor;

input double   TP5Factor=4.236;

input string   TP2_help="TP2 is half-way between TP1 and TP3";

input string   TP4_help="TP4 is half-way between TP3 and TP5";

      double SLFactor     = 1.000;

input double   LevelsResizeFactor=1.0;

input color    BoxColorOK=clrLightBlue;

input color    BoxColorNOK=clrRed;

input color    BoxColorMAX=clrOrange;

input color    LevelColor=clrBlack;

input int      FibLength=140;

input bool     showProfitZone=true;

input color    ProfitColor=clrLightGreen;

input string   objPrefix="LB2-";



double dTP1Factor,dTP3Factor,dTP5Factor;

bool dLimitBoxToMaxSize = LimitBoxToMaxSize;

bool dStickBoxToLatestExtreme = StickBoxToLatestExtreme;



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



// GLOBAL variables



double pip;

int digits;

int BarsBack;



//breakout levels

//Entry, stop and tp

double BuyEntry,BuyTP1,BuyTP2,BuyTP3,BuyTP4,BuyTP5,BuySL;

double SellEntry,SellTP1,SellTP2,SellTP3,SellTP4,SellTP5,SellSL;

double SL_pips,TP1_pips,TP2_pips,TP3_pips,TP4_pips,TP5_pips;

double TP1FactorInput,TP2FactorInput,TP3FactorInput,TP4FactorInput,TP5FactorInput,SLFactorInput;

//box and session

datetime tBoxStart,tBoxEnd,tSessionStart,tSessionEnd,tLastComputedSessionStart,tLastComputedSessionEnd;

double boxHigh,boxLow,boxExtent,boxMedianPrice;



int StartShift;

int EndShift;

datetime alreadyDrawn;





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

//| Custom indicator initialization function                         |

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

int OnInit()

  {

//--- indicator buffers mapping

   Comment (Info+" ["+StartTime+"-"+EndTime+"] end "+SessionEndTime+" min "+DoubleToString(MinBoxSizeInPips,0)+"p, "+" max "+DoubleToString(MaxBoxSizeInPips,0)+"p,"

           +DoubleToString(TP1Factor,1)+"/"+DoubleToString(TP3Factor,1)+"/"+DoubleToString(TP5Factor,1));



  RemoveObjects(objPrefix);

  getpip();



  BarsBack = NumDays*(1440/Period());

  alreadyDrawn = 0;



  //save input Factors;

  TP1FactorInput = TP1Factor;

  TP3FactorInput = TP3Factor;

  TP5FactorInput = TP5Factor;

  SLFactorInput  = SLFactor;



  TP2Factor = (TP1Factor+TP3Factor)/2;

  TP4Factor = (TP3Factor+TP5Factor)/2;



  // StickBoxOusideSRlevels mode requires LimitBoxToMaxSize and StickBoxToLatestExtreme options true

  if (StickBoxOusideSRlevels==true) {

    dLimitBoxToMaxSize = true;

    dStickBoxToLatestExtreme = true;

  }



   return(INIT_SUCCEEDED);

  }

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

//| Custom indicator iteration function                              |

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

int OnCalculate(const int rates_total,

                const int prev_calculated,

                const int begin,

                const double &price[])

  {

  int i, limit, counted_bars=0;

  if(prev_calculated>0)  counted_bars = prev_calculated-1;

  if(prev_calculated==0) counted_bars = 0;

  int bars=Bars(_Symbol,_Period);

  int res = bars - counted_bars - 1;

  limit = MathMin(BarsBack,res);



  for (i=limit; i>=0; i--) {

    new_tick(i);

  } // limit loop



   return(rates_total);

  }

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



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

void new_tick(int i) // i = bar number: 0=current(last) bar

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

{

  datetime Time[];

  int count=Bars(_Symbol,_Period);        // A:>;L:> :>?8@C5<

  ArraySetAsSeries(Time,true);

  CopyTime(_Symbol,_Period,0,count,Time);

  datetime now = Time[i];



  //compute LEVELS values:

  compute_LB_Indi_LEVELS(now);

  

  show_boxes(now);



}//new_tick()



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

// RemoveObjects

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



void RemoveObjects(string Pref)

{  

   int i;

   string objname = "";



   for (i = ObjectsTotal(0,-1,-1); i >= 0; i--) {

      objname = ObjectName(0,i);

      if (StringFind(objname, Pref, 0) > -1)

      {

        ObjectDelete(0,objname);

      }

   }

} /* RemoveObjects*/



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

// getpip

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



void getpip()

{

   if(_Digits == 2 || _Digits == 4) pip = _Point;

   else if(_Digits == 3 || _Digits == 5) pip = 10*_Point;

   else if(_Digits == 6) pip = 100*_Point;

      

if (_Digits == 3 || _Digits == 2) digits = 2;

else digits = 4;

} /* getpip*/



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

void compute_LB_Indi_LEVELS(datetime now)

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

{

  int boxStartShift,boxEndShift;



  if (now >= tSessionStart && now <= tSessionEnd) return; // box already up-to-date, no need to recompute

 

  //determine box and session times

  tBoxStart = StringToTime(TimeToString(now,TIME_DATE) + " "  + StartTime);

  tBoxEnd   = StringToTime(TimeToString(now,TIME_DATE) + " "  + EndTime);

  

  if (tBoxStart > tBoxEnd) tBoxStart -= 86400; // midnight wrap fix

  int day = TimeDayOfWeek(tBoxStart);

  if (TimeDayOfWeek(tBoxStart) == 6)

     {

       tBoxStart += 90000;

       tBoxEnd += 86400;

     }



  if ((TimeDayOfWeek(tBoxStart) == 0) && day == 0)

     {

       tBoxStart += 3600;

     }

  tSessionStart = tBoxEnd;

  tSessionEnd = StringToTime(TimeToString(tSessionStart,TIME_DATE) + " "  + SessionEndTime);

  if (tSessionStart > tSessionEnd) tSessionEnd = tSessionEnd + 86400; // midnight wrap fix

  

  // save the computed session start&end times to avoid recomputing them for each handled trade;

  tLastComputedSessionStart = tSessionStart;

  tLastComputedSessionEnd   = tSessionEnd;



  //determine hi/lo

  boxStartShift = iBarShift(NULL,0,tBoxStart);

  boxEndShift   = iBarShift(NULL,0,tBoxEnd);

  

  double High[];

  int count=Bars(_Symbol,_Period);

  ArraySetAsSeries(High,true);

  CopyHigh(_Symbol,_Period,0,count,High);

  

  boxHigh = High[iHighest(NULL,0,MODE_HIGH,(boxStartShift-boxEndShift+1),boxEndShift)];



  double Low[];

  ArraySetAsSeries(Low,true);

  CopyLow(_Symbol,_Period,0,count,Low);



  boxLow  = Low[iLowest(NULL,0,MODE_LOW,(boxStartShift-boxEndShift+1),boxEndShift)];

  

  boxMedianPrice = (boxHigh+boxLow)/2;

  boxExtent = boxHigh - boxLow;



  if (boxExtent >= MaxBoxSizeInPips * pip && dLimitBoxToMaxSize==true) { // box too large, but we allow to trade it at its max acceptable value

    if (dStickBoxToLatestExtreme==true) {

      // adjust box parameters to "stick" it to the box high or box low, whichever comes last;

      // use M1 bars to maximize price precision

      int boxStartShiftM1 = iBarShift(NULL,PERIOD_M1,tBoxStart);

      int boxEndShiftM1   = iBarShift(NULL,PERIOD_M1,tBoxEnd);

      int boxHighShift    = iHighest(NULL,PERIOD_M1,MODE_HIGH,(boxStartShiftM1-boxEndShiftM1+1),boxEndShiftM1);

      int boxLowShift     = iLowest(NULL,PERIOD_M1,MODE_LOW,(boxStartShiftM1-boxEndShiftM1+1),boxEndShiftM1);

      boxExtent = MaxBoxSizeInPips * pip;

      if (boxHighShift <= boxLowShift) {

        // box high is more recent than box low: stick box to highest price

        if (StickBoxOusideSRlevels==true) {

          boxMedianPrice = boxHigh + boxExtent/2;

        } else {

          boxMedianPrice = boxHigh - boxExtent/2;

        }

      } else {

        // box low is more recent than box high: stick box to lowest price

        if (StickBoxOusideSRlevels==true) {

          boxMedianPrice = boxLow - boxExtent/2;

        } else {

          boxMedianPrice = boxLow + boxExtent/2;

        }

      }

    } else {

      // adjust box parameters to recenter it on the EMA(box_time_range) value

      boxExtent      = MaxBoxSizeInPips * pip;

      boxMedianPrice = iMA(NULL,0,boxStartShift-boxEndShift,0,MODE_EMA,PRICE_MEDIAN);



    }

  }

  

  //apply LevelsResizeFactor to the box extent

  boxExtent *= LevelsResizeFactor;

  //recompute box hi/lo prices based on adjusted median price and extent

  boxHigh = NormalizeDouble(boxMedianPrice + (boxExtent/2),_Digits);

  boxLow  = NormalizeDouble(boxMedianPrice - (boxExtent/2),_Digits);



  //restore input Factors;

  dTP1Factor = TP1FactorInput;

  dTP3Factor = TP3FactorInput;

  dTP5Factor = TP5FactorInput;

  SLFactor  = SLFactorInput;



  //compute breakout levels

  BuyEntry  = boxHigh;

  SellEntry = boxLow;



  // when a Factor is >=10, it is considered as FIXED PIPs rather than a Factor of the box size;

  if (dTP1Factor < 10) TP1_pips = boxExtent*dTP1Factor/pip;

  else { TP1_pips = dTP1Factor; dTP1Factor = TP1_pips*pip/boxExtent; }

  BuyTP1  = NormalizeDouble(BuyEntry  + TP1_pips*pip,_Digits);

  SellTP1 = NormalizeDouble(SellEntry - TP1_pips*pip,_Digits);



  if (dTP3Factor < 10) TP3_pips = boxExtent*dTP3Factor/pip;

  else { TP3_pips = dTP3Factor; dTP3Factor = TP3_pips*pip/boxExtent; }

  BuyTP3  = NormalizeDouble(BuyEntry  + TP3_pips*pip,_Digits);

  SellTP3 = NormalizeDouble(SellEntry - TP3_pips*pip,_Digits);



  TP2Factor = (dTP1Factor+dTP3Factor)/2;

  if (TP2Factor < 10) TP2_pips = boxExtent*TP2Factor/pip;

  else { TP2_pips = TP2Factor; TP2Factor = TP2_pips*pip/boxExtent; }

  BuyTP2  = NormalizeDouble(BuyEntry  + TP2_pips*pip,_Digits);

  SellTP2 = NormalizeDouble(SellEntry - TP2_pips*pip,_Digits);



  if (dTP5Factor < 10) TP5_pips = boxExtent*dTP5Factor/pip;

  else { TP5_pips = dTP5Factor; dTP5Factor = TP5_pips*pip/boxExtent; }

  BuyTP5  = NormalizeDouble(BuyEntry  + TP5_pips*pip,_Digits);

  SellTP5 = NormalizeDouble(SellEntry - TP5_pips*pip,_Digits);



  TP4Factor = (dTP3Factor+dTP5Factor)/2;

  if (TP4Factor < 10) TP4_pips = boxExtent*TP4Factor/pip;

  else { TP4_pips = TP4Factor; TP4Factor = TP4_pips*pip/boxExtent; }

  BuyTP4  = NormalizeDouble(BuyEntry  + TP4_pips*pip,_Digits);

  SellTP4 = NormalizeDouble(SellEntry - TP4_pips*pip,_Digits);



  if (SLFactor < 10) SL_pips = boxExtent*SLFactor/pip;

  else { SL_pips = SLFactor; SLFactor = SL_pips*pip/boxExtent; }

  BuySL  = NormalizeDouble(BuyEntry  - SL_pips*pip,_Digits);

  SellSL = NormalizeDouble(SellEntry + SL_pips*pip,_Digits);



}//compute_LB_Indi_LEVELS



int TimeDayOfWeek(datetime date)

  {

   MqlDateTime tm;

   TimeToStruct(date,tm);

   return(tm.day_of_week);

  }



int iHighest(string symbol,int tf,int type,int count=WHOLE_ARRAY,int start=0)

{

   if(start<0) return(-1);

   if(count<=0) count=Bars(_Symbol,_Period);



   if(type==MODE_HIGH)

     {

      double High[];

      ArraySetAsSeries(High,true);

      CopyHigh(_Symbol,_Period,start,count,High);

      return(ArrayMaximum(High,0,count)+start);

     }

   return(0);

}  



int iLowest(string symbol,int tf,int type,int count=WHOLE_ARRAY,int start=0)

{

   if(start<0) return(-1);

   if(count<=0) count=Bars(_Symbol,_Period);



   if(type==MODE_LOW)

     {

      double Low[];

      ArraySetAsSeries(Low,true);

      CopyLow(_Symbol,_Period,start,count,Low);

      return(ArrayMinimum(Low,0,count)+start);

     }

   return(0);

}  



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

void show_boxes(datetime now)

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

{

  // show session period with a different "background" color

  drawBoxOnce (objPrefix+"Session-"+TimeToString(tSessionStart,TIME_DATE | TIME_SECONDS),tSessionStart,0,tSessionEnd,BuyEntry*2,SessionColor,1, STYLE_SOLID, true);



  // draw pre-breakout box blue/red once per Session:

  if (alreadyDrawn != tBoxEnd) {

    alreadyDrawn = tBoxEnd; // won't redraw until next box

  

    // draw pre-breakout box blue/red:

    string boxName = objPrefix+"Box-"+TimeToString(now,TIME_DATE)+"-"+StartTime+"-"+EndTime;

    if (boxExtent >= MaxBoxSizeInPips * pip) { // box too large: DON'T TRADE !

      if (LimitBoxToMaxSize==false) { // box too large, but we allow to trade it at its max acceptable value

        drawBox (boxName,tBoxStart,boxLow,tBoxEnd,boxHigh,BoxColorNOK,1, STYLE_SOLID, true);

        DrawLbl(objPrefix+"Lbl-"+TimeToString(now,TIME_DATE)+"-"+StartTime+"-"+EndTime, "NO TRADE! ("+DoubleToString(boxExtent/pip,0)+"p)", tBoxStart+(tBoxEnd-tBoxStart)/2,boxLow, 12, "Arial Black", LevelColor, 3);

      } else {

        drawBox (boxName,tBoxStart,boxLow,tBoxEnd,boxHigh,BoxColorMAX,1, STYLE_SOLID, true);

        DrawLbl(objPrefix+"Lbl-"+TimeToString(now,TIME_DATE)+"-"+StartTime+"-"+EndTime, "MAX LIMIT! ("+DoubleToString(boxExtent/pip,0)+"p)", tBoxStart+(tBoxEnd-tBoxStart)/2,boxLow, 12, "Arial Black", LevelColor, 3);

      }

    } else if (boxExtent >= MinBoxSizeInPips * pip) { // box OK

      drawBox (boxName,tBoxStart,boxLow,tBoxEnd,boxHigh,BoxColorOK,1, STYLE_SOLID, true);

      DrawLbl(objPrefix+"Lbl-"+TimeToString(now,TIME_DATE)+"-"+StartTime+"-"+EndTime, DoubleToString(boxExtent/pip,0)+"p", tBoxStart+(tBoxEnd-tBoxStart)/2,boxLow, 12, "Arial Black", LevelColor, 3);

    } else { // "Caution!" box

      drawBox (boxName,tBoxStart,boxLow,tBoxEnd,boxHigh,BoxColorNOK,1, STYLE_SOLID, true);

      DrawLbl(objPrefix+"Lbl-"+TimeToString(now,TIME_DATE)+"-"+StartTime+"-"+EndTime, "Caution! ("+DoubleToString(boxExtent/pip,0)+"p)", tBoxStart+(tBoxEnd-tBoxStart)/2,boxLow, 12, "Arial Black", BoxColorNOK, 3);

    }

    DrawLbl(objPrefix+"Lbl2-"+TimeToString(now,TIME_DATE)+"-"+StartTime+"-"+EndTime,"BO", tBoxStart+(tBoxEnd-tBoxStart)/2,boxLow-6*pip, 24, "Arial Black", LevelColor, 2);



    if (showProfitZone) {

      double UpperTP,LowerTP;

      if (TP5Factor>0) {// draw TP4 and TP5 optional targets

        UpperTP = BuyTP5;

        LowerTP = SellTP5;

      } else {// draw only up to TP3

        UpperTP = BuyTP3;

        LowerTP = SellTP3;

      }

      drawBox (objPrefix+"BuyProfitZone-" +TimeToString(tSessionStart,TIME_DATE),tSessionStart,BuyTP1,tSessionEnd,UpperTP,ProfitColor,1, STYLE_SOLID, true);

      drawBox (objPrefix+"SellProfitZone-"+TimeToString(tSessionStart,TIME_DATE),tSessionStart,SellTP1,tSessionEnd,LowerTP,ProfitColor,1, STYLE_SOLID, true);

    }



    // draw "fib" lines for entry+stop+TP levels:

    string objname = objPrefix+"Fibo-" + TimeToString(tBoxEnd,TIME_DATE);

    ObjectCreate(0,objname,OBJ_FIBO,0,tBoxStart,SellEntry,tBoxStart+FibLength*60*10,BuyEntry); //--- A>74048< "#@>2=8 $81>=0GG8" ?> 7040==K< :>>@48=0B0<



    ObjectSetInteger(0,objname,OBJPROP_RAY_RIGHT,false);

    ObjectSetInteger(0,objname,OBJPROP_COLOR,clrNONE);

    ObjectSetInteger(0,objname,OBJPROP_STYLE,STYLE_DASH);

    ObjectSetInteger(0,objname,OBJPROP_LEVELS,12);

    _SetFibLevel(objname,0,0.0,"Entry Buy= %$");

    _SetFibLevel(objname,1,1.0,"Entry Sell= %$");

    _SetFibLevel(objname,2,-TP1Factor, "Buy Target 1= %$  (+"+DoubleToString(TP1_pips,0)+"p)");

    _SetFibLevel(objname,3,1+TP1Factor,"Sell Target 1= %$  (+"+DoubleToString(TP1_pips,0)+"p)");

    _SetFibLevel(objname,4,-TP2Factor, "Buy Target 2= %$  (+"+DoubleToString(TP2_pips,0)+"p)");

    _SetFibLevel(objname,5,1+TP2Factor,"Sell Target 2= %$  (+"+DoubleToString(TP2_pips,0)+"p)");

    _SetFibLevel(objname,6,-TP3Factor, "Buy Target 3= %$  (+"+DoubleToString(TP3_pips,0)+"p)");

    _SetFibLevel(objname,7,1+TP3Factor,"Sell Target 3= %$  (+"+DoubleToString(TP3_pips,0)+"p)");

    if (TP5Factor>0) {// draw TP4 and TP5 optional targets

      _SetFibLevel(objname,8,-TP4Factor, "Buy Target 4= %$  (+"+DoubleToString(TP4_pips,0)+"p)");

      _SetFibLevel(objname,9,1+TP4Factor,"Sell Target 4= %$  (+"+DoubleToString(TP4_pips,0)+"p)");

      _SetFibLevel(objname,10,-TP5Factor, "Buy Target 5= %$  (+"+DoubleToString(TP5_pips,0)+"p)");

      _SetFibLevel(objname,11,1+TP5Factor,"Sell Target 5= %$  (+"+DoubleToString(TP5_pips,0)+"p)");

    }

  }



}//show_boxes()



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

void _SetFibLevel(string objname, int level, double value, string description)

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

{  

    //--- 7=0G5=85 C@>2=O

      ObjectSetDouble(0,objname,OBJPROP_LEVELVALUE,level,value);

      //--- F25B C@>2=O

      ObjectSetInteger(0,objname,OBJPROP_LEVELCOLOR,level,LevelColor);

      //--- AB8;L C@>2=O

      ObjectSetInteger(0,objname,OBJPROP_LEVELSTYLE,level,STYLE_SOLID);

      //--- B>;I8=0 C@>2=O

      ObjectSetInteger(0,objname,OBJPROP_LEVELWIDTH,level,1);

      //--- >?8A0=85 C@>2=O

      ObjectSetString(0,objname,OBJPROP_LEVELTEXT,level,description);

}



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

// drawBoxOnce: draw a Box only once; if it already exists, do nothing

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



void drawBoxOnce (

  string objname,

  datetime tStart, double vStart,

  datetime tEnd,   double vEnd,

  color c, int width, int style, bool bg

)

{

  if (ObjectFind(0,objname) != -1) return;

  

  ObjectCreate(0,objname, OBJ_RECTANGLE, 0, tStart,vStart,tEnd,vEnd);

  //--- CAB0=>28< F25B ?@O<>C3>;L=8:0

  ObjectSetInteger(0,objname,OBJPROP_COLOR, c);

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

  ObjectSetInteger(0,objname, OBJPROP_BACK, bg);

  //--- CAB0=>28< B>;I8=C ;8=89 ?@O<>C3>;L=8:0

  ObjectSetInteger(0,objname, OBJPROP_WIDTH, width);

  //--- CAB0=>28< AB8;L ;8=89 ?@O<>C3>;L=8:0

  ObjectSetInteger(0,objname, OBJPROP_STYLE, style);

  //--- 2:;NG8< (true) 8;8 >B:;NG8< (false) @568< 70;82:8 ?@O<>C3>;L=8:0

   ObjectSetInteger(0,objname,OBJPROP_FILL,true);

} /* drawBoxOnce */



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

// drawBox

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



void drawBox (

  string objname,

  datetime tStart, double vStart,

  datetime tEnd,   double vEnd,

  color c, int width, int style, bool bg

)

{

  if (ObjectFind(0,objname) == -1) {

    ObjectCreate(0,objname, OBJ_RECTANGLE, 0, tStart,vStart,tEnd,vEnd);

  } else {

    ObjectSetInteger(0,objname, OBJPROP_TIME, tStart);

    ObjectSetInteger(0,objname, OBJPROP_TIME,1, tEnd);

    ObjectSetDouble(0,objname, OBJPROP_PRICE, vStart);

    ObjectSetDouble(0,objname, OBJPROP_PRICE,1, vEnd);

  }



  ObjectSetInteger(0,objname,OBJPROP_COLOR, c);

  ObjectSetInteger(0,objname, OBJPROP_BACK, bg);

  ObjectSetInteger(0,objname, OBJPROP_WIDTH, width);

  ObjectSetInteger(0,objname, OBJPROP_STYLE, style);

  ObjectSetInteger(0,objname,OBJPROP_FILL,true);

} /* drawBox */



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

// DrawLbl

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



void DrawLbl(string objname, string s, datetime LTime, double LPrice, int FSize, string Font, color c, int width)

{

  if (ObjectFind(0,objname) < 0) {

    ObjectCreate(0,objname, OBJ_TEXT, 0, LTime, LPrice);  //--- A>74048< >1J5:B ""5:AB"

  } else {

    if (ObjectGetInteger(0,objname,OBJPROP_TYPE) == OBJ_TEXT) { //>72@0I05B 7=0G5=85 A>>B25BAB2CNI53> A2>9AB20 >1J5:B0.

      ObjectSetInteger(0,objname, OBJPROP_TIME, LTime); //TIME1 >;CG05B/CAB0=02;8205B ?5@2CN :>>@48=0BC 2@5<5=8

      ObjectSetDouble(0,objname, OBJPROP_PRICE, LPrice); //PRICE1 >;CG05B/CAB0=02;8205B ?5@2CN :>>@48=0BC F5=K

    }

  }

  ObjectSetInteger(0,objname, OBJPROP_FONTSIZE, FSize); //--- CAB0=>28< @07<5@ H@8DB0

  ObjectSetText(objname, s, FSize, Font, c); //7<5=O5B >?8A0=85 >1J5:B0

  

} /* DrawLbl*/



bool ObjectSetText(string name, string text,int font_size,string font="",color text_color=CLR_NONE)

{

   int tmpObjType=(int)ObjectGetInteger(0,name,OBJPROP_TYPE);

   if(tmpObjType!=OBJ_LABEL && tmpObjType!=OBJ_TEXT) return(false);

   if(StringLen(text)>0 && font_size>0)

     {

      if(ObjectSetString(0,name,OBJPROP_TEXT,text)==true

         && ObjectSetInteger(0,name,OBJPROP_FONTSIZE,font_size)==true)

        {

         if((StringLen(font)>0)

            && ObjectSetString(0,name,OBJPROP_FONT,font)==false)

            return(false);

         if(ObjectSetInteger(0,name,OBJPROP_COLOR,text_color)==false)

            return(false);

         return(true);

        }

      return(false);

     }

   return(false);

}



void OnDeinit(const int reason)

  {

    RemoveObjects(objPrefix);

  }

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