Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
BearBulls
//+------------------------------------------------------------------+
//| BearBulls.mq4 |
//| Copyright © 2005, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#property indicator_separate_window
#property indicator_level1 0.0002
#property indicator_level2 -0.0002
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Lime
#property indicator_width1 4
#property indicator_width2 2
//---- input parameters
extern int BearsBullsPeriod=13;
//---- buffers
double BearsBuffer[];
double BullsBuffer[];
double TempBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- 1 additional buffer used for counting.
IndicatorBuffers(3);
IndicatorDigits(Digits);
//---- indicator line
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexBuffer(0,BearsBuffer);
SetIndexBuffer(1,BullsBuffer);
SetIndexBuffer(2,TempBuffer);
//---- name for DataWindow and indicator subwindow label
short_name="BearBulls("+BearsBullsPeriod+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
SetIndexLabel(1,"BearBulls2("+BearsBullsPeriod+")");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Bears Power |
//+------------------------------------------------------------------+
int start()
{
int i,counted_bars=IndicatorCounted();
//----
if(Bars<=BearsBullsPeriod) return(0);
//----
int limit=Bars-counted_bars;
if(counted_bars>0) limit++;
for(i=0; i<limit; i++)
TempBuffer[i]=iMA(NULL,0,BearsBullsPeriod,0,MODE_EMA,PRICE_CLOSE,i);
//----
i=Bars-counted_bars-1;
while(i>=0)
{
BearsBuffer[i]=Low[i]-TempBuffer[i];
BullsBuffer[i]=High[i]-TempBuffer[i];
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
---