SuperTrend Candles_source

Author: SuperTrend Candles by cja
SuperTrend Candles_source
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
SuperTrend Candles_source
#property copyright "SuperTrend Candles by cja"
#property link      ""

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_color3 Lime
#property indicator_color4 Red

extern int Nbr_Periods = 10;
extern double Multiplier = 3.0;
extern int BARS = 300;
extern string IIIIIIIIIIIIIIIIIIIIIIIII = ">>> Candle/Wick Display Settings >>>>>>>>>>>>>>>>>";
extern int BarWidth = 1;
extern int CandleWidth = 3;
double g_ibuf_108[];
double g_ibuf_112[];
double g_ibuf_116[];
double g_ibuf_120[];
double gda_124[];
double gda_128[];
double gda_132[];
double gda_136[];

int init() {
   IndicatorShortName("SuperTrend Candles");
   IndicatorBuffers(4);
   SetIndexBuffer(0, g_ibuf_108);
   SetIndexBuffer(1, g_ibuf_112);
   SetIndexBuffer(2, g_ibuf_116);
   SetIndexBuffer(3, g_ibuf_120);
   SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, BarWidth);
   SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, BarWidth);
   SetIndexStyle(2, DRAW_HISTOGRAM, STYLE_SOLID, CandleWidth);
   SetIndexStyle(3, DRAW_HISTOGRAM, STYLE_SOLID, CandleWidth);
   return (0);
}

int deinit() {
   return (0);
}

double Super_UP(int ai_0 = 0) {
   return (iCustom(NULL, 0, "SuperTrend", Nbr_Periods, Multiplier, 0, 0, ai_0));
}

double Super_DN(int ai_0 = 0) {
   return (iCustom(NULL, 0, "SuperTrend", Nbr_Periods, Multiplier, 0, 1, ai_0));
}

void SetCandleColor(int ai_0, int ai_4) {
   double ld_24 = MathMax(Open[ai_4], Close[ai_4]);
   double ld_32 = MathMin(Open[ai_4], Close[ai_4]);
   double l_high_8 = High[ai_4];
   double l_low_16 = Low[ai_4];
   g_ibuf_108[ai_4] = l_low_16;
   g_ibuf_116[ai_4] = ld_32;
   g_ibuf_112[ai_4] = l_low_16;
   g_ibuf_120[ai_4] = ld_32;
   g_ibuf_108[ai_4] = l_low_16;
   gda_124[ai_4] = ld_32;
   g_ibuf_112[ai_4] = l_low_16;
   gda_128[ai_4] = ld_32;
   g_ibuf_108[ai_4] = l_low_16;
   gda_132[ai_4] = ld_32;
   g_ibuf_112[ai_4] = l_low_16;
   gda_136[ai_4] = ld_32;
   switch (ai_0) {
   case 1:
      g_ibuf_108[ai_4] = l_high_8;
      g_ibuf_116[ai_4] = ld_24;
      return;
   case 2:
      g_ibuf_112[ai_4] = l_high_8;
      g_ibuf_120[ai_4] = ld_24;
      return;
   case 3:
      g_ibuf_108[ai_4] = l_high_8;
      gda_124[ai_4] = ld_24;
      return;
   case 4:
      g_ibuf_112[ai_4] = l_high_8;
      gda_128[ai_4] = ld_24;
      return;
   case 5:
      g_ibuf_108[ai_4] = l_high_8;
      gda_132[ai_4] = ld_24;
      return;
   case 6:
      g_ibuf_112[ai_4] = l_high_8;
      gda_136[ai_4] = ld_24;
      return;
      return;
   }
}

int start() {
   double ld_4;
   double ld_12;
   for (int li_0 = MathMax(BARS - 1 - IndicatorCounted(), 1); li_0 >= 0; li_0--) {
      ld_4 = Super_UP(li_0);
      ld_12 = Super_DN(li_0);
      if (ld_4 > ld_12) SetCandleColor(2, li_0);
      else
         if (ld_4 <= ld_12) SetCandleColor(1, li_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 ---