Author: Copyright © 2005, Danilla
2 Views
0 Downloads
0 Favorites
ParTest
ÿþ//+------------------------------------------------------------------+

//|                                                      ParTest.mq5 |

//|                                        Copyright © 2005, Danilla |

//|                                                                  |

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

//---- 02B>@AB2> 8=48:0B>@0

#property copyright "Copyright © 2005, Danilla"

//---- AAK;:0 =0 A09B 02B>@0

#property link      ""

//---- =><5@ 25@A88 8=48:0B>@0

#property version   "1.00"

//---- >B@8A>2:0 8=48:0B>@0 2 3;02=>< >:=5

#property indicator_chart_window

//---- 2 8=48:0B>@5 =5B 8=48:0B>@=KE 1CD5@>2

#property indicator_buffers 0 

//---- 2 8=48:0B>@5 =5B 3@0D8G5A:8E ?>AB@>5=89

#property indicator_plots  0 

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

//|  >1JO2;5=85 ?5@5G8A;5=8O          |

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

enum Number

  {

   Number_0,

   Number_1,

   Number_2,

   Number_3

  };

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

//|  >1JO2;5=85 ?5@5G8A;5=8O          |

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

enum Width

  {

   Width_1=1, //1

   Width_2,   //2

   Width_3,   //3

   Width_4,   //4

   Width_5    //5

  };

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

//|  >1JO2;5=85 ?5@5G8A;5=8O          |

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

enum STYLE

  {

   SOLID_,//!?;>H=0O ;8=8O

   DASH_,//(B@8E>20O ;8=8O

   DOT_,//C=:B8@=0O ;8=8O

   DASHDOT_,//(B@8E-?C=:B8@=0O ;8=8O

   DASHDOTDOT_   //(B@8E-?C=:B8@=0O ;8=8O A 42>9=K<8 B>G:0<8

  };

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

//|  >1JO2;5=85 :>=AB0=B                         |

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

#define RESET       0 // >=AB0=B0 4;O 2>72@0B0 B5@<8=0;C :><0=4K =0 ?5@5AGQB 8=48:0B>@0

#define DAYSSIZE    60*60*24 // :>=AB0=B0 :>;8G5AB20 A5:C=4 2 4=5

#define SIZE10HOURS 60*60*10 // :>=AB0=B0 :>;8G5AB20 A5:C=4 2 10 G0A0E

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

//| E>4=K5 ?0@0<5B@K 8=48:0B>@0                 |

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

input string  IndicatorSirname="Paramon";

//----

input color  Up_Color = clrMediumSeaGreen; //F25B 25@E=53> C@>2=O

input color  UpFill_Color = clrPaleGreen; //F25B 70;82:8 25@E=53> C@>2=O

input color  Md_Color = clrBlue; //F25B A@54=53> C@>2=O

input color  Dn_Color=clrMagenta; //F25B  =86=53> C@>2=O

input color  DnFill_Color=clrPlum; //F25B 70;82:8 =86=53> C@>2=O

input color  DayColor=clrBlueViolet; //F25B C@>2=O =0G0;0 4=O

//----

input STYLE  Up_Style = SOLID_;      //AB8;L 25@=53> C@>2=O

input STYLE  Md_Style = DASHDOTDOT_; //AB8;L A@54=53> C@>2=O

input STYLE  Dn_Style = SOLID_;      //AB8;L =86=53> C@>2=O

input STYLE  DayStyle = SOLID_;      //AB8;L C@>2=O =0G0;0 4=O

//----

input Width  Up_Width = Width_3; //B>;I8=0 25@=53> C@>2=O

input Width  Md_Width = Width_1; //B>;I8=0 A@54=53> C@>2=O

input Width  Dn_Width = Width_3; //B>;I8=0 =86=53> C@>2=O

input Width  DayWidth = Width_3; //B>;I8=0 C@>2=O =0G0;0 4=O



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

//---- >1JO2;5=85 48=0<8G5A:8E <0AA82>2, :>B>@K5 1C4CB 2 

// 40;L=59H5< 8A?>;L7>20=K 2 :0G5AB25 8=48:0B>@=KE 1CD5@>2

double ExtMapBuffer1[];

double ExtMapBuffer2[];

//----

int DayExtremumsOffset=3600;

string UpLineName,MiddleLineName,DownLineName,DayLineName,UpRectangleName,DnRectangleName;

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

//| Custom indicator initialization function                         |

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

void OnInit()

  {

//----

   UpLineName=IndicatorSirname+" UpLine";

   MiddleLineName=IndicatorSirname+" MiddleLine";

   DownLineName=IndicatorSirname+" DownLine";

   DayLineName=IndicatorSirname+" DayLine";

   UpRectangleName=IndicatorSirname+" UpRectangle";

   DnRectangleName=IndicatorSirname+" DownRectangle";

//---- A>740=85 <5B>: 4;O >B>1@065=8O 2 DataWindow 8 8<5=8 4;O >B>1@065=8O 2 >B45;L=>< ?>4>:=5 8 2> 2A?;K20NI59 ?>4A:07:5

   IndicatorSetString(INDICATOR_SHORTNAME,"Paramon");

//----

  }

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

//| Custom indicator deinitialization function                       |

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

void OnDeinit(const int reason)

  {

//----

   ObjectDelete(0,UpLineName);

   ObjectDelete(0,MiddleLineName);

   ObjectDelete(0,DownLineName);

   ObjectDelete(0,DayLineName);

   ObjectDelete(0,UpRectangleName);

   ObjectDelete(0,DnRectangleName);

//----

   ChartRedraw(0);

  }

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

//| Custom indicator iteration function                              |

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

int OnCalculate(

                const int rates_total,    // :>;8G5AB2> 8AB>@88 2 10@0E =0 B5:CI5< B8:5

                const int prev_calculated,// :>;8G5AB2> 8AB>@88 2 10@0E =0 ?@54K4CI5< B8:5

                const datetime &time[],

                const double &open[],

                const double& high[],     // F5=>2>9 <0AA82 <0:A8<C<>2 F5=K 4;O @0AGQB0 8=48:0B>@0

                const double& low[],      // F5=>2>9 <0AA82 <8=8<C<>2 F5=K  4;O @0AGQB0 8=48:0B>@0

                const double &close[],

                const long &tick_volume[],

                const long &volume[],

                const int &spread[]

                )

  {

//---- 8=45:A0F8O M;5<5=B>2 2 <0AA820E :0: 2 B09<A5@8OE  

   ArraySetAsSeries(time,true);

   ArraySetAsSeries(high,true);

   ArraySetAsSeries(low,true);

//----  

   double lowprice,highprice,avprice;

   int DayExtremumsBarOffset=0;

   datetime iTime[];

//----   



//---- :>?8@C5< 2=>2L ?>O282H85AO 40==K5 2 <0AA82 iTime[]

   if(CopyTime(Symbol(),PERIOD_D1,0,1,iTime)<=0) return(RESET);

   

   int bar=0;

   while(time[bar]>=iTime[0]) bar++;

   if(bar) bar--;

//----

   if(TimeCurrent()%DAYSSIZE>SIZE10HOURS)

     {

      while(time[0]-time[DayExtremumsBarOffset]<DayExtremumsOffset && time[DayExtremumsBarOffset]%DAYSSIZE>SIZE10HOURS)

         DayExtremumsBarOffset++;



      if(DayExtremumsBarOffset) DayExtremumsBarOffset--;

     }

//----  

    lowprice=low[ArrayMinimum(low,DayExtremumsBarOffset,bar-DayExtremumsBarOffset)];

    highprice=high[ArrayMaximum(high,DayExtremumsBarOffset,bar-DayExtremumsBarOffset)];

   avprice=(highprice+lowprice)/2;

//----

   SetRectangle(0,UpRectangleName,0,time[bar],avprice,time[0]+PeriodSeconds(),highprice,UpFill_Color,SOLID_,Width_1,UpRectangleName+DoubleToString(highprice,_Digits));

   SetRectangle(0,DnRectangleName,0,time[bar],avprice,time[0]+PeriodSeconds(),lowprice,DnFill_Color,SOLID_,Width_1,DnRectangleName+DoubleToString(lowprice,_Digits));

   SetHline(0,UpLineName,0,highprice,Up_Color,Up_Style,Up_Width,UpLineName+DoubleToString(highprice,_Digits));

   SetHline(0,MiddleLineName,0,avprice,Md_Color,Md_Style,Md_Width,MiddleLineName+DoubleToString(avprice,_Digits));

   SetHline(0,DownLineName,0,lowprice,Dn_Color,Dn_Style,Dn_Width,DownLineName+DoubleToString(lowprice,_Digits));

   SetVline(0,DayLineName,0,time[bar],DayColor,DayStyle,DayWidth,true,"4=52=>9 10@");  

//----

   ChartRedraw(0);

   return(rates_total);

  }

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

//|  !>740=85 ?@O<>C3>;L=8:0                                         |

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

void CreateRectangle

(

 long     chart_id,      // 845=B8D8:0B>@ 3@0D8:0

 string   name,          // 8<O >1J5:B0

 int      nwin,          // 8=45:A >:=0

 datetime time1,         // 2@5<O 1 F5=>2>3> C@>2=O

 double   price1,        // 1 F5=>2>9 C@>25=L

 datetime time2,         // 2@5<O 2 F5=>2>3> C@>2=O

 double   price2,        // 2 F5=>2>9 C@>25=L

 color    Color,         // F25B ;8=88

 int      style,         // AB8;L ;8=88

 int      width,         // B>;I8=0 ;8=88

 string   text           // B5:AB

 )

//---- 

  {

//----

   ObjectCreate(chart_id,name,OBJ_RECTANGLE,nwin,time1,price1,time2,price2);

   ObjectSetInteger(chart_id,name,OBJPROP_COLOR,Color);

   ObjectSetInteger(chart_id,name,OBJPROP_STYLE,style);

   ObjectSetInteger(chart_id,name,OBJPROP_WIDTH,width);

   ObjectSetString(chart_id,name,OBJPROP_TEXT,text);

   ObjectSetInteger(chart_id,name,OBJPROP_BACK,false);

   ObjectSetInteger(chart_id,name,OBJPROP_RAY_RIGHT,true);

   ObjectSetInteger(chart_id,name,OBJPROP_SELECTED,true);

   ObjectSetInteger(chart_id,name,OBJPROP_SELECTABLE,true);

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

   ObjectSetInteger(chart_id,name,OBJPROP_FILL,true); 

//----

  }

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

//|  5@5CAB0=>2:0 ?@O<>C3>;L=8:0                                    |

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

void SetRectangle

(

 long     chart_id,      // 845=B8D8:0B>@ 3@0D8:0

 string   name,          // 8<O >1J5:B0

 int      nwin,          // 8=45:A >:=0

 datetime time1,         // 2@5<O 1 F5=>2>3> C@>2=O

 double   price1,        // 1 F5=>2>9 C@>25=L

 datetime time2,         // 2@5<O 2 F5=>2>3> C@>2=O

 double   price2,        // 2 F5=>2>9 C@>25=L

 color    Color,         // F25B ;8=88

 int      style,         // AB8;L ;8=88

 int      width,         // B>;I8=0 ;8=88

 string   text           // B5:AB

 )

//---- 

  {

//----

   if(ObjectFind(chart_id,name)==-1) CreateRectangle(chart_id,name,nwin,time1,price1,time2,price2,Color,style,width,text);

   else

     {

      ObjectSetString(chart_id,name,OBJPROP_TEXT,text);

      ObjectMove(chart_id,name,0,time1,price1);

      ObjectMove(chart_id,name,1,time2,price2);

      ObjectSetInteger(chart_id,name,OBJPROP_COLOR,Color);

     }

//----

  }

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

//|  !>740=85 3>@87>=B0;L=>3>, F5=>2>3> C@>2=O                       |

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

void CreateHline

(

 long   chart_id,      // 845=B8D8:0B>@ 3@0D8:0

 string name,          // 8<O >1J5:B0

 int    nwin,          // 8=45:A >:=0

 double price,         // F5=>2>9 C@>25=L

 color  Color,         // F25B ;8=88

 int    style,         // AB8;L ;8=88

 int    width,         // B>;I8=0 ;8=88

 string text           // B5:AB

 )

//---- 

  {

//----

   ObjectCreate(chart_id,name,OBJ_HLINE,0,0,price);

   ObjectSetInteger(chart_id,name,OBJPROP_COLOR,Color);

   ObjectSetInteger(chart_id,name,OBJPROP_STYLE,style);

   ObjectSetInteger(chart_id,name,OBJPROP_WIDTH,width);

   ObjectSetString(chart_id,name,OBJPROP_TEXT,text);

   ObjectSetInteger(chart_id,name,OBJPROP_BACK,true);

//----

  }

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

//|  5@5CAB0=>2:0 3>@87>=B0;L=>3>, F5=>2>3> C@>2=O                  |

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

void SetHline

(

 long   chart_id,      // 845=B8D8:0B>@ 3@0D8:0

 string name,          // 8<O >1J5:B0

 int    nwin,          // 8=45:A >:=0

 double price,         // F5=>2>9 C@>25=L

 color  Color,         // F25B ;8=88

 int    style,         // AB8;L ;8=88

 int    width,         // B>;I8=0 ;8=88

 string text           // B5:AB

 )

//---- 

  {

//----

   if(ObjectFind(chart_id,name)==-1) CreateHline(chart_id,name,nwin,price,Color,style,width,text);

   else

     {

      //ObjectSetDouble(chart_id,name,OBJPROP_PRICE,price);

      ObjectSetString(chart_id,name,OBJPROP_TEXT,text);

      ObjectMove(chart_id,name,0,0,price);

     }

//----

  }

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

//|  !>740=85 25@B8:0;L=>9 ;8=88                                     |

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

void CreateVline

(

 long     chart_id,      // 845=B8D8:0B>@ 3@0D8:0

 string   name,          // 8<O >1J5:B0

 int      nwin,          // 8=45:A >:=0

 datetime time1,         // 2@5<O 25@B8:0;L=>3> C@>2=O

 color    Color,         // F25B ;8=88

 int      style,         // AB8;L ;8=88

 int      width,         // B>;I8=0 ;8=88

 bool     background,// D>=>2>5 >B>1@065=85 ;8=88

 string   text           // B5:AB

 )

//---- 

  {

//----

   ObjectCreate(chart_id,name,OBJ_VLINE,nwin,time1,999999999);

   ObjectSetInteger(chart_id,name,OBJPROP_COLOR,Color);

   ObjectSetInteger(chart_id,name,OBJPROP_STYLE,style);

   ObjectSetInteger(chart_id,name,OBJPROP_WIDTH,width);

   ObjectSetString(chart_id,name,OBJPROP_TEXT,text);

   ObjectSetInteger(chart_id,name,OBJPROP_BACK,background);

   ObjectSetInteger(chart_id,name,OBJPROP_RAY,true);

   ObjectSetString(chart_id,name,OBJPROP_TOOLTIP,"\n"); //70?@5B 2A?;K20NI59 ?>4A:07:8

   ObjectSetInteger(chart_id,name,OBJPROP_BACK,true); //>1J5:B =0 704=5< ?;0=5

//----

  }

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

//|  5@5CAB0=>2:0 25@B8:0;L=>9 ;8=88                                |

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

void SetVline

(

 long     chart_id,      // 845=B8D8:0B>@ 3@0D8:0

 string   name,          // 8<O >1J5:B0

 int      nwin,          // 8=45:A >:=0

 datetime time1,         // 2@5<O 25@B8:0;L=>3> C@>2=O

 color    Color,         // F25B ;8=88

 int      style,         // AB8;L ;8=88

 int      width,         // B>;I8=0 ;8=88

 bool     background,// D>=>2>5 >B>1@065=85 ;8=88

 string   text           // B5:AB

 )

//---- 

  {

//----

   if(ObjectFind(chart_id,name)==-1) CreateVline(chart_id,name,nwin,time1,Color,style,width,background,text);

   else

     {

      ObjectSetString(chart_id,name,OBJPROP_TEXT,text);

      ObjectMove(chart_id,name,0,time1,999999999);

     }

//----

  }

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

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