Insid_Outside_Bar

Author: Copyright 2018, MetaQuotes Software Corp.
0 Views
0 Downloads
0 Favorites
Insid_Outside_Bar
ÿþ//+------------------------------------------------------------------+

//|                                            Insid_Outside_Bar.mq5 |

//|                        Copyright 2018, MetaQuotes Software Corp. |

//|                              https://www.mql5.com/ru/users/s22aa |

//+------------------------------------------------------------------+

#property copyright "Copyright 2018, MetaQuotes Software Corp."

#property link      "https://www.mql5.com"

#property version   "1.00"

#property indicator_chart_window



#property indicator_buffers 2  

#property indicator_plots 2   



#property indicator_type1 DRAW_ARROW  

#property indicator_type2 DRAW_ARROW  



#property indicator_color1 clrRed  

#property indicator_color2 clrBlue   



#property indicator_width1  2     

#property indicator_width2  2

   

//--- input parameters

input int      ArrowShift     = 0;  //   BABC? B>G5: >B A25G8, ?> 2KA>B5.



enum Indicator

{

Insid=0, // Insid_Bar

Outside=1, // Outside_Bar

};

input Indicator Insid_Outside_Bar=Insid;



double BuffUp[];    

double BuffDn[]; 



//+------------------------------------------------------------------+

//| Custom indicator initialization function                         |

//+------------------------------------------------------------------+

int OnInit()

{

      SetIndexBuffer(0,BuffUp, INDICATOR_DATA); 

      SetIndexBuffer(1,BuffDn, INDICATOR_DATA);

    

      IndicatorSetString (INDICATOR_SHORTNAME,"Insid_Bar2"); 

      IndicatorSetInteger(INDICATOR_DIGITS, _Digits);
	  

      PlotIndexSetInteger(0, PLOT_ARROW, 159);        

      PlotIndexSetInteger(1, PLOT_ARROW, 159);

      

      PlotIndexSetInteger(0, PLOT_ARROW_SHIFT, ArrowShift); 

      PlotIndexSetInteger(1, PLOT_ARROW_SHIFT, -ArrowShift);

   

      PlotIndexSetDouble(0, PLOT_EMPTY_VALUE, EMPTY_VALUE);

      PlotIndexSetDouble(1, PLOT_EMPTY_VALUE, EMPTY_VALUE);  

    

    return(INIT_SUCCEEDED);

}

//+------------------------------------------------------------------+

//| Custom indicator iteration function                              |

//+------------------------------------------------------------------+

int OnCalculate(const int rates_total,

                const int prev_calculated,

                const datetime &time[],

                const double &open[],

                const double &high[],

                const double &low[],

                const double &close[],

                const long &tick_volume[],

                const long &volume[],

                const int &spread[])

{



   int i, limit;

   

   if (rates_total < 2)

      return(0);

     

   if (prev_calculated < 3)

   {

      limit = 2;

      

      ArrayInitialize(BuffDn, EMPTY_VALUE); 

      ArrayInitialize(BuffUp, EMPTY_VALUE);

      

   } else limit = rates_total - 2;

   

   for(i = limit; i<rates_total-1; i++)

   {

      if (Insid_Outside_Bar == Insid)



         if (high[i] <= high[i-1] && low[i] >= low[i-1])

      {

         BuffUp[i-1] = low[i-1]; BuffDn[i-1] = high[i-1];

      }

      else

      {

         BuffUp[i] = EMPTY_VALUE;

         BuffDn[i] = EMPTY_VALUE;

      }

      

   }

   for(i = limit; i<rates_total-1; i++)

   {

      if (Insid_Outside_Bar == Outside)



         if (high[i] >= high[i-1] && low[i] <= low[i-1])

      {

         BuffUp[i] = low[i]; BuffDn[i] = high[i];

      }

      else

      {

         BuffUp[i] = EMPTY_VALUE;

         BuffDn[i] = EMPTY_VALUE;

      }

      

   }   



   return(rates_total);

}

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