impulsmodify

Author: Copyright � Roman Shiredchenko, 2009
impulsmodify
Indicators Used
Moving average indicatorMACD Histogram
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
impulsmodify
//--------------------------------------------------------------------
// ravi.mq4 
//--------------------------------------------------------------- 1 --
#property copyright "Copyright © Roman Shiredchenko, 2009"
//--------------------------------------------------------------------
#property indicator_separate_window 

#property  indicator_buffers 3
#property  indicator_color1  Blue
#property  indicator_color2  Green
#property  indicator_color3  Red

//---- indicator parameters 
  
extern int Period_Ema=13;

extern int Period_Macd1=12;
extern int Period_Macd2=26;
extern int Period_Macd3=9;
 
 
 
 
double     ExtBuffer0[];
double     ExtBuffer1[];
double     ExtBuffer2[];
//+------------------------------------------------------------------+ 
//| Custom indicator initialization function                         | 
//+------------------------------------------------------------------+ 
int init() 
  {    

   SetIndexBuffer(0,ExtBuffer0);
   SetIndexBuffer(1,ExtBuffer1);
   SetIndexBuffer(2,ExtBuffer2);
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   IndicatorShortName("impulsmodify");
//---- initialization done
   return(0);
  } 
//+------------------------------------------------------------------+ 
//| Custor indicator deinitialization function                       | 
//+------------------------------------------------------------------+ 
int deinit() 
  { 
//---- TODO: add your code here 
    
//---- 
   return(0); 
  } 
//----------------------------------------------------------------

int start()                         // Ñïåöèàëüíàÿ ôóíêöèÿ start()
  {
//-----------------------------------------------------------------
  
   double
   EMA1,  EMA2, SumEMA;                  // 2 ÌÀ äëÿ ðàñ÷åòà çíà÷åíèé èíäèêàòîðà EMA
   double
   M_0, M_1, SumMacd ;                           // Çíà÷åíèå MAIN MACD íà 0 è 1 áàðàõ
   
//--------------------------------------------------------------- 4 --
                      
                             
   int   i1 = 0;                  // ïåðåìåííûå äëÿ  îòêðûòèÿ çàêðûòèÿ ïîçèöèè 
                
   //---ñðåäíÿÿ ÅÌÀ è ìàéí ÌÀÊÄè ðàñòóò
 
      ExtBuffer1[1] = 0;
      ExtBuffer0[1] = 0;
      ExtBuffer2[1] = 0;
      EMA1=iMA(NULL, PERIOD_D1,Period_Ema,0,MODE_EMA,PRICE_CLOSE,i1); // Çíà÷åíèå  EÌÀ1 current
      EMA2=iMA(NULL, PERIOD_D1,Period_Ema,0,MODE_EMA,PRICE_CLOSE,i1+1); // Çíà÷åíèå  EÌÀ2  prev 
      SumEMA = 0;
      SumEMA = EMA1 - EMA2;
           
      M_0=iMACD(NULL, PERIOD_D1,Period_Macd1,Period_Macd2,Period_Macd3,PRICE_CLOSE,MODE_MAIN,i1); // 
      M_1=iMACD(NULL, PERIOD_D1,Period_Macd1,Period_Macd2,Period_Macd3,PRICE_CLOSE,MODE_MAIN,i1+1); // 
      SumMacd=0;
      SumMacd=M_0-M_1;
      
      if (SumEMA>0 && SumMacd>0) ExtBuffer1[1] = 4;   // mas green  
       if  (ExtBuffer1[1] == 0)
       {
       if (SumEMA<0 && SumMacd<0)      // åñëè åìà è ìàêäè óìåíüøàþòñÿ, òî ðèñóé êðàñíóþ ëèí  
       { ExtBuffer2[1] = 2;
       } else
        ExtBuffer0[1] = 3;            // èíà÷å ðèñóé blue ëèíèþ ãèñòîãðàììû 
        }
      
     //-------------------------------------------
      
     
        
      
    
   return;                          // Âûõîä èç ñïåö. ô-èè start()
  }
//-------------------------------------------------------------- 15 --

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 ---