Miscellaneous
0
Views
0
Downloads
0
Favorites
FastFractals
//+------------------------------------------------------------------+
//| FractalsPaint.mq4 |
//| Copyright © 2006 Scorpion@fxfisherman.com |
//+------------------------------------------------------------------+
#property copyright "FxFisherman.com"
#property link "http://www.fxfisherman.com"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
extern int Shift_Bars=0;
int Bars_Count= 0;
//---- buffers
double v1[];
double v2[];
int init()
{
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(0,v1);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexBuffer(1,v2);
watermark();
return(0);
}
int start()
{
bool hiFractal;
bool loFractal;
int curFractal;
double price;
int i;
int shift;
int counted_bars = IndicatorCounted();
if (counted_bars > 0) counted_bars--;
if (Bars_Count > 0 && Bars_Count <= Bars)
{
i = Bars_Count - counted_bars;
}else{
i = Bars - counted_bars;
}
while(i>=0)
{
shift = i + Shift_Bars;
// Resistance
price = High[shift+3];
hiFractal = price > High[shift+2] &&
price > High[shift+1];
// Support
price = Low[shift+3];
loFractal = price < Low[shift+2] &&
price < Low[shift+1];
if (hiFractal && !loFractal) {
curFractal = -1;
}else if(loFractal && !hiFractal) {
curFractal = 1;
}else if(loFractal && hiFractal){
curFractal = 0;
}
if (curFractal == 1) {
v2[i] = High[i];
v1[i] = Low[i];
}else if(curFractal == -1) {
v1[i] = High[i];
v2[i] = Low[i];
}else{
v1[i] = Low[i];
v2[i] = Low[i];
}
i--;
}
return(0);
}
//+------------------------------------------------------------------+
void watermark()
{
ObjectCreate("fxfisherman", OBJ_LABEL, 0, 0, 0);
ObjectSetText("fxfisherman", "fxfisherman.com", 11, "Lucida Handwriting", RoyalBlue);
ObjectSet("fxfisherman", OBJPROP_CORNER, 2);
ObjectSet("fxfisherman", OBJPROP_XDISTANCE, 5);
ObjectSet("fxfisherman", OBJPROP_YDISTANCE, 10);
return(0);
}
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---