Price Data Components
Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
FX-BAR
//+------------------------------------------------------------------+
//| FX-BAR.mq4 |
//| Copyright © 2005, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 6
#property indicator_color1 Black
#property indicator_color2 Gold
#property indicator_color3 Red
#property indicator_color4 Black
#property indicator_color5 Gold
#property indicator_color6 Red
//---- indicator buffers
double ExtBuffer0[];
double ExtBuffer1[];
double ExtBuffer2[];
double ExtBuffer3[];
double ExtBuffer4[];
double ExtBuffer5[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- drawing settings
SetIndexStyle(0,DRAW_NONE);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexStyle(2,DRAW_HISTOGRAM);
SetIndexStyle(3,DRAW_NONE);
SetIndexStyle(4,DRAW_HISTOGRAM);
SetIndexStyle(5,DRAW_HISTOGRAM);
IndicatorDigits(Digits+1);
SetIndexDrawBegin(0,34);
SetIndexDrawBegin(1,34);
SetIndexDrawBegin(2,34);
SetIndexDrawBegin(3,34);
SetIndexDrawBegin(4,34);
SetIndexDrawBegin(5,34);
//---- 3 indicator buffers mapping
SetIndexBuffer(0,ExtBuffer0);
SetIndexBuffer(1,ExtBuffer1);
SetIndexBuffer(2,ExtBuffer2);
SetIndexBuffer(3,ExtBuffer3);
SetIndexBuffer(4,ExtBuffer4);
SetIndexBuffer(5,ExtBuffer5);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("FX-BAR");
SetIndexLabel(1,NULL);
SetIndexLabel(2,NULL);
SetIndexLabel(4,NULL);
SetIndexLabel(5,NULL);
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Awesome Oscillator |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
double prev,current;
int limit2;
int counted_bars2=IndicatorCounted();
double prev2,current2;
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
if(counted_bars2>0) counted_bars2--;
limit2=Bars-counted_bars2;
//---- macd
for(int i=0; i<limit; i++)
ExtBuffer0[i] = iHigh(NULL,0,i)-iMA(NULL,0,8,5,MODE_SMMA,PRICE_MEDIAN,i);
for(int n=0; n<limit2; n++)
ExtBuffer3[n]=iLow(NULL,0,n)-iMA(NULL,0,8,5,MODE_SMMA,PRICE_MEDIAN,n);
//---- dispatch values between 2 buffers
bool up=true;
for(i=limit-1; i>=0; i--)
{
if (ExtBuffer0[i]>=0){
current=ExtBuffer0[i];
prev=ExtBuffer0[i+1];
}
if (ExtBuffer0[i]<0){
ExtBuffer0[i]=0;
current=ExtBuffer0[i];
prev=ExtBuffer0[i+1];
}
if(current>prev) up=true;
if(current<prev) up=false;
if(!up)
{
ExtBuffer2[i]=current;
ExtBuffer1[i]=0.0;
}
else
{
ExtBuffer1[i]=current;
ExtBuffer2[i]=0.0;
}
}
bool up2=true;
for(n=limit2-1; n>=0; n--)
{
if (ExtBuffer3[n]<=0){
current2=ExtBuffer3[n];
prev2=ExtBuffer3[n+1];
}
if (ExtBuffer3[n]>0){
ExtBuffer3[n]=0;
current2=ExtBuffer3[n];
prev2=ExtBuffer3[n+1];
}
if(current2>prev2) up2=true;
if(current2<prev2) up2=false;
if(!up2)
{
ExtBuffer5[n]=current2;
ExtBuffer4[n]=0.0;
}
else
{
ExtBuffer4[n]=current2;
ExtBuffer5[n]=0.0;
}
}
//---- done
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
---