Miscellaneous
0
Views
0
Downloads
0
Favorites
iTest
// iTest.mq4
#property copyright "Copyright © 2005, AAE."
#property link "rz1zr@mail.ru"
#property indicator_chart_window
#property indicator_buffers 3
//#property indicator_color1 Magenta
//#property indicator_color2 Lime
//#property indicator_color3 Green
//---- input parameters
//extern double k1 = 0;
//extern int p1 = 3;
extern int CountBars=300;
//---- buffers
double val1[];
double val2[];
double val3[];
// Custom indicator initialization function
int init()
{
string short_name;
//---- indicator line
IndicatorBuffers(3);
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,159);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,159);
SetIndexStyle(2,DRAW_ARROW);
SetIndexArrow(2,159);
SetIndexBuffer(0,val1);
SetIndexBuffer(1,val2);
SetIndexBuffer(2,val3);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
IndicatorShortName("iTest");
//----
return(0);
}
// iTest
int start()
{
SetIndexDrawBegin(0,Bars-CountBars);
SetIndexDrawBegin(1,Bars-CountBars);
SetIndexDrawBegin(2,Bars-CountBars);
int i,per,MyBars,counted_bars=IndicatorCounted();
double i1,i2,i3,i4,i5,i6,i7,i8,i9.i10,i11,i12,i13;
bool Sell=false, Buy=false;
string txt="";
string txt2="";
string txt3="";
string txt4="";
//----
i=CountBars;
while(i>=0)
{
val1[i]=0;
val2[i]=0;
val3[i]=0;
i1 = ((Open[i+1]+High[i+1]+Low[i+1]+Close[i+1])/4);
i2 = ((Open[i+2]+High[i+2]+Low[i+2]+Close[i+2])/4);
i3 = ((Open[i+3]+High[i+3]+Low[i+3]+Close[i+3])/4);
if (((i1-i2)<0) && (! Sell || MyBars==CountBars) )
{//åñëè 1-é áàð ñ ñèãíàëîì SELL - çàáèâàåì ñòðåëêó âíèç
val1[i]=High[i]+3*Point;
Sell=true; Buy=false; MyBars=Bars-i;
txt="SELL";
txt2=((Open[i+1]-Close[i+1])*10000);
}
if (((i1-i2)>0) && (! Buy || MyBars==CountBars) )
{//åñëè 1-é áàð ñ ñèãíàëîì BUY - çàáèâàåì ñòðåëêó ââåðõ
val2[i]=Low[i]-3*Point;
Buy=true; Sell=false; MyBars=Bars-1;
txt="BUY";
txt2=((Close[i+1]-Open[i+1])*10000);
}
if (((i2-i3)<0) && (! Sell || MyBars==CountBars) )
{//åñëè 1-é áàð ñ ñèãíàëîì SELL - çàáèâàåì ñòðåëêó âíèç
val2[i]=High[i]+3*Point;
Sell=true; Buy=false; MyBars=Bars-i;
txt3="SELL";
txt4=((Open[i+2]-Close[i+2])*10000);
}
if (((i2-i3)>0) && (! Buy || MyBars==CountBars) )
{//åñëè 1-é áàð ñ ñèãíàëîì BUY - çàáèâàåì ñòðåëêó ââåðõ
val3[i]=Low[i]-4*Point;
Buy=true; Sell=false; MyBars=Bars-2;
txt3="BUY";
txt4=(((Close[i+2]-Open[i+2]))*10000);
}
if (val1[i]==0 && val2[i]==0 && MyBars==CountBars)
{//åñëè ñèãíàë ïðîïàë
Sell=!Sell;
Buy=!Buy;
MyBars=MyBars-1;
if (val2[i]==0 && val3[i]==0 && MyBars==CountBars)
{//åñëè ñèãíàë ïðîïàë
Sell=!Sell;
Buy=!Buy;
MyBars=MyBars-2;
}
}
Comment("\n","1 candle back.",
"\n","Open: ",Open[i+1],
"\n","High: ",High[i+1],
"\n","Low: ",Low[i+1],
"\n","Close: ",Close[i+1],
"\n","Average [-1]: ",i1,
"\n",i1," - ",i2," = ",txt,
"\n","Profit = ",txt2,"\n","\n",
"2 candles back.",
"\n","Open: ",Open[i+2],
"\n","High: ",High[i+2],
"\n","Low: ",Low[i+2],
"\n","Close: ",Close[i+2],
"\n",i2," - ",i3," = ",txt3,
"\n","Average [-2]: ",i2,"\n",
"\n","Profit = ",txt4,"\n","\n",
);
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
---