FX Sniper's MA Cross

FX Sniper's MA Cross
0 Views
0 Downloads
0 Favorites
FX Sniper's MA Cross
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//Coded By FX Sniper


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


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+


extern int MA1 = 5;
extern int MA1_Type = 1;
extern int MA2 = 20;
extern int MA2_Type = 1;

double buf1[];
double buf2[];
double buf3[];
double buf4[];


int init()
  {
//---- indicators
// ObjectDelete("EU");
// ObjectDelete("USSession");
//----
   IndicatorBuffers(8);
   SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY,5,Blue);
   SetIndexBuffer(0,buf1);
  
   SetIndexStyle(1,DRAW_HISTOGRAM,EMPTY,5,Red);
   SetIndexBuffer(1,buf2);
  
  SetIndexBuffer(2,buf3);
  SetIndexBuffer(3,buf4);
  
   IndicatorShortName(" ");
//----
   
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
  
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
      for (int x=Bars;x>=0;x--) 
   {  
   
   switch(MA1_Type)
    {
      case 1:
       buf3[x]=iMA(NULL,0,MA1,0,MODE_SMA,PRICE_CLOSE,x);
       break;
      case 2:
       buf3[x]=iMA(NULL,0,MA1,0,MODE_EMA,PRICE_CLOSE,x);
       break;
      case 3:
       buf3[x]=iMA(NULL,0,MA1,0,MODE_LWMA,PRICE_CLOSE,x);
       break;
        
   }
   
   switch(MA2_Type)
    {
      case 1:
       buf4[x]=iMA(NULL,0,MA2,0,MODE_SMA,PRICE_CLOSE,x);
       break;
      case 2:
       buf4[x]=iMA(NULL,0,MA2,0,MODE_EMA,PRICE_CLOSE,x);
       break;
      case 3:
       buf4[x]=iMA(NULL,0,MA2,0,MODE_LWMA,PRICE_CLOSE,x);
       break; 
   }
   
   
      if (buf3[x]>buf4[x])
         {         
            buf1[x]=24;
            buf2[x]=0;
         }
         else
         {  buf2[x]=24;
            buf1[x]=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 ---