Author: Copyright � 2005, MetaQuotes Software Corp.
0 Views
0 Downloads
0 Favorites
Gann_001
#include <stdlib.mqh>
//+------------------------------------------------------------------+
//|                                                         Gann.mq4 |
//|                                    Copyright © 2006, Yousky Soft |
//|                                            http://yousky.free.fr |
//|                                                                  |
//+------------------------------------------------------------------+

#property copyright " Copyright © 2005, MetaQuotes Software Corp."
#property link      " http://www.metaquotes.net/"

#property indicator_chart_window

string id = "gann_01_";

//+------------------------------------------------------------------+
//| Common External variables                                        |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| External variables                                               |
//+------------------------------------------------------------------+
extern double factor = 1;
extern double back   = 1;
extern double GMT    = 2;

//+------------------------------------------------------------------+
//| Special Convertion Functions                                     |
//+------------------------------------------------------------------+

int LastTradeTime;


//bool SetTextObject(string name, string text, string font, int font_size, color text_color=CLR_NONE)
//{
 // ObjectSetText(name, text, font_size, font, text_color);
///}

void create_line(int from,int to,color c,double p0,double p1,int long,int style,int otype){
   static int acc = 0;
   string  buff_str = id+acc; acc++;
   ObjectCreate(buff_str, otype, 0, Time[from]-GMT*3600, p0, Time[to]-GMT*3600, p1);
   ObjectSet(buff_str,OBJPROP_RAY,long);
   ObjectSet(buff_str,OBJPROP_COLOR,c);
   ObjectSet(buff_str,OBJPROP_XDISTANCE,100);
   ObjectSet(buff_str,OBJPROP_YDISTANCE,100);
   ObjectSet(buff_str,OBJPROP_STYLE,style);
   ObjectSet(buff_str,OBJPROP_BACK,true);
   //ObjectSet(buff_str,OBJPROP_WIDTH,2);
}



//+------------------------------------------------------------------+
//| End                                                              |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| Initialization                                                   |
//+------------------------------------------------------------------+

int init()
{
   return(0);
}

void delete_obj(){
   string  buff_str = "";
   for(int i=ObjectsTotal()-1;i>=0;i--){
      buff_str = ObjectName(i);
      if(StringFind(buff_str,id,0)==0) ObjectDelete(buff_str);
      }
}

int deinit(){
   delete_obj();
   return (0);
}

int last=0;
//================================
int start()  {   
   if(last==Bars) return (0);
   last=Bars;
   
//+------------------------------------------------------------------+
//| Local variables                                                  |
//+------------------------------------------------------------------+
int shift = 0;
double sum = 0;
int v1 = 0;
int v2 = 0;
double v3 = 0;
double v4 = 0;
double loop = 0;
int select = 0;
datetime start_t = 0;
datetime endof_t = 0;
double mult = 0;
double step = 0;
double v45 = 0;
double mml00 = 0;
double mml0 = 0;
double mml1 = 0;
double mml2 = 0;
double mml3 = 0;
double mml4 = 0;
double mml5 = 0;
double mml6 = 0;
double mml7 = 0;
double mml8 = 0;
double mml9 = 0;
double mml98 = 0;
double mml99 = 0;
double range = 0;
double octave = 0;
double mn = 0;
double mx = 0;
double bottomhit = 0;
double bottom = 0;
double top = 0;
double tophit = 0;
int look = 0;
double whereat = 0;
double offset = 0;
double finalH = 0;
double finalL = 0;
double x1 = 0;
double x2 = 0;
double x3 = 0;
double x4 = 0;
double x5 = 0;
double x6 = 0;
double y1 = 0;
double y2 = 0;
double y3 = 0;
double y4 = 0;
double y5 = 0;
double y6 = 0;
datetime lunarCycles_05[8];
delete_obj();
// loop from first bar to current bar (with shift=0)

lunarCycles_05[1] = StrToTime("2005.03.25 0:00");
lunarCycles_05[2] = StrToTime("2005.06.22 0:00"); 
lunarCycles_05[3] = StrToTime("2005.09.18 0:00");
lunarCycles_05[4] = StrToTime("2005.12.15 0:00"); 
lunarCycles_05[5] = StrToTime("2006.03.15 0:00");
lunarCycles_05[6] = StrToTime("2006.06.12 0:00"); 
lunarCycles_05[7] = StrToTime("2006.09.07 0:00");
lunarCycles_05[8] = StrToTime("2006.12.05 0:00"); 


if( 10000 * Point == 1 ) mult = 1;
if( 10000 * Point == 100 ) mult = 100;
step = 0.0244140625 * mult*factor;
offset = step*4;

loop = 0;
for(select =1;select <=8 ;select ++){ 
   if( loop == 0 &&  Time[1] < lunarCycles_05[select] ) {
      loop = 1;
      start_t = lunarCycles_05[select-1]*factor;
      break;
      }
} 

v1 = 1;

for(shift =365;shift >=1 ;shift --){ 
   if( Time[shift] == start_t ) {
      v2 = shift;
      break;
      }	
   } 
mml00 = (Low[Lowest  (NULL, 0, MODE_LOW ,MathAbs(v1-v2),v1)]);
mml0  = (High[Highest(NULL, 0, MODE_HIGH,MathAbs(v1-v2),v1)]);

bottomhit = 0;
tophit = 0;

for(look =1;look <=1000 ;look ++){ 
   whereat = look * (step); 
   if( bottomhit == 0 && whereat > mml00 ) {
      bottomhit = 1;
      bottom = (look-1)*(step);
      }
   if( tophit == 0 && whereat > mml0 ) {
      tophit = 1;
      top = (look+1)*(step);
      }
   } 

Comment(bottom," ",top," ",mml00," ",mml0);
 
create_line(v1,v2,Black,top+offset,top-step+offset,0,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,top-step+offset,top-(step*2)+offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,top-(step*2)+offset,top-(step*3)+offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,top-(step*3)+offset,top-(step*4)+offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,top-(step*4)+offset,top-(step*5)+offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,top-(step*5)+offset,top-(step*6)+offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,top-(step*6)+offset,top-(step*7)+offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,top-(step*7)+offset,top-(step*8)+offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,top-(step*8)+offset,top-(step*9)+offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,top-(step*9)+offset,top-(step*10)+offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,top-(step*10)+offset,top-(step*11)+offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,top-(step*11)+offset,top-(step*12)+offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,top-(step*12)+offset,top-(step*13)+offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,top-(step*13)+offset,top-(step*14)+offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,top-(step*14)+offset,top-(step*15)+offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,top-(step*15)+offset,top-(step*16)+offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,top-(step*16)+offset,top-(step*17)+offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,top-(step*17)+offset,top-(step*18)+offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,top-(step*18)+offset,top-(step*19)+offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,top-(step*19)+offset,top-(step*20)+offset,1,STYLE_SOLID,OBJ_TREND);

create_line(v1,v2,Black,bottom-offset,bottom-offset+step,0,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,bottom+(step*1)-offset,bottom+(step*2)-offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,bottom+(step*2)-offset,bottom+(step*3)-offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,bottom+(step*3)-offset,bottom+(step*4)-offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,bottom+(step*4)-offset,bottom+(step*5)-offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,bottom+(step*5)-offset,bottom+(step*6)-offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,bottom+(step*6)-offset,bottom+(step*7)-offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,bottom+(step*7)-offset,bottom+(step*8)-offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,bottom+(step*8)-offset,bottom+(step*9)-offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,bottom+(step*9)-offset,bottom+(step*10)-offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,bottom+(step*10)-offset,bottom+(step*11)-offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,bottom+(step*11)-offset,bottom+(step*12)-offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,bottom+(step*12)-offset,bottom+(step*13)-offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,bottom+(step*13)-offset,bottom+(step*14)-offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,bottom+(step*14)-offset,bottom+(step*15)-offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,bottom+(step*15)-offset,bottom+(step*16)-offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,bottom+(step*16)-offset,bottom+(step*17)-offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,bottom+(step*17)-offset,bottom+(step*18)-offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,bottom+(step*18)-offset,bottom+(step*19)-offset,1,STYLE_SOLID,OBJ_TREND);
create_line(v1,v2,Black,bottom+(step*19)-offset,bottom+(step*20)-offset,1,STYLE_SOLID,OBJ_TREND);

create_line(0,0,Black,top+offset,top+offset,0,STYLE_SOLID,OBJ_HLINE);
create_line(0,0,Black,top-(step*1)+offset,top-(step*2)+offset,0,STYLE_SOLID,OBJ_HLINE);
create_line(0,0,Black,top-(step*2)+offset,top-(step*3)+offset,0,STYLE_SOLID,OBJ_HLINE);
create_line(0,0,Black,top-(step*3)+offset,top-(step*4)+offset,0,STYLE_SOLID,OBJ_HLINE);
create_line(0,0,Black,top-(step*4)+offset,top-(step*5)+offset,0,STYLE_SOLID,OBJ_HLINE);
create_line(0,0,Black,top-(step*5)+offset,top-(step*6)+offset,0,STYLE_SOLID,OBJ_HLINE);
create_line(0,0,Black,top-(step*6)+offset,top-(step*7)+offset,0,STYLE_SOLID,OBJ_HLINE);
create_line(0,0,Black,top-(step*7)+offset,top-(step*8)+offset,0,STYLE_SOLID,OBJ_HLINE);
create_line(0,0,Black,top-(step*8)+offset,top-(step*9)+offset,0,STYLE_SOLID,OBJ_HLINE);
create_line(0,0,Black,top-(step*9)+offset,top-(step*10)+offset,0,STYLE_SOLID,OBJ_HLINE);
create_line(0,0,Black,top-(step*10)+offset,top-(step*11)+offset,0,STYLE_SOLID,OBJ_HLINE);
create_line(0,0,Black,top-(step*11)+offset,top-(step*12)+offset,0,STYLE_SOLID,OBJ_HLINE);
create_line(0,0,Black,top-(step*12)+offset,top-(step*13)+offset,0,STYLE_SOLID,OBJ_HLINE);
create_line(0,0,Black,top-(step*13)+offset,top-(step*14)+offset,0,STYLE_SOLID,OBJ_HLINE);
create_line(0,0,Black,top-(step*14)+offset,top-(step*15)+offset,0,STYLE_SOLID,OBJ_HLINE);
create_line(0,0,Black,top-(step*15)+offset,top-(step*16)+offset,0,STYLE_SOLID,OBJ_HLINE);


create_line(0,0,Black,top-(step*0.5)+offset,top-(step*0.5)+offset,0,STYLE_SOLID,OBJ_HLINE);
create_line(0,0,Black,top-(step*1.5)+offset,top-(step*1.5)+offset,0,STYLE_SOLID,OBJ_HLINE);
create_line(0,0,Black,top-(step*2.5)+offset,top-(step*2.5)+offset,0,STYLE_SOLID,OBJ_HLINE);
create_line(0,0,Black,top-(step*3.5)+offset,top-(step*3.5)+offset,0,STYLE_SOLID,OBJ_HLINE);
create_line(0,0,Black,top-(step*4.5)+offset,top-(step*4.5)+offset,0,STYLE_SOLID,OBJ_HLINE);
create_line(0,0,Black,top-(step*5.5)+offset,top-(step*5.5)+offset,0,STYLE_SOLID,OBJ_HLINE);
create_line(0,0,Black,top-(step*6.5)+offset,top-(step*6.5)+offset,0,STYLE_SOLID,OBJ_HLINE);
create_line(0,0,Black,top-(step*7.5)+offset,top-(step*7.5)+offset,0,STYLE_SOLID,OBJ_HLINE);
create_line(0,0,Black,top-(step*8.5)+offset,top-(step*8.5)+offset,0,STYLE_SOLID,OBJ_HLINE);
create_line(0,0,Black,top-(step*9.5)+offset,top-(step*9.5)+offset,0,STYLE_SOLID,OBJ_HLINE);
create_line(0,0,Black,top-(step*10.5)+offset,top-(step*10.5)+offset,0,STYLE_SOLID,OBJ_HLINE);
create_line(0,0,Black,top-(step*11.5)+offset,top-(step*11.5)+offset,0,STYLE_SOLID,OBJ_HLINE);
create_line(0,0,Black,top-(step*12.5)+offset,top-(step*12.5)+offset,0,STYLE_SOLID,OBJ_HLINE);
create_line(0,0,Black,top-(step*13.5)+offset,top-(step*13.5)+offset,0,STYLE_SOLID,OBJ_HLINE);
create_line(0,0,Black,top-(step*14.5)+offset,top-(step*14.5)+offset,0,STYLE_SOLID,OBJ_HLINE);



  return(0);
}

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