Miscellaneous
0
Views
0
Downloads
0
Favorites
20s_Indicator_ts_mtf
//+------------------------------------------------------------------+
//|mtffxtsd The 20's v0.20 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, TraderSeven"
#property link "TraderSeven@gmx.net"
// This EA has 2 main parts.
// Variation=0
// If previous bar opens in the lower 20% of its range and closes in the upper 20% of its range then sell on previous high+10pips.
// If previous bar opens in the upper 20% of its range and closes in the lower 20% of its range then buy on previous low-10pips.
// Variation=1
// The previous bar is an inside bar that has a smaller range than the 3 bars before it.
// If todays bar opens in the lower 20% of yesterdays range then buy.
// If todays bar opens in the upper 20% of yesterdays range then sell.
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//----
extern bool InsideBarMode = False;
//extern int Variation=0;
extern int TimeFrame = 0;
extern string note_TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN|0-CurrentTF";
//----
double The20sBufferBuy[];
double The20sBufferSell[];
string IndicatorFileName;
string Mode;
string short_name;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(2);
SetIndexStyle(0,DRAW_ARROW);
SetIndexStyle(1,DRAW_ARROW);
SetIndexBuffer(0,The20sBufferBuy);
SetIndexBuffer(1,The20sBufferSell);
SetIndexArrow(0,181);
SetIndexArrow(1,181);
SetIndexEmptyValue(0,0.0);
SetIndexEmptyValue(1,0.0);
ArraySetAsSeries(The20sBufferBuy,true);
ArraySetAsSeries(The20sBufferSell,true);
switch(InsideBarMode)
{
case 1 : short_name="InsideBarMode"; break;
default : short_name="MainMode";
}
switch(TimeFrame)
{
case 1 : string TimeFrameStr= "M1"; break;
case 5 : TimeFrameStr= "M5"; break;
case 15 : TimeFrameStr= "M15"; break;
case 30 : TimeFrameStr= "M30"; break;
case 60 : TimeFrameStr= "H1"; break;
case 240 : TimeFrameStr= "H4"; break;
case 1440 : TimeFrameStr= "D1"; break;
case 10080 : TimeFrameStr= "W1"; break;
case 43200 : TimeFrameStr= "MN1"; break;
default : TimeFrameStr= "CurrTF";
}
SetIndexLabel(0,"The20s "+short_name+" Buy ["+TimeFrameStr+"]");
SetIndexLabel(1,"The20s "+short_name+" Sell ["+TimeFrameStr+"]");
IndicatorFileName = WindowExpertName();
IndicatorShortName("The20s("+short_name+")["+TimeFrameStr+"]");
if (TimeFrame<Period()) TimeFrame=Period();
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int limit,i;
if(counted_bars < 0) return(-1);
limit = Bars-counted_bars;
if (TimeFrame != Period())
{
limit = MathMax(limit,TimeFrame/Period());
datetime TimeArray[];
ArrayCopySeries(TimeArray ,MODE_TIME ,NULL,TimeFrame);
for(i=0,int y=0; i<limit; i++)
{
if(Time[i]<TimeArray[y]) y++;
The20sBufferBuy[i] =iCustom(NULL,TimeFrame,IndicatorFileName,InsideBarMode,0,y);
The20sBufferSell[i]=iCustom(NULL,TimeFrame,IndicatorFileName,InsideBarMode,1,y);
}
return(0);
}
int TotalBars, CountedBars;
double LastBarsRange,Top20,Bottom20;
CountedBars=IndicatorCounted(); // Find the number of bars on the screen since
// this indicator/expert was first executed
// on the current chart
if(CountedBars < 0) // If there are less than 0 bars of data, we
return(-1); // have a problem
if(CountedBars > 0)
CountedBars--;
//----
TotalBars=Bars-CountedBars;
for(i=TotalBars-1;i>=0;i--)
{
LastBarsRange=(High[i+1]-Low[i+1]);
Top20=High[i+1]-(LastBarsRange*0.20);
Bottom20=Low[i+1]+(LastBarsRange*0.20);
// if(Variation==0)
if (!InsideBarMode)
//
//
{
if(Open[i+1]>=Top20 && Close[i+1]<=Bottom20 && Low[i]<=Low[i+1]+10*Point)
The20sBufferBuy[i]=Low[i];
else if(Open[i+1]<=Bottom20 && Close[i+1]>=Top20 && High[i]>=High[i+1]+10*Point)
The20sBufferSell[i]=High[i];
}
//// else if(Variation==1)
else if(InsideBarMode)
{
if((High[i+4]-Low[i+4])>LastBarsRange && (High[i+3]-Low[i+3])>LastBarsRange && (High[i+2]-Low[i+2])>LastBarsRange && High[i+2]>High[i+1] && Low[i+2]<Low[i+1])
{
if(Open[i]<=Bottom20)
The20sBufferBuy[i]=Low[i];
if(Open[i]>=Top20)
The20sBufferSell[i]=High[i];
}
}
}
}
//+-------------------------------------------
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
---