Miscellaneous
0
Views
0
Downloads
0
Favorites
Trend SMC
//+------------------------------------------------------------------+
//| SMC Trend.mq4 |
//| Copyright © 2004|
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004"
#property link "na"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
//---- input parameters
extern int TPeriodMA=55;
extern int TPeriodL= 15;
//---- buffers
double TBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,TBuffer);
//---- name for DataWindow and indicator subwindow label
short_name="SMC Trend("+TPeriodMA+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
//----
SetIndexDrawBegin(0,TPeriodMA);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Trend |
//+------------------------------------------------------------------+
int start()
{
int i,x,cnt;
int counted_bars=IndicatorCounted();
double Total;
//----
if(Bars<=TPeriodMA) return(0);
//---- initial zero
if(counted_bars<1)
for(i=1;i<=TPeriodMA;i++) TBuffer[Bars-i]=0.0;
//----
i=Bars-TPeriodMA-1;
if(counted_bars>=TPeriodMA) i=Bars-counted_bars-1;
while(i>=0)
{
Total=0;
x=0;
while (x < TPeriodMA)
{Total=Total + Close[i+x];
x=x+1;
}
Total= Total / TPeriodMA; //Calculates MA for TPeriod for Current Bar
x=0;
cnt=0;
while(x < TPeriodL)
{if(High[i+x] > Total && Low[i+x] < Total) cnt= cnt+1;
x=x+1;
}
TBuffer[i] = cnt;
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
---