Exp_-_indicatorZZxFibo

Author: Copyright © 2009, expforex
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
Exp_-_indicatorZZxFibo
ÿþ//+------------------------------------------------------------------+

//|                                       Exp - indicatorZZ+Fibo.mq4 |

//|                                       Copyright © 2009, expforex |

//|                                        http://www.expforex.com |

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

#property copyright "Copyright © 2009, expforex"

#property link      "http://www.expforex.com"

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

#property indicator_chart_window

#property indicator_buffers 1

#property indicator_color1 Green

//----

extern int Length=6;

extern int CountBars=1000;   // >;8G5AB2> >B>1@0605<KE 10@>2

//----

double buffer[];        double FiboLevels[];

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

//|                                                                  |

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

void init()

  {

   Stamp();

   SetIndexStyle(0,DRAW_SECTION,0,1);

   SetIndexBuffer(0,buffer);

   SetIndexLabel(0,"Value");

   SetIndexDrawBegin(0,0);

  }

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

//|                                                                  |

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

void start()

  {

   int shift,zu,zd,Swing,Swing_n;

   double HH,LL,BH,BL;

//----

   Swing=0;

   Swing_n=0;

   shift=CountBars-1;

   zu=shift;

   zd=shift;

   BH=High[shift];

   BL=Low[shift];

//----

   for(shift=CountBars-1; shift>=0; shift--)

     {

      HH=High[Highest(NULL,0,MODE_HIGH,Length,shift+1)];

      LL=Low [Lowest (NULL,0,MODE_LOW ,Length,shift+1)];

      if(Low[shift]<LL && High[shift]>HH)

        {

         Swing=2;

         if(Swing_n== 1) zu=shift+1;

         if(Swing_n==-1) zd=shift+1;

        }

      else

        {

         if(Low [shift]<LL) Swing=-1;

         if(High[shift]>HH) Swing= 1;

        }

      if(Swing!=Swing_n && Swing_n!=0)

        {

         if(Swing== 2) {Swing=-Swing_n; BH=High[shift]; BL=Low[shift];}

         if(Swing== 1) {buffer[zd]=BL;FiboCreate(Low[shift],High[shift],shift);}

         if(Swing==-1) {buffer[zu]=BH;FiboCreate(Low[shift],High[shift],shift);}

         BH=High[shift];

         BL=Low [shift];

        }

      if(Swing== 1) {if(High[shift]>=BH) {BH=High[shift]; zu=shift;}}

      if(Swing==-1) {if(Low [shift]<=BL) {BL=Low [shift]; zd=shift;}}

      Swing_n=Swing;



     }

  }

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

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



void deinit()



  {

   ObjectDelete("object");

  }

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

//|                                                                  |

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

void Stamp()

  {



   ObjectCreate("Original",OBJ_LABEL,0,0,0);

   ObjectSetText("Original"," @>3@0<<8@>20=85: ---www.expforex.com---",15,"Arial Bold",Green);

   ObjectSet("Original",OBJPROP_CORNER,2);

   ObjectSet("Original",OBJPROP_XDISTANCE,300);

   ObjectSet("Original",OBJPROP_YDISTANCE,20);



  }

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

//|                                                                  |

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

void FiboCreate(double low=0,double high=0,int h=0)

  {

   ObjectDelete("object");

   ObjectCreate("object",OBJ_FIBO,0,Time[h],high,Time[h-1],low);

   ObjectSet("object",OBJPROP_RAY,0);

   if(Period()==5) ObjectSet("object",OBJPROP_TIMEFRAMES,OBJ_PERIOD_M5);

   if(Period()==15) ObjectSet("object",OBJPROP_TIMEFRAMES,OBJ_PERIOD_M15);

   if(Period()==30) ObjectSet("object",OBJPROP_TIMEFRAMES,OBJ_PERIOD_M30);

   if(Period()==60) ObjectSet("object",OBJPROP_TIMEFRAMES,OBJ_PERIOD_H1);

   ObjectSet("object",OBJPROP_FIBOLEVELS,13);

   ObjectSet("object",OBJPROP_FIRSTLEVEL,0.0);

   ObjectSet("object",OBJPROP_FIRSTLEVEL+1,1.0);

   ObjectSet("object",OBJPROP_FIRSTLEVEL+2,1.61);

   ObjectSet("object",OBJPROP_FIRSTLEVEL+3,2.61);

   ObjectSet("object",OBJPROP_FIRSTLEVEL+4,3.61);

   ObjectSet("object",OBJPROP_FIRSTLEVEL+5,4.23);

   ObjectSet("object",OBJPROP_FIRSTLEVEL+6,4.61);

   ObjectSet("object",OBJPROP_FIRSTLEVEL+7,-1.0);

   ObjectSet("object",OBJPROP_FIRSTLEVEL+8,-1.61);

   ObjectSet("object",OBJPROP_FIRSTLEVEL+9,-2.61);

   ObjectSet("object",OBJPROP_FIRSTLEVEL+10,-3.61);

   ObjectSet("object",OBJPROP_FIRSTLEVEL+11,-4.23);

   ObjectSet("object",OBJPROP_FIRSTLEVEL+12,-4.61);

   ObjectSetFiboDescription("object",0,"0:A8<C<");

   ObjectSetFiboDescription("object",1,"#@>25=L 100");

   ObjectSetFiboDescription("object",2,"#@>25=L 161");

   ObjectSetFiboDescription("object",3,"#@>25=L 261");

   ObjectSetFiboDescription("object",4,"#@>25=L 361");

   ObjectSetFiboDescription("object",5,"#@>25=L 423");

   ObjectSetFiboDescription("object",6,"#@>25=L 461");

   ObjectSetFiboDescription("object",7,"#@>25=L -100");

   ObjectSetFiboDescription("object",8,"#@>25=L -161");

   ObjectSetFiboDescription("object",9,"#@>25=L -261");

   ObjectSetFiboDescription("object",10,"#@>25=L -361");

   ObjectSetFiboDescription("object",11,"#@>25=L -423");

   ObjectSetFiboDescription("object",12,"#@>25=L -461");



//----

   ObjectSet("object",OBJPROP_LEVELSTYLE,STYLE_DASHDOTDOT);

   ObjectSet("object",OBJPROP_LEVELWIDTH,2);

   ObjectSet("object",OBJPROP_LEVELCOLOR,Red);

//----

   ObjectSet("object",OBJPROP_STYLE,STYLE_DASH);

   ObjectSet("object",OBJPROP_WIDTH,1);

   ObjectSet("object",OBJPROP_COLOR,Blue);

   WindowRedraw();



   if(ObjectsTotal(OBJ_FIBO)>0)

     {

      string name="";

      for(int o=ObjectsTotal()-1; o>=0; o --)

        {

         name=ObjectName(o);

         if(ObjectType(name)!=OBJ_FIBO) continue;



         int levels_count=ObjectGet(name,OBJPROP_FIBOLEVELS);

         if(levels_count<1) break;



         ArrayResize(FiboLevels,levels_count);



         double price_000 = ObjectGet( name, OBJPROP_PRICE2 );

         double price_100 = ObjectGet( name, OBJPROP_PRICE1 );



         for(int l=0; l<levels_count; l++)

           {

            FiboLevels[l]=price_000+(price_100-price_000)*ObjectGet(name,OBJPROP_FIRSTLEVEL+l);

           }



         break;

        }

     }

   Comment(

           " FiboLevels[0]="+FiboLevels[0]+

           "\n FiboLevels[1]="+FiboLevels[1]+

           "\n FiboLevels[2]="+FiboLevels[2]+

           "\n FiboLevels[3]="+FiboLevels[3]+

           "\n FiboLevels[4]="+FiboLevels[4]+

           "\n FiboLevels[5]="+FiboLevels[5]+

           "\n FiboLevels[6]="+FiboLevels[6]+

           "\n FiboLevels[7]="+FiboLevels[7]+

           "\n FiboLevels[8]="+FiboLevels[8]+

           "\n FiboLevels[9]="+FiboLevels[9]+

           "\n FiboLevels[10]="+FiboLevels[10]+

           "\n FiboLevels[11]="+FiboLevels[11]+

           "\n FiboLevels[12]="+FiboLevels[12]



           );



  }

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

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