fractal+text

Author: Copyright � 2007, HexSys
fractal+text
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
fractal+text
//+------------------------------------------------------------------+
//|                                         Copyright © 2007, HexSys |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, HexSys"
#property link      ""

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue

//---- input parameters
extern int       viewBars=200;
extern color     cUP=Magenta;
extern color     cDO=SkyBlue;
//---- buffers
double fractalUP[];
double fractalDO[];

int Time0 = 0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators   
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,217);
   SetIndexBuffer(0,fractalUP);
   SetIndexEmptyValue(0,0.0);
   
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,218);
   SetIndexBuffer(1,fractalDO);
   SetIndexEmptyValue(1,0.0);
//----
   
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
  for(int i=1; i<=viewBars+1;i++)
  {
   DeleteObjects("fracUP"+i); 
   DeleteObjects("fracDO"+i);
  } 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//----
   //---------------------------
   if (Time0 == Time[0]) return;
   Time0 = Time[0];
   //---------------------------
   
   ArrayInitialize(fractalUP,0);
   ArrayInitialize(fractalDO,0);
   
   
   
   for(int i=1; i<viewBars; i++)
   {
      if(i>2)
      {
         if(High[i+1]<High[i] && High[i]>=High[i-1] && High[i+2]<High[i] && High[i]>=High[i-2]) 
         {
            fractalUP[i]=High[i];
            CreateObjects("fracUP"+i,cUP,i,High[i]);
         }
         if(Low[i+1]>Low[i] && Low[i]<=Low[i-1] && Low[i+2]>Low[i] && Low[i]<=Low[i-2])
         {
            fractalDO[i]=Low[i];
            CreateObjects("fracDO"+i,cDO,i,Low[i]);
         }
      }
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+


//--------------------------------------------------
// CreateObjects - ñîçäàåò ãîðèçîíòàëüíóþ ëèíèþ
//--------------------------------------------------
void CreateObjects(string nm, color cl, int sh, double pr) 
{
 datetime t=Time[sh];
 
 if (ObjectFind(nm)==-1)
 {
  ObjectCreate(nm,OBJ_ARROW,0,0,0);
  ObjectSet(nm,OBJPROP_COLOR,cl);
  //ObjectSetText(nm,txt);
 }
 ObjectSet(nm,OBJPROP_ARROWCODE,SYMBOL_LEFTPRICE);
 ObjectSet(nm,OBJPROP_PRICE1,pr);
 ObjectSet(nm,OBJPROP_TIME1,t);
 ObjectSetText(nm,DoubleToStr(pr,4));
 //ObjectSet(nm,OBJPROP_WIDTH,0);
 //ObjectSet(nm,OBJPROP_BACK,True);
 //ObjectSet(nm,OBJPROP_STYLE,STYLE_DOT);
 //ObjectSet(nm,OBJPROP_TIMEFRAMES,0x001F);
}

//--------------------------------------------------
// DeleteObjects - 
//--------------------------------------------------
void DeleteObjects(string nm) 
{
 if (ObjectFind(nm)!=-1)
 {
  ObjectDelete(nm);
 }
}

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