Author: Yuriy Tokman (YTG)
0 Views
0 Downloads
0 Favorites
Price Bid
ÿþ//+------------------------------------------------------------------+

//|                                                    Price Bid.mq4 |

//|                                               Yuriy Tokman (YTG) |

//|                                               https://ytg.com.ua |

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

#property copyright "Yuriy Tokman (YTG)"

#property link      "https://ytg.com.ua"

#property version   "1.00"

#property strict

#property indicator_chart_window



input color           _clr=clrRed;        // F25B F5=>2>9 <5B:8

input int             _width=3;           // @07<5@ F5=>2>9 <5B:8



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

//| Custom indicator initialization function                         |

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

int OnInit()

  {

//--- indicator buffers mapping

   ArrowRightPriceCreate(_clr,_width);

//---

   return(INIT_SUCCEEDED);

  }

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

//|                                                                  |

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

void OnDeinit(const int reason)

  {

//---

   ObjectDelete(0,"RightPrice");

  }

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

//| Custom indicator iteration function                              |

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

int OnCalculate(const int rates_total,

                const int prev_calculated,

                const datetime &time[],

                const double &open[],

                const double &high[],

                const double &low[],

                const double &close[],

                const long &tick_volume[],

                const long &volume[],

                const int &spread[])

  {

//---

   ArrowRightPriceMove();

//--- return value of prev_calculated for next call

   return(rates_total);

  }



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

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

//| !>7405B ?@02CN F5=>2CN <5B:C                                     |

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

bool ArrowRightPriceCreate(const color           clr=clrRed,        // F25B F5=>2>9 <5B:8

                           const int             width=1,           // @07<5@ F5=>2>9 <5B:8

                           datetime              time=0,            // 2@5<O B>G:8 ?@82O7:8

                           double                price=0,           // F5=0 B>G:8 ?@82O7:8

                           const ENUM_LINE_STYLE style=STYLE_SOLID, // AB8;L >:09<;ONI59 ;8=88

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

                           const string          name="RightPrice", // 8<O F5=>2>9 <5B:8

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

                           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

  {

//---

   if(ObjectFind(chart_ID,name) != 0)

      ObjectDelete(chart_ID,name);

//--- 5A;8 :>>@48=0BK B>G:8 =5 7040=K, B> ?5@5<5I05< 55 =0 B5:CI89 10@ A F5=>9 Bid

   if(!time)

      time=Time[0];

   if(!price)

      price=SymbolInfoDouble(Symbol(),SYMBOL_BID);

//--- A1@>A8< 7=0G5=85 >H81:8

   ResetLastError();

//--- A>74048< F5=>2CN <5B:C

   if(!ObjectCreate(chart_ID,name,OBJ_ARROW_RIGHT_PRICE,sub_window,time,price))

     {

      Print(__FUNCTION__,

            ": =5 C40;>AL A>740BL ?@02CN F5=>2CN <5B:C! >4 >H81:8 = ",GetLastError());

      return(false);

     }

//--- CAB0=>28< F25B <5B:8

   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);

//--- CAB0=>28< AB8;L >:09<;ONI59 ;8=88

   ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style);

//--- CAB0=>28< @07<5@ <5B:8

   ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width);

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

   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);

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

//--- ?@8 A>740=88 3@0D8G5A:>3> >1J5:B0 DC=:F859 ObjectCreate, ?> C<>;G0=8N >1J5:B

//--- =5;L7O 2K45;8BL 8 ?5@5<5I0BL. =CB@8 65 MB>3> <5B>40 ?0@0<5B@ selection

//--- ?> C<>;G0=8N @025= true, GB> ?>72>;O5B 2K45;OBL 8 ?5@5<5I0BL MB>B >1J5:B

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);

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

   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);

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

   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);

//--- CA?5H=>5 2K?>;=5=85

   return(true);

  }

//----

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

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

//| 5@5<5I05B B>G:C ?@82O7:8                                        |

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

bool ArrowRightPriceMove(datetime     time=0,            // :>>@48=0B0 2@5<5=8 B>G:8 ?@82O7:8

                         double       price=0,           // :>>@48=0B0 F5=K B>G:8 ?@82O7:8

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

                         const string name="RightPrice") // 8<O <5B:8

  {

//--- 5A;8 :>>@48=0BK B>G:8 =5 7040=K, B> ?5@5<5I05< 55 =0 B5:CI89 10@ A F5=>9 Bid

   if(!time)

      time=Time[0];

   if(!price)

      price=SymbolInfoDouble(Symbol(),SYMBOL_BID);

//--- A1@>A8< 7=0G5=85 >H81:8

   ResetLastError();

//--- ?5@5<5AB8< B>G:C ?@82O7:8

   if(!ObjectMove(chart_ID,name,0,time,price))

     {

      Print(__FUNCTION__,

            ": =5 C40;>AL ?5@5<5AB8BL B>G:C ?@82O7:8! >4 >H81:8 = ",GetLastError());

      return(false);

     }

//--- CA?5H=>5 2K?>;=5=85

   return(true);

  }

//----

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

Comments