Navigation:Home > Content >

Moon.mq4

Time: 2014-06-09 | Download file:Moon.mq4

//+------------------------------------------------------------------+
//|                                                         Moon.mq4 |
//|                                Copyright © 2008, Borys Chekmasov |
//|                                 http://www.uatrader.blogspot.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Borys Chekmasov"
#property link      "http://www.uatrader.blogspot.com"

#property indicator_chart_window

extern color moon_color = ForestGreen;
extern datetime start_cycle = D'2008.01.08  11:38:00';
extern double period_cycle = 2551442.82048;
int prd;
int init()
  {
prd=MathFloor((Time[1]-start_cycle)/period_cycle);

   return(0);
  }

int deinit()
  {
for(int i=0; i<=((Time[1]-start_cycle)/period_cycle); i++)
     {
     ObjectDelete("FullMoon"+i);
     ObjectDelete("LastQuarter"+i);
     ObjectDelete("NewMoon"+i);
     ObjectDelete("FirstQuarter"+i);
     }
   return(0);
  }

int start()
  {
  
 int i;

if (Period()>PERIOD_D1)
{
for(i=0; i<=prd; i++)
     {
     ObjectDelete("FullMoon"+i);
     ObjectDelete("LastQuarter"+i);
     ObjectDelete("NewMoon"+i);
     ObjectDelete("FirstQuarter"+i);
     }
}
else
{
for(i=0; i<=prd; i++)
     {
     if (ObjectFind("FullMoon"+i)==-1)
     {
ObjectCreate("FullMoon"+i,OBJ_TEXT,0,start_cycle+period_cycle*i, Low[1]-20*Point);
ObjectSetText("FullMoon"+i,StringSetChar(" ", 0, 0129),12,"Wingdings 2",moon_color);

ObjectCreate("LastQuarter"+i,OBJ_TEXT,0,(start_cycle+period_cycle*i+MathFloor(period_cycle/4)), Low[1]-20*Point);
ObjectSetText("LastQuarter"+i,StringSetChar(" ", 0, 0131),12,"Wingdings 2",moon_color); 

ObjectCreate("NewMoon"+i,OBJ_TEXT,0,start_cycle+period_cycle*i+MathFloor(period_cycle/2), Low[1]-20*Point);
ObjectSetText("NewMoon"+i,StringSetChar(" ", 0, 0152),12,"Wingdings 2",moon_color);

ObjectCreate("FirstQuarter"+i,OBJ_TEXT,0,start_cycle+period_cycle*i+MathFloor(period_cycle*3/4), Low[1]-20*Point);
ObjectSetText("FirstQuarter"+i,StringSetChar(" ", 0, 0130),12,"Wingdings 2",moon_color);
}  
     }
}

   return(0);
  }
//+------------------------------------------------------------------+

Recommend