Simple_Session_Price_Change

Author: Copyright 2024, MrBrooklin
Price Data Components
Series array that contains open prices of each bar
0 Views
0 Downloads
0 Favorites
Simple_Session_Price_Change
ÿþ//+------------------------------------------------------------------+

//|                                  Simple_Session_Price_Change.mq5 |

//|                                       Copyright 2024, MrBrooklin |

//|                         https://www.mql5.com/ru/users/mrbrooklin |

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

#property copyright "Copyright 2024, MrBrooklin"

#property link      "https://www.mql5.com/ru/users/mrbrooklin"

#property version   "1.00"

#property indicator_chart_window // 2K2545< 8=48:0B>@ 2 >:=5 3@0D8:0

#property indicator_plots   0    // 704048< :>;8G5AB2> 3@0D8G5A:8E A5@89 2 8=48:0B>@5

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

//|                                                                  |

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

int OnInit()

  {

   ObjectCreate(0,"Inscription",OBJ_LABEL,0,0,0); // A>74048< >1J5:B "B5:AB>20O <5B:0"

   return(INIT_SUCCEEDED);

  }

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

//|                                                                  |

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

void OnDeinit(const int reason)

  {

   ObjectDelete(0, "Inscription"); // C40;8< =04?8AL A 3@0D8:0 ?@8 7025@H5=88 @01>BK 8=48:0B>@0

  }

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

//|                                                                  |

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

void Label_Create(string text)

  {

   ObjectSetInteger(0,"Inscription",OBJPROP_XDISTANCE,500);  // CAB0=>28< :>>@48=0BK <5B:8 ?> >A8 X

   ObjectSetInteger(0,"Inscription",OBJPROP_YDISTANCE,30);   // CAB0=>28< :>>@48=0BK <5B:8 ?> >A8 Y

//--- >?@545;8< C3>; 3@0D8:0, >B:C40 1C4CB >?@545;OBLAO :>>@48=0BK B>G:8 ?@82O7:8

   ObjectSetInteger(0,"Inscription",OBJPROP_CORNER,2);

   ObjectSetString(0,"Inscription",OBJPROP_TEXT,text);       // 704048< B5:AB 4;O 2K2>40 =0 M:@0=

   ObjectSetString(0,"Inscription",OBJPROP_FONT,"Segoe UI"); // 704048< H@8DB B5:AB0

   ObjectSetInteger(0,"Inscription",OBJPROP_FONTSIZE,12);    // 704048< @07<5@ H@8DB0

   ObjectSetInteger(0,"Inscription",OBJPROP_COLOR,clrDarkMagenta); // 704048< F25B B5:AB0

  }

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

//|                                                                  |

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

double Info_Print()

  {

   double change=0.0; // >1JO28< 8 8=8F80;878@C5< ?5@5<5==CN change (87<5=5=85 F5=K 2 % A <><5=B0 >B:@KB8O B>@3>2>9 A5AA88)

   MqlTick mql_tick; // >1JO28< 8 8=8F80;878@C5< ?5@5<5==CN mql_tick 4;O C?@>I5==>3> 4>ABC?0 : AB@C:BC@5 MqlTick

   SymbolInfoTick(_Symbol,mql_tick); // ?>;CG8< 0:BC0;L=K5 B5:CI85 F5=K

   double price_bid=mql_tick.bid; // ?>;CG8< B5:CICN F5=C bid

   double price_open_day=iOpen(_Symbol,PERIOD_D1,0); // ?>;CG8< F5=C >B:@KB8O B>@3>2>9 A5AA88

   if(price_open_day>0 && price_bid>0) // 5A;8 2A5 F5=K ?>;CG5=K 8 >=8 1>;LH5 =C;O

      change=((price_bid-price_open_day)*100)/price_open_day; // 2KG8A;O5< 87<5=5=85 F5=K 2 %

   return(change); // 2>72@0I05< 7=0G5=85 87<5=5=8O F5=K 2 %

  }

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

//| 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[])

  {

//--- 2K2>48< =04?8AL 2 ?@02>9 =86=59 G0AB8 >:=0 3@0D8:0

   Label_Create("7<5=5=85 F5=K A <><5=B0 >B:@KB8O B>@3>2>9 A5AA88 = " + DoubleToString(Info_Print(),2)+" %");

//--- 2>72@0I05< 7=0G5=85 rates_total 4;O A;54CNI53> 2K7>20

   return(rates_total);

  }

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

Comments