Author: Copyright 2016, AM2
0 Views
0 Downloads
0 Favorites
ColorDay
ÿþ//+------------------------------------------------------------------+

//|                                                     ColorDay.mq5 |

//|                                              Copyright 2016, AM2 |

//|                                      http://www.forexsystems.biz |

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

#property copyright "Copyright 2016, AM2"

#property link      "http://www.forexsystems.biz"

#property version   "1.00"

#property strict

#property indicator_chart_window



#property indicator_buffers 0

#property indicator_plots   0



input int   Days = 11;  // 4=59 4;O @0AG5B0

input color UP = Blue;  // F25B 1KGL53> 4=O 

input color DN = Red;   // F25B <54256L53> 4=O



datetime tm[];

double op[];

double cl[];

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

//| Custom indicator initialization function                         |

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

int OnInit()

  {

//--- indicator buffers mapping

   Comment("");

   ArrayResize(tm,Days);

   ArrayResize(op,Days);

   ArrayResize(cl,Days);

//---

   return(INIT_SUCCEEDED);

  }

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

//|                                                                  |

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

void OnDeinit(const int reason)

  {

   Comment("");

   DeleteObjects();

  }

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

//|                                                                  |

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

void DeleteObjects()

  {

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

     {

      string name=ObjectName(0,i,0,OBJ_RECTANGLE);

      if(StringFind(name,"Rect",0)>=0) ObjectDelete(0,name);

     }

  }

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

//|                                                                  |

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

void PutRect(string name,datetime t1,double p1,datetime t2,double p2,color clr)

  {

   ObjectDelete(0,name);

//--- A>74048< ?@O<>C3>;L=8: ?> 7040==K< :>>@48=0B0<

   ObjectCreate(0,name,OBJ_RECTANGLE,0,t1,p1,t2,p2);

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

   ObjectSetInteger(0,name,OBJPROP_COLOR,clr);

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

   ObjectSetInteger(0,name,OBJPROP_FILL,true);

  }

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

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

  {

//---

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

     {

      CopyTime(NULL,PERIOD_D1,0,Days+1,tm);

      CopyOpen(NULL,PERIOD_D1,0,Days+1,op);

      CopyClose(NULL,PERIOD_D1,0,Days+1,cl);



      datetime time0=tm[i];

      datetime time1=time0+3600*24;

      double dopen=op[i];

      double dclose=cl[i];



      if(dclose<dopen) PutRect("Rect"+(string)dopen,time0,dopen,time1,dclose,DN);

      if(dclose>dopen) PutRect("Rect"+(string)dopen,time0,dopen,time1,dclose,UP);

     }



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

   return(rates_total);

  }

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

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