Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
Stochastic_fan_color
//+------------------------------------------------------------------+
//| Stochastic_fan |
//| Copyright © 2009 Fox_RM |
//| fox.rm@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2012 Fox_RM"
#property link "fox.rm@mail.ru"
//----
#property indicator_separate_window
#property indicator_buffers 6
//---- fan style
#property indicator_color1 DarkGray
#property indicator_color2 Blue
#property indicator_color3 Black
#property indicator_color4 Red
#property indicator_color5 Green
#property indicator_color6 Blue
#property indicator_style1 0
#property indicator_style2 2
#property indicator_style3 1
#property indicator_style4 0
#property indicator_width1 2
#property indicator_width5 2
#property indicator_width4 2
#property indicator_width6 2
#property indicator_level1 88.2
#property indicator_level2 11.8
#property indicator_levelcolor DarkGray
#property indicator_levelstyle 0
//---- basic fan indicator parameters
extern bool Show_STOCH_1=true;
extern int K_period1=13;
extern int S_period1=1;
extern bool Show_STOCH_2=true;
extern int K_period2=34;
extern int S_period2=1;
extern bool Show_STOCH_3=true;
extern int K_period3=89;
extern int S_period3=1;
extern bool Show_STOCH_4=true;
extern int K_period4=233;
extern int S_period4=1;
//---- indicator buffers
int i=0,j=0;
double rast,S;
double Brs,BrsMA1,BrsMA2;
double MainBuffer1[],MainBuffer2[],MainBuffer3[],MainBuffer44[],
MainBuffer4[],MainBuffer11[],MathArr[],MathArrMA[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- stochastic line 1 (fast)
if(Show_STOCH_1 ==true){Show_STOCH_1=DRAW_LINE; }
else
{Show_STOCH_1=DRAW_NONE; }
SetIndexBuffer(0,MainBuffer1);
SetIndexStyle(0,Show_STOCH_1,0);
SetIndexLabel(0,"fast Stoh ( "+K_period1+" )");
//---- stochastic line 2 (basic)
if(Show_STOCH_2 ==true){Show_STOCH_2=DRAW_LINE; }
else
{Show_STOCH_2=DRAW_NONE; }
SetIndexBuffer(1,MainBuffer2);
SetIndexStyle(1,Show_STOCH_2);
SetIndexLabel(1,"basic Stoh ( "+K_period2+" )");
//---- stochastic line 3 (flat)
if(Show_STOCH_3 ==true){Show_STOCH_3=DRAW_LINE; }
else
{Show_STOCH_3=DRAW_NONE; }
SetIndexBuffer(2,MainBuffer3);
SetIndexStyle(2,Show_STOCH_3,0);
SetIndexLabel(2,"slow Stoh ( "+K_period3+" )");
//---- stochastic line 4 (control)
if(Show_STOCH_4 ==true){Show_STOCH_4=DRAW_LINE; }
else
{Show_STOCH_4=DRAW_NONE; }
SetIndexBuffer(3,MainBuffer4);
SetIndexStyle(3,Show_STOCH_4,0,2);
SetIndexLabel(3,"control Stoh ( "+K_period4+" )");
//---- stochastic line 1 (fast)
SetIndexBuffer(4,MainBuffer11);
SetIndexLabel(4,"fast Stoh ( "+K_period1+" )");
SetIndexBuffer(5,MainBuffer44);
SetIndexLabel(5,"slow Stoh ( "+K_period4+" )");
SetIndexBuffer(6,MathArr);
SetIndexStyle(6,DRAW_NONE);
SetIndexBuffer(7,MathArrMA);
SetIndexStyle(7,DRAW_NONE);
IndicatorBuffers(8);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("Stochastic_fan_color");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
ObjectsDeleteAll(0,OBJ_LABEL);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Stochastic_fan |
//+------------------------------------------------------------------+
int start()
{
int i,shift,limit;//,counted_bars=IndicatorCounted();
//limit=Bars-counted_bars;
int counted_bars = IndicatorCounted();
if(counted_bars < 0) return(-1);
if(counted_bars > 0) counted_bars--;
limit = Bars - counted_bars;
if(counted_bars==0) limit-=1+2;
for(i=0;i<limit;i++)
{
//-------------------
S=0;
rast=1;
if (High[i+2]>High[i+1] && Low[i+2]>Low[i+1])
{
S=High[i+1]-Low[i+2];
rast=High[i+2]-Low[i+1];
} else if (High[i+2]<High[i+1] && Low[i+2]<Low[i+1])
{
S=High[i+2]-Low[i+1];
rast=(High[i+1]-Low[i+2]);
} else if (High[i+2]>=High[i+1] && Low[i+2]<=Low[i+1])
{
S=(High[i+1]-Low[i+1]);
rast=(High[i+2]-Low[i+2]);
} else if (High[i+2]<=High[i+1] && Low[i+2]>=Low[i+1])
{
S=(High[i+2]-Low[i+2]);
rast=(High[i+1]-Low[i+1]);
}
MathArr[i]=0;
if (rast!=0) MathArr[i]=(S/rast*100);
}
for(i=0;i<limit;i++)
{
MathArrMA[i]=iMAOnArray(MathArr,0,5,0,0,i);
BrsMA1=iMAOnArray(MathArrMA,0,13,0,0,i);
BrsMA2=iMAOnArray(MathArrMA,0,34,0,0,i);
Brs=BrsMA1-BrsMA2;
//------------------
MainBuffer1[i]=iStochastic(NULL,0,K_period1,1,S_period1,0,0,MODE_MAIN,i);
if (Brs<0)MainBuffer11[i]=iStochastic(NULL,0,K_period1,1,S_period1,0,0,MODE_MAIN,i);
MainBuffer4[i]=iStochastic(NULL,0,K_period4,1,S_period4,0,0,MODE_MAIN,i);
if (iStochastic(NULL,0,144,1,13,0,0,MODE_MAIN,i)-iStochastic(NULL,0,144,1,3,0,0,MODE_MAIN,i) > 0)
{MainBuffer44[i]=iStochastic(NULL,0,K_period4,1,S_period4,0,0,MODE_MAIN,i);}
MainBuffer3[i]=iStochastic(NULL,0,K_period3,1,S_period3,0,0,MODE_MAIN,i);
MainBuffer2[i]=iStochastic(NULL,0,K_period2,1,S_period2,0,0,MODE_MAIN,i);
}
//----
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
---