Jump to content

Converting mql4 to mql5


shickman

Recommended Posts

Hello coders

I have 2 indicators that I really rely on and need them so much

not a very complicated one at all but very important to me

I ask you to PLEASE PLEASE help me and convert them to mql5

I can't thank you enough for this

thank you

 

here is the first one:

 

 

 

 

/*

Generated by EX4-TO-MQ4 decompiler V4.0.225.1g []

Website: http://purebeam.biz

E-mail : [email protected]

*/

#property copyright "Copyright © 2008, 2hrfx.com"

#property link "http://www.2hrfx.com"

 

#property indicator_chart_window

#property indicator_buffers 3

#property indicator_color1 Red

#property indicator_color2 White

#property indicator_color3 Magenta

#property indicator_width2 4

#property indicator_width3 4

 

extern int Price = 0;

extern int Length = 20;

extern int Displace = 0;

extern int Filter = 0;

extern int Color = 1;

extern int ColorBarBack = 1;

extern double Deviation = 0.0;

double g_ibuf_108[];

double g_ibuf_112[];

double g_ibuf_116[];

double g_ibuf_120[];

double gda_124[];

int g_index_128;

int gi_132;

int gi_136;

int gi_140 = 4;

double gd_144;

double gd_152;

double gd_160;

double gd_168;

double gd_176;

double gd_184;

double gd_192 = 3.1415926535;

 

int init() {

IndicatorBuffers(4);

SetIndexStyle(0, DRAW_LINE);

SetIndexBuffer(0, g_ibuf_108);

SetIndexStyle(1, DRAW_LINE);

SetIndexBuffer(1, g_ibuf_112);

SetIndexStyle(2, DRAW_LINE);

SetIndexBuffer(2, g_ibuf_116);

SetIndexBuffer(3, g_ibuf_120);

IndicatorDigits(MarketInfo(Symbol(), MODE_DIGITS));

string ls_0 = "SaneFX(" + Length + ")";

IndicatorShortName(ls_0);

SetIndexLabel(0, "SaneFX");

SetIndexLabel(1, "Up");

SetIndexLabel(2, "Dn");

SetIndexShift(0, Displace);

SetIndexShift(1, Displace);

SetIndexShift(2, Displace);

SetIndexEmptyValue(0, EMPTY_VALUE);

SetIndexEmptyValue(1, EMPTY_VALUE);

SetIndexEmptyValue(2, EMPTY_VALUE);

SetIndexDrawBegin(0, Length * gi_140 + Length);

SetIndexDrawBegin(1, Length * gi_140 + Length);

SetIndexDrawBegin(2, Length * gi_140 + Length);

gd_144 = 3.0 * gd_192;

gi_132 = Length - 1;

gi_136 = Length * gi_140 + gi_132;

ArrayResize(gda_124, gi_136);

gd_176 = 0;

for (g_index_128 = 0; g_index_128 < gi_136 - 1; g_index_128++) {

if (g_index_128 <= gi_132 - 1) gd_160 = 1.0 * g_index_128 / (gi_132 - 1);

else gd_160 = (g_index_128 - gi_132 + 1) * (2.0 * gi_140 - 1.0) / (gi_140 * Length - 1.0) + 1.0;

gd_152 = MathCos(gd_192 * gd_160);

gd_184 = 1.0 / (gd_144 * gd_160 + 1.0);

if (gd_160 <= 0.5) gd_184 = 1;

gda_124[g_index_128] = gd_184 * gd_152;

gd_176 += gda_124[g_index_128];

}

return (0);

}

 

int start() {

int li_12;

double ld_16;

int l_ind_counted_8 = IndicatorCounted();

if (l_ind_counted_8 > 0) li_12 = Bars - l_ind_counted_8;

if (l_ind_counted_8 < 0) return (0);

if (l_ind_counted_8 == 0) li_12 = Bars - gi_136 - 1;

if (l_ind_counted_8 < 1) {

for (int l_index_0 = 1; l_index_0 < Length * gi_140 + Length; l_index_0++) {

g_ibuf_108[bars - l_index_0] = 0;

g_ibuf_112[bars - l_index_0] = 0;

g_ibuf_116[bars - l_index_0] = 0;

}

}

for (int li_4 = li_12; li_4 >= 0; li_4--) {

gd_168 = 0;

for (l_index_0 = 0; l_index_0 <= gi_136 - 1; l_index_0++) {

if (Price == 0) ld_16 = Close[li_4 + l_index_0];

else {

if (Price == 1) ld_16 = Open[li_4 + l_index_0];

else {

if (Price == 2) ld_16 = High[li_4 + l_index_0];

else {

if (Price == 3) ld_16 = Low[li_4 + l_index_0];

else {

if (Price == 4) ld_16 = (High[li_4 + l_index_0] + (Low[li_4 + l_index_0])) / 2.0;

else {

if (Price == 5) ld_16 = (High[li_4 + l_index_0] + (Low[li_4 + l_index_0]) + (Close[li_4 + l_index_0])) / 3.0;

else

if (Price == 6) ld_16 = (High[li_4 + l_index_0] + (Low[li_4 + l_index_0]) + 2.0 * (Close[li_4 + l_index_0])) / 4.0;

}

}

}

}

}

gd_168 += gda_124[l_index_0] * ld_16;

}

if (gd_176 > 0.0) g_ibuf_108[li_4] = (Deviation / 100.0 + 1.0) * gd_168 / gd_176;

if (Filter > 0)

if (MathAbs(g_ibuf_108[li_4] - (g_ibuf_108[li_4 + 1])) < Filter * Point) g_ibuf_108[li_4] = g_ibuf_108[li_4 + 1];

if (Color > 0) {

g_ibuf_120[li_4] = g_ibuf_120[li_4 + 1];

if (g_ibuf_108[li_4] - (g_ibuf_108[li_4 + 1]) > Filter * Point) g_ibuf_120[li_4] = 1;

if (g_ibuf_108[li_4 + 1] - g_ibuf_108[li_4] > Filter * Point) g_ibuf_120[li_4] = -1;

if (g_ibuf_120[li_4] > 0.0) {

g_ibuf_112[li_4] = g_ibuf_108[li_4];

if (g_ibuf_120[li_4 + ColorBarBack] < 0.0) g_ibuf_112[li_4 + ColorBarBack] = g_ibuf_108[li_4 + ColorBarBack];

g_ibuf_116[li_4] = EMPTY_VALUE;

}

if (g_ibuf_120[li_4] < 0.0) {

g_ibuf_116[li_4] = g_ibuf_108[li_4];

if (g_ibuf_120[li_4 + ColorBarBack] > 0.0) g_ibuf_116[li_4 + ColorBarBack] = g_ibuf_108[li_4 + ColorBarBack];

g_ibuf_112[li_4] = EMPTY_VALUE;

}

}

}

return (0);

}

 

 

 

 

 

 

 

and this is the second one needed:

 

 

 

 

 

 

 

#property copyright "eevviill"

#property link "http://alievtm.blogspot.com"

#property version "3.0"

#property strict

#property indicator_chart_window

 

#property indicator_buffers 8

#property indicator_color1 clrRed

#property indicator_color2 clrDeepSkyBlue

#property indicator_color3 clrRed

#property indicator_color4 clrDeepSkyBlue

#property indicator_width1 4

#property indicator_width2 4

#property indicator_width3 1

#property indicator_width4 1

//yell

#property indicator_color5 clrYellow

#property indicator_color6 clrYellow

#property indicator_color7 clrYellow

#property indicator_color8 clrYellow

#property indicator_width5 4

#property indicator_width6 4

#property indicator_width7 1

#property indicator_width8 1

 

 

extern int Number_of_candles = 3;

extern int Candle_shift = 5;

extern bool use_revers = false;

extern ENUM_TIMEFRAMES Time_frame1 = 1440;

extern ENUM_TIMEFRAMES Time_frame2 = 240;

extern ENUM_TIMEFRAMES Time_frame3 = 60;

extern ENUM_TIMEFRAMES Time_frame4 = 1440;

extern ENUM_TIMEFRAMES Time_frame5 = 1440;

extern ENUM_TIMEFRAMES Time_frame6 = 1440;

extern ENUM_TIMEFRAMES Time_frame7 = 1440;

extern ENUM_TIMEFRAMES Time_frame8 = 1440;

extern ENUM_TIMEFRAMES Time_frame9 = 1440;

 

 

 

double body_up[];

double body_down[];

double shadow_up[];

double shadow_down[];

//yell

double yell_body_up[];

double yell_body_down[];

double yell_shadow_up[];

double yell_shadow_down[];

 

datetime prevtime;

ENUM_TIMEFRAMES Time_frames[9];

 

/////////////////////////////////////////////////////////////////

int OnInit()

{

if(Number_of_candles>9) Number_of_candles=9;

Time_frames[0]=Time_frame1;

Time_frames[1]=Time_frame2;

Time_frames[2]=Time_frame3;

Time_frames[3]=Time_frame4;

Time_frames[4]=Time_frame5;

Time_frames[5]=Time_frame6;

Time_frames[6]=Time_frame7;

Time_frames[7]=Time_frame8;

Time_frames[8]=Time_frame9;

 

 

SetIndexBuffer(0,body_up);

SetIndexStyle(0,DRAW_HISTOGRAM);

SetIndexShift(0,Candle_shift+Number_of_candles);

 

 

SetIndexBuffer(1,body_down);

SetIndexStyle(1,DRAW_HISTOGRAM);

SetIndexShift(1,Candle_shift+Number_of_candles);

 

SetIndexBuffer(2,shadow_up);

SetIndexStyle(2,DRAW_HISTOGRAM);

SetIndexShift(2,Candle_shift+Number_of_candles);

 

SetIndexBuffer(3,shadow_down);

SetIndexStyle(3,DRAW_HISTOGRAM);

SetIndexShift(3,Candle_shift+Number_of_candles);

 

//yell

SetIndexBuffer(4,yell_body_up);

SetIndexStyle(4,DRAW_HISTOGRAM);

SetIndexShift(4,Candle_shift+Number_of_candles);

 

SetIndexBuffer(5,yell_body_down);

SetIndexStyle(5,DRAW_HISTOGRAM);

SetIndexShift(5,Candle_shift+Number_of_candles);

 

SetIndexBuffer(6,yell_shadow_up);

SetIndexStyle(6,DRAW_HISTOGRAM);

SetIndexShift(6,Candle_shift+Number_of_candles);

 

SetIndexBuffer(7,yell_shadow_down);

SetIndexStyle(7,DRAW_HISTOGRAM);

SetIndexShift(7,Candle_shift+Number_of_candles);

 

return(INIT_SUCCEEDED);

}

 

 

 

 

//////////////////////////////////////////////////////////////////

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[])

{

//new bar

if (Time[0] != prevtime)

{

ArrayInitialize(body_up,EMPTY_VALUE);

ArrayInitialize(body_down,EMPTY_VALUE);

ArrayInitialize(shadow_up,EMPTY_VALUE);

ArrayInitialize(shadow_down,EMPTY_VALUE);

ArrayInitialize(yell_body_up,EMPTY_VALUE);

ArrayInitialize(yell_body_down,EMPTY_VALUE);

ArrayInitialize(yell_shadow_up,EMPTY_VALUE);

ArrayInitialize(yell_shadow_down,EMPTY_VALUE);

 

 

prevtime = Time[0];

}

 

int i2=0;

for(int i=0;i<Number_of_candles;i++)

{

i2=i;

if(use_revers) i2=Number_of_candles-i;

 

double open_=iOpen(Symbol(),Time_frames,0);

double close_=iClose(Symbol(),Time_frames,0);

 

//main

if(close_!=open_)

{

yell_body_up[i2]=EMPTY_VALUE;

yell_body_down[i2]=EMPTY_VALUE;

yell_shadow_up[i2]=EMPTY_VALUE;

yell_shadow_down[i2]=EMPTY_VALUE;

 

body_up[i2]=open_;

body_down[i2]=close_;

 

if(close_<open_)

{

shadow_up[i2]=iHigh(Symbol(),Time_frames,0);

shadow_down[i2]=iLow(Symbol(),Time_frames,0);

}

if(close_>open_)

{

shadow_up[i2]=iLow(Symbol(),Time_frames,0);

shadow_down[i2]=iHigh(Symbol(),Time_frames,0);

}

}

 

//yell

if(close_==open_)

{

body_up[i2]=EMPTY_VALUE;

body_down[i2]=EMPTY_VALUE;

shadow_up[i2]=EMPTY_VALUE;

shadow_down[i2]=EMPTY_VALUE;

 

yell_body_up[i2]=open_;

yell_body_down[i2]=close_;

yell_shadow_up[i2]=iHigh(Symbol(),Time_frames,0);

yell_shadow_down[i2]=iLow(Symbol(),Time_frames,0);

}

}

 

 

return(rates_total);

}

 

 

 

 

 

 

 

 

that's it, thank you for this

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...