#MTF_dmi~
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
#MTF_dmi~
/*
   www.mtcoding.com
*/

#property indicator_separate_window
#property indicator_minimum 0.0
#property indicator_maximum 1.0
#property indicator_buffers 2
#property indicator_color1 DodgerBlue
#property indicator_color2 Red

extern int TimeFrame = 0;
extern string dmi_smooth_str = "DMI Setting";
extern int dmi_smooth = 3;
double g_ibuf_92[];
double g_ibuf_96[];

int init() {
   string ls_4;
   SetIndexStyle(0, DRAW_HISTOGRAM);
   SetIndexStyle(1, DRAW_HISTOGRAM);
   SetIndexBuffer(0, g_ibuf_92);
   SetIndexBuffer(1, g_ibuf_96);
   switch (TimeFrame) {
   case 1:
      ls_4 = "Period_M1";
      break;
   case 5:
      ls_4 = "Period_M5";
      break;
   case 15:
      ls_4 = "Period_M15";
      break;
   case 30:
      ls_4 = "Period_M30";
      break;
   case 60:
      ls_4 = "Period_H1";
      break;
   case 240:
      ls_4 = "Period_H4";
      break;
   case 1440:
      ls_4 = "Period_D1";
      break;
   case 10080:
      ls_4 = "Period_W1";
      break;
   case 43200:
      ls_4 = "Period_MN1";
      break;
   default:
      ls_4 = "Current Timeframe";
   }
   SetIndexLabel(0, "Up");
   SetIndexLabel(1, "Down");
   IndicatorShortName("DMI bar v.j.1 (" + ls_4 + ") -- by SapiMAS --");
   return (0);
}

int start() {
   int lia_0[];
   double l_icustom_20;
   double l_icustom_28;
   int l_index_12 = 0;
   int l_ind_counted_16 = IndicatorCounted();
   ArrayCopySeries(lia_0, 5, Symbol(), TimeFrame);
   int li_8 = Bars - l_ind_counted_16;
   int l_index_4 = 0;
   l_index_12 = 0;
   while (l_index_4 < li_8) {
      if (Time[l_index_4] < lia_0[l_index_12]) l_index_12++;
      l_icustom_20 = iCustom(Symbol(), TimeFrame, "dmi", dmi_smooth, 0, 0, 1, 1, 1, 0, l_index_12);
      l_icustom_28 = iCustom(Symbol(), TimeFrame, "dmi", dmi_smooth, 0, 0, 1, 1, 1, 1, l_index_12);
      if (l_icustom_20 > l_icustom_28) {
         g_ibuf_92[l_index_4] = 1;
         g_ibuf_96[l_index_4] = 0;
      } else {
         g_ibuf_92[l_index_4] = 0;
         g_ibuf_96[l_index_4] = 1;
      }
      l_index_4++;
   }
   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 ---