MTF_BearBulls

Author: Copyright � 2006, Keris2112
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
MTF_BearBulls
///+------------------------------------------------------------------+
//|                                             MTF_MACD_inColor.mq4 |
//|                                      Copyright © 2006, Keris2112 |
//|  1June06 Stache  added traditional view and 2-color Histogram                                                               |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Keris2112"
#property link      "http://www.forex-tsd.com"

#property indicator_separate_window
#property  indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Lime

#property indicator_width1 4
#property indicator_width2 2

//---- input parameters
extern string note_TimeFrames_  = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN|0-currentTF";
extern int    TimeFrame         = 0;
extern int    BearsBullsPeriod  = 13;
//---- buffers
double BearsBuffer[];
double BullsBuffer[];
double TempBuffer[];



//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  { 
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
   IndicatorBuffers(3);
   IndicatorDigits(Digits);
//---- indicator line
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(0,BearsBuffer);
   SetIndexBuffer(1,BullsBuffer);
   
   SetIndexBuffer(2,TempBuffer);

   SetIndexLabel(0,"BearsBuffer");
   SetIndexLabel(1,"BullsBuffer");

   switch(TimeFrame)
   {
      case 1 : string TimeFrameStr="Period_M1"; break;
      case 5 : TimeFrameStr="Period_M5"; break;
      case 15 : TimeFrameStr="Period_M15"; break;
      case 30 : TimeFrameStr="Period_M30"; break;
      case 60 : TimeFrameStr="Period_H1"; break;
      case 240 : TimeFrameStr="Period_H4"; break;
      case 1440 : TimeFrameStr="Period_D1"; break;
      case 10080 : TimeFrameStr="Period_W1"; break;
      case 43200 : TimeFrameStr="Period_MN1"; break;
      default : TimeFrameStr="ChartTimeframe";
   }
   IndicatorShortName("MTF_BearBulls("+BearsBullsPeriod+") ("+TimeFrameStr+")");

  }
//----
   return(0);
 
//+------------------------------------------------------------------+
//| MTF MACD                                            |
//+------------------------------------------------------------------+
int start()
  {

   datetime TimeArray[];
   int    i,limit,y=0,counted_bars=IndicatorCounted(); 

// Plot defined time frame on to current time frame

   ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame); 
   
   limit=Bars-counted_bars+TimeFrame/Period();

   for(i=0,y=0;i<limit;i++)
   {
   if (Time[i]<TimeArray[y]) y++;


/***********************************************************   
   Add your main indicator loop below.  You can reference an existing
      indicator with its iName  or iCustom.
   Rule 1:  Add extern inputs above for all neccesary values   
   Rule 2:  Use 'TimeFrame' for the indicator time frame
   Rule 3:  Use 'y' for your indicator's shift value
 **********************************************************/  
 
   BearsBuffer[i] = iCustom(NULL,TimeFrame,"BearBulls",BearsBullsPeriod,0,y); 
   BullsBuffer[i] = iCustom(NULL,TimeFrame,"BearBulls",BearsBullsPeriod,1,y); 
   TempBuffer[i]  = iCustom(NULL,TimeFrame,"BearBulls",BearsBullsPeriod,2,y); 
   
    }  
     
   if (TimeFrame>Period()) {
     int PerINT=TimeFrame/Period()+1;
     datetime TimeArr[]; ArrayResize(TimeArr,PerINT);
     ArrayCopySeries(TimeArr,MODE_TIME,Symbol(),Period()); 
     for(i=0;i<PerINT+1;i++) {if (TimeArr[i]>=TimeArray[0]) {
 /********************************************************     
    Refresh buffers:         buffer[i] = buffer[0];
 ********************************************************/  

   BearsBuffer[i] = BearsBuffer[0];
   BullsBuffer[i] = BullsBuffer[0];
   TempBuffer[i]  = TempBuffer[0];
 
  } } }

   return(0);
  }

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---