Miscellaneous
0
Views
0
Downloads
0
Favorites
MTF_OsMA2_v3
//+------------------------------------------------------------------+
//| #MTF OsMA_v3 |
//| Copyright © 2006, Eli hayun |
//| OsMA Conversion By image3022 |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Eli hayun"
#property link "http://"
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 20
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 Red
#property indicator_color4 Blue
//---- buffers
double buf4_up[];
double buf4_down[];
double buf3_up[];
double buf3_down[];
extern double Gap = 3; // Gap between the lines of bars
extern int Period_1 = PERIOD_M30;
extern int Period_2 = PERIOD_H1;
extern bool AutoDisplay = false;
string shortname = "";
bool firstTime = true;
int UniqueNum = 228;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
shortname = "# MTF OsMA2("+Period_1+","+Period_2+")";
firstTime = true;
IndicatorShortName(shortname);
//---- indicators
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,110);
SetIndexBuffer(0,buf4_up);
SetIndexEmptyValue(0,0.0);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,110);
SetIndexBuffer(1,buf4_down);
SetIndexEmptyValue(1,0.0);
SetIndexStyle(2,DRAW_ARROW);
SetIndexArrow(2,110);
SetIndexBuffer(2,buf3_up);
SetIndexEmptyValue(2,0.0);
SetIndexStyle(3,DRAW_ARROW);
SetIndexArrow(3,110);
SetIndexBuffer(3,buf3_down);
SetIndexEmptyValue(3,0.0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
shortname = "# MTF OsMA2("+Period_1+","+Period_2+")";
firstTime = true;
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int i=0, y5m=0, y15m=0, yy;
int limit=Bars-counted_bars;
datetime TimeArray_5M[], TimeArray_15M[];
//----
ArrayCopySeries(TimeArray_15M,MODE_TIME,Symbol(),Period_2);
ArrayCopySeries(TimeArray_5M,MODE_TIME,Symbol(),Period_1);
for(i=0, y5m=0, y15m=0;i<limit;i++)
{
if (Time[i]<TimeArray_5M[y5m]) y5m++;
if (Time[i]<TimeArray_15M[y15m]) y15m++;
for (int tf = 0; tf < 2; tf++)
{
int prd;
switch (tf)
{
case 0: prd = Period_1; yy = y5m; break;
case 1: prd = Period_2; yy = y15m; break;
}
// iCustom(NULL,0,"Xo",10.0,0,SignalCandle);
double cci = iCustom(NULL, prd, "OsMA2",12,0,yy);
double dUp = EMPTY_VALUE; // iCustom(NULL, prd, "SuperTrend", false, 1, yy);
double dDn = EMPTY_VALUE; //iCustom(NULL, prd, "SuperTrend", false, 0, yy);
// if (cci > 0) dUp = 1; else dDn = 1;
if (cci > 0) dDn = 1; else dUp = 1;
switch (tf)
{
case 0: if (dUp == EMPTY_VALUE) buf3_down[i] = 1 + Gap * 2;
else buf3_up[i] = 1 + Gap * 2; break;
case 1: if (dUp == EMPTY_VALUE) buf4_down[i] = 1 + Gap * 3;
else buf4_up[i] = 1 + Gap * 3; break;
}
}
}
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
---