SU
Can anyone code these MQ4 Indicator to C#
19 Apr 2013, 23:20
1) Candle Indicator :-
#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Black
#property indicator_color2 Red
#property indicator_color3 DimGray
#property indicator_color4 DimGray
#property indicator_color5 Black
#property indicator_color6 Red
#property indicator_color7 DimGray
#property indicator_color8 DimGray
double g_period_76 = 50.0;
double g_period_84 = 30.0;
double g_period_92 = 38.0;
double g_ibuf_100[];
double g_ibuf_104[];
double g_ibuf_108[];
double g_ibuf_112[];
double g_ibuf_116[];
double g_ibuf_120[];
double g_ibuf_124[];
double g_ibuf_128[];
int init() {
SetIndexStyle(0, DRAW_HISTOGRAM);
SetIndexBuffer(0, g_ibuf_100);
SetIndexStyle(1, DRAW_HISTOGRAM);
SetIndexBuffer(1, g_ibuf_104);
SetIndexStyle(2, DRAW_HISTOGRAM);
SetIndexBuffer(2, g_ibuf_108);
SetIndexStyle(3, DRAW_HISTOGRAM);
SetIndexBuffer(3, g_ibuf_112);
SetIndexStyle(4, DRAW_HISTOGRAM);
SetIndexBuffer(4, g_ibuf_116);
SetIndexStyle(5, DRAW_HISTOGRAM);
SetIndexBuffer(5, g_ibuf_120);
SetIndexStyle(6, DRAW_HISTOGRAM);
SetIndexBuffer(6, g_ibuf_124);
SetIndexStyle(7, DRAW_HISTOGRAM);
SetIndexBuffer(7, g_ibuf_128);
string ls_0 = "Copyright © 2010, SlumDog";
IndicatorShortName(ls_0);
return (0);
}
int start() {
double l_icci_8;
double l_iwpr_16;
double l_iforce_24;
int li_32;
//if (TimeCurrent() > StrToTime("2050.04.20")) {
// Alert("");
// return;
//}
//if (AccountNumber() != 0 && 0) {
// Alert("");
// return;
//}
int l_ind_counted_4 = IndicatorCounted();
if (Bars <= 15) return (0);
if (l_ind_counted_4 < 1) {
for (int li_0 = 1; li_0 <= 15; li_0++) {
g_ibuf_100[Bars - li_0] = 0.0;
g_ibuf_108[Bars - li_0] = 0.0;
g_ibuf_104[Bars - li_0] = 0.0;
g_ibuf_112[Bars - li_0] = 0.0;
g_ibuf_116[Bars - li_0] = 0.0;
g_ibuf_124[Bars - li_0] = 0.0;
g_ibuf_120[Bars - li_0] = 0.0;
g_ibuf_128[Bars - li_0] = 0.0;
}
}
if (l_ind_counted_4 > 0) li_32 = Bars - l_ind_counted_4;
if (l_ind_counted_4 == 0) li_32 = Bars - 15 - 1;
for (li_0 = li_32; li_0 >= 0; li_0--) {
l_icci_8 = iCCI(NULL, 0, g_period_84, PRICE_TYPICAL, li_0);
l_iwpr_16 = iWPR(NULL, 0, g_period_92, li_0);
l_iforce_24 = iForce(NULL, 0, g_period_76, MODE_EMA, PRICE_CLOSE, li_0);
g_ibuf_100[li_0] = EMPTY_VALUE;
g_ibuf_108[li_0] = EMPTY_VALUE;
g_ibuf_104[li_0] = EMPTY_VALUE;
g_ibuf_112[li_0] = EMPTY_VALUE;
g_ibuf_116[li_0] = EMPTY_VALUE;
g_ibuf_124[li_0] = EMPTY_VALUE;
g_ibuf_120[li_0] = EMPTY_VALUE;
g_ibuf_128[li_0] = EMPTY_VALUE;
if (l_icci_8 > 0.0 && l_iwpr_16 > -50.0 && l_iforce_24 > 0.0) {
g_ibuf_100[li_0] = MathMax(Open[li_0], Close[li_0]);
g_ibuf_104[li_0] = MathMin(Open[li_0], Close[li_0]);
g_ibuf_116[li_0] = High[li_0];
g_ibuf_120[li_0] = Low[li_0];
} else {
if (l_icci_8 > 0.0 && l_iwpr_16 < -50.0) {
g_ibuf_108[li_0] = MathMax(Open[li_0], Close[li_0]);
g_ibuf_112[li_0] = MathMin(Open[li_0], Close[li_0]);
g_ibuf_124[li_0] = High[li_0];
g_ibuf_128[li_0] = Low[li_0];
} else {
if (l_icci_8 < 0.0 && l_iwpr_16 < -50.0 && l_iforce_24 < 0.0) {
g_ibuf_104[li_0] = MathMax(Open[li_0], Close[li_0]);
g_ibuf_100[li_0] = MathMin(Open[li_0], Close[li_0]);
g_ibuf_120[li_0] = High[li_0];
g_ibuf_116[li_0] = Low[li_0];
} else {
if (l_icci_8 < 0.0 && l_iwpr_16 > -50.0) {
g_ibuf_112[li_0] = MathMax(Open[li_0], Close[li_0]);
g_ibuf_108[li_0] = MathMin(Open[li_0], Close[li_0]);
g_ibuf_128[li_0] = High[li_0];
g_ibuf_124[li_0] = Low[li_0];
}
}
}
}
}
return (0);
}
2) HAMA
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 DarkOrange
#property indicator_color2 Turquoise
#property indicator_color3 Red
#property indicator_color4 RoyalBlue
//---- parameters
int MaMetod = 1;
int MaPeriod = 20;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
//----
int ExtCountedBars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//|------------------------------------------------------------------|
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_NONE, 0, 2, Red);
SetIndexBuffer(0, ExtMapBuffer1);
SetIndexStyle(1,DRAW_NONE, 0, 2, RoyalBlue);
SetIndexBuffer(1, ExtMapBuffer2);
SetIndexStyle(2,DRAW_HISTOGRAM, 0, 2, Red);
SetIndexBuffer(2, ExtMapBuffer3);
SetIndexStyle(3,DRAW_HISTOGRAM, 0, 2, RoyalBlue);
SetIndexBuffer(3, ExtMapBuffer4);
//----
SetIndexDrawBegin(0,5);
//---- indicator buffers mapping
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexBuffer(3,ExtMapBuffer4);
//---- initialization done
watermark();
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
double maOpen, maClose, maLow, maHigh;
double haOpen, haHigh, haLow, haClose;
if(Bars<=10) return(0);
ExtCountedBars=IndicatorCounted();
//---- check for possible errors
if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted
if (ExtCountedBars>0) ExtCountedBars--;
int pos=Bars-ExtCountedBars-1;
while(pos>=0)
{
maOpen=iMA(NULL,0,MaPeriod,0,MaMetod,MODE_OPEN,pos);
maClose=iMA(NULL,0,MaPeriod,0,MaMetod,MODE_CLOSE,pos);
maLow=iMA(NULL,0,MaPeriod,0,MaMetod,MODE_LOW,pos);
maHigh=iMA(NULL,0,MaPeriod,0,MaMetod,MODE_HIGH,pos);
haOpen=(ExtMapBuffer3[pos+1]+ExtMapBuffer4[pos+1])/2;
haClose=(maOpen+maHigh+maLow+maClose)/4;
haHigh=MathMax(maHigh, MathMax(haOpen, haClose));
haLow=MathMin(maLow, MathMin(haOpen, haClose));
if (haOpen<haClose)
{
ExtMapBuffer1[pos]=haLow;
ExtMapBuffer2[pos]=haHigh;
}
else
{
ExtMapBuffer1[pos]=haHigh;
ExtMapBuffer2[pos]=haLow;
}
ExtMapBuffer3[pos]=haOpen;
ExtMapBuffer4[pos]=haClose;
pos--;
}
//----
return(0);
}
//+------------------------------------------------------------------+
void watermark()
{
ObjectCreate("", OBJ_LABEL, 0, 0, 0);
ObjectSetText("", "", 8, "Verdana", RoyalBlue);
ObjectSet("", OBJPROP_CORNER, 2);
ObjectSet("", OBJPROP_XDISTANCE, 5);
ObjectSet("", OBJPROP_YDISTANCE, 5);
return(0);
}
3) Slope
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Yellow
#property indicator_color2 Red
#property indicator_color3 Black
extern int MagaPeriod = 80;
extern int Smoothing = 5;
extern int Mode = 2;
extern int Price = 0;
double g_ibuf_92[];
double g_ibuf_96[];
double g_ibuf_100[];
double gda_unused_104[];
double gda_unused_108[];
double gda_unused_112[];
double g_ibuf_116[];
double g_ibuf_120[];
int gi_124;
string gs_dummy_128;
string gs_dummy_136;
int gi_unused_144 = 0;
int init() {
IndicatorBuffers(8);
SetIndexBuffer(0, g_ibuf_100);
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 1);
SetIndexBuffer(1, g_ibuf_96);
SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 1);
SetIndexBuffer(2, g_ibuf_92);
SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, 1);
SetIndexBuffer(3, g_ibuf_116);
SetIndexBuffer(4, g_ibuf_120);
IndicatorShortName("SD_Ma_slow");
return (0);
}
int start() {
gi_124 = Bars - IndicatorCounted();
showMAGA();
return (0);
}
void showMAGA() {
for (int li_0 = gi_124; li_0 >= 0; li_0--) g_ibuf_116[li_0] = 2.0 * iMA(NULL, 0, MagaPeriod / 2, 0, Mode, Price, li_0) - iMA(NULL, 0, MagaPeriod, 0, Mode, Price, li_0);
for (li_0 = gi_124; li_0 >= 0; li_0--) g_ibuf_120[li_0] = iMAOnArray(g_ibuf_116, 0, Smoothing, 0, Mode, li_0);
for (li_0 = gi_124; li_0 >= 0; li_0--) {
g_ibuf_92[li_0] = g_ibuf_120[li_0];
g_ibuf_96[li_0] = g_ibuf_120[li_0];
g_ibuf_100[li_0] = g_ibuf_120[li_0];
if (g_ibuf_120[li_0] > g_ibuf_120[li_0 + 1]) g_ibuf_96[li_0] = EMPTY_VALUE;
else {
if (g_ibuf_120[li_0] < g_ibuf_120[li_0 + 1]) g_ibuf_92[li_0] = EMPTY_VALUE;
else {
g_ibuf_92[li_0] = EMPTY_VALUE;
g_ibuf_96[li_0] = EMPTY_VALUE;
}
}
}
}
Replies
emeeder
22 Jul 2014, 21:08
I also would really appreciate these indicators. especially the HAMA.
I tried the Heiken Ashi Smoothed indicator, but it is a memory hog and has lots of extra coding in it.
Can someone make these for Ctrader?
Thanks

susantasaren
23 Apr 2013, 09:06
Help
Can anyone help me please.
@susantasaren