Price Data Components
Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
Zerolagstochs_v3
//+------------------------------------------------------------------+
//| PriceVSwma.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "perky_z@yahoo.com"
#property indicator_separate_window
#property indicator_buffers 8
#property indicator_color1 Yellow
#property indicator_color2 Lime
#property indicator_color3 Red
extern bool UseSendMail = false;
bool SendFlag = false;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
//---- input parameters
double stok1=0,stok2=0,stok3=0,stok4=0,stok5=0,mov=0,stoksmoothed=0,smoothing=15;
double stok11=0,stok12=0,stok13=0,stok14=0,stok15=0,mov1=0,stoksmoothed1=0,smoothing1=15;
int shift=0, MAType=1, cnt=0, prevbars=0,loopbegin=0;
bool first=true;
//---- buffers
double LoBuffer[];
double HiBuffer[];
double PlusSdiBuffer[];
double MinusSdiBuffer[];
double TempBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- 3 additional buffers are used for counting.
IndicatorBuffers(8);
//---- indicator buffers
//---- drawing settings
SetIndexBuffer(2,ExtMapBuffer1);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexBuffer(0,ExtMapBuffer3);
SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,2);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
SetIndexBuffer(3,LoBuffer);
SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,2,Magenta);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("ZeroLagStocs");
return(0);
}
//+------------------------------------------------------------------+
//| Average Directional Movement Index |
//+------------------------------------------------------------------+
int start()
{
// initial checkings
// check for additional bars loading or total reloading
if (Bars < prevbars ) first = true;
if (Bars-prevbars>1) first = true;
prevbars = Bars;
if (first)
{
// loopbegin prevent couning of counted bars exclude current
loopbegin = Bars-1;
if (loopbegin < 0) return(0); // not enough bars for counting
first = False;
}
loopbegin = loopbegin+1;
// Comment( loopbegin); // current bar is to be recounted too
for (shift = loopbegin; shift>= 0 ;shift--)
{
stok1 = (iStochastic(NULL,0,8,3,3,MODE_SMA,NULL,MODE_MAIN,shift))*0.05;
stok2 = (iStochastic(NULL,0,89,21,3,MODE_SMA,NULL,MODE_MAIN,shift))*0.43;
stok3 = (iStochastic(NULL,0,55,13,3,MODE_SMA,NULL,MODE_MAIN,shift))*0.26;
stok4 = (iStochastic(NULL,0,34,8,3,MODE_SMA,NULL,MODE_MAIN,shift))*0.16;
stok5 = (iStochastic(NULL,0,21,5,3,MODE_SMA,NULL,MODE_MAIN,shift))*0.10;
mov = stok1+stok2+stok3+stok4+stok5;
stok11 = (iStochastic(NULL,0,8,3,3,MODE_SMA,NULL,MODE_MAIN,shift+1))*0.05;
stok12 = (iStochastic(NULL,0,89,21,3,MODE_SMA,NULL,MODE_MAIN,shift+1))*0.43;
stok13 = (iStochastic(NULL,0,55,13,3,MODE_SMA,NULL,MODE_MAIN,shift+1))*0.26;
stok14 = (iStochastic(NULL,0,34,8,3,MODE_SMA,NULL,MODE_MAIN,shift+1))*0.16;
stok15 = (iStochastic(NULL,0,21,5,3,MODE_SMA,NULL,MODE_MAIN,shift+1))*0.10;
mov1 = stok11+stok12+stok13+stok14+stok15;
stoksmoothed = mov/smoothing + LoBuffer[shift+1]*(smoothing-1)/smoothing;
LoBuffer[shift]= stoksmoothed;
loopbegin = loopbegin-1;
//========== COLOR CODING ===========================================
ExtMapBuffer3[shift] = mov; //yellow
ExtMapBuffer2[shift] = mov; //green
ExtMapBuffer1[shift] = mov; //red
if (mov1 > mov)
{
ExtMapBuffer2[shift] = EMPTY_VALUE;
if (UseSendMail == true && SendFlag == true) SendMail(Symbol() + " " + Period() + " " + TimeToStr(CurTime(),TIME_DATE|TIME_SECONDS) + " SMA8 change to YELLOW ","");
SendFlag = false;
}
else if (mov1 < mov)
{
ExtMapBuffer1[shift] = EMPTY_VALUE; //-1 red/greem tight
}
else
{
ExtMapBuffer1[shift]=EMPTY_VALUE;//EMPTY_VALUE;
ExtMapBuffer2[shift]=EMPTY_VALUE;//EMPTY_VALUE;
SendFlag = true;
}
}}
return(0);
// prevent to previous bars recounting
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
---