MQL4 Learning - page 80

 

I think it's because your initial P_SELL and D_SELL = 0. Change it, for example:

double P_SELL=1000, D_SELL=1000;

 

Higher in the code it is declared as:

P_BUY=High[1];

D_BUY=Low[1];

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Spread,Low[1]-1*Point,0,"exp MA",28041985,0,Green);

AND:

P_SELL=High[1];

D_SELL=Low[1];

ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,Spread,High[1]+(Spread+1)*Point,0,"exp MA",28041985,0,Red);

 

OK, try this way. Add function Print:

if(Close[1]-Open[1]<0 && High[1]<P_SELL && Low[1]<D_SELL)

{

Print("OK - ",High[1]+(Spread+1)*Point);

P_SELL=High[1];

D_SELL=Low[1];

OrderModify(OrderTicket(),OrderOpenPrice(),High[1]+(Spread+1)*Point,OrderTakeProfit(),0,Red);

and inform you see this in logs.

 

OK;)

There's nothing for SELL. For BUY it shows value in logs.

 

Next step:

Print("close - ",Close[1]," open - ",Open[1]," high - ",High[1]," p_sell - ",P_SELL," low - ",Low[1]," d_sell - ",D_SELL);

if(Close[1]-Open[1]<0 && High[1]<P_SELL && Low[1]<D_SELL)

{

Print("OK - ",High[1]+(Spread+1)*Point);

P_SELL=High[1];

D_SELL=Low[1];

OrderModify(OrderTicket(),OrderOpenPrice(),High[1]+(Spread+1)*Point,OrderTakeProfit(),0,Red);

and find your conditions.

 

Adding email notification

Hey Folks,

I've been trying to modify this piece of code, as a test if you like to learn some MQL.

I'm trying to add an email notification option to this indicator, basically it draws an up or down arrow at certain conditions.

So far all ive manged to do is add :-

extern bool EmailON=True;

Which seems to add the option to the indicator, but im a bit baffled as to what todo next. I know SetIndexBuffer is defining the indicator (or i think it is).

Here's the code so far :-

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 DarkGray

#property indicator_color2 DarkGray

extern bool EmailON=True;

double gd_76 = 0.2;

int gi_84 = 100;

int gi_88 = SYMBOL_ARROWDOWN;

int gi_92 = SYMBOL_ARROWUP;

double g_ibuf_96[];

double g_ibuf_100[];

int init() {

SetIndexStyle(0, DRAW_ARROW, EMPTY, 1);

SetIndexArrow(0, gi_88);

SetIndexBuffer(0, g_ibuf_96);

SetIndexEmptyValue(0, 0.0);

SetIndexStyle(1, DRAW_ARROW, EMPTY, 1);

SetIndexArrow(1, gi_92);

SetIndexBuffer(1, g_ibuf_100);

SetIndexEmptyValue(1, 0.0);

return (0);

}

int deinit() {

return (0);

}

int start() {

int li_0;

double ld_4;

double ld_12;

int li_20 = IndicatorCounted();

if (li_20 > 0) li_20--;

int li_24 = Bars - li_20;

if (li_24 > gi_84) li_24 = gi_84;

for (int l_count_28 = 0; l_count_28 < li_24; l_count_28++) {

li_0 = l_count_28;

ld_4 = 0;

ld_12 = 0;

for (li_0 = l_count_28; li_0 <= l_count_28 + 99; li_0++) ld_12 += MathAbs(High[li_0] - Low[li_0]);

ld_4 = ld_12 / 100.0;

if (Close[l_count_28 + 2] > Close[l_count_28 + 3] && High[l_count_28 + 2] - (Close[l_count_28 + 2]) > High[l_count_28 + 3] - (Close[l_count_28 + 3])) g_ibuf_96[l_count_28 + 2] = High[l_count_28 + 2] + ld_4 * gd_76;(Alert("Indicator set"));

else g_ibuf_96[l_count_28 + 2] = 0.0;

if (Close[l_count_28 + 2] Close[l_count_28 + 3] - iLow(NULL, 0, l_count_28 + 3)) g_ibuf_100[l_count_28 + 2] = Low[l_count_28 + 2] - ld_4 * gd_76;

else g_ibuf_100[l_count_28 + 2] = 0.0;

//

}

return (0);

}

Any help is mucho appreciated

 
Roger09:
Next step:

Print("close - ",Close[1]," open - ",Open[1]," high - ",High[1]," p_sell - ",P_SELL," low - ",Low[1]," d_sell - ",D_SELL);

if(Close[1]-Open[1]<0 && High[1]<P_SELL && Low[1]<D_SELL)

{

Print("OK - ",High[1]+(Spread+1)*Point);

P_SELL=High[1];

D_SELL=Low[1];

OrderModify(OrderTicket(),OrderOpenPrice(),High[1]+(Spread+1)*Point,OrderTakeProfit(),0,Red);

and find your conditions.

Ok, error founded. Now I don't know how to solve it;)

I'll try to rewrite the code with some modifications.

Thanks for help.

 

Time display

TF=15. I am trying to activate a bit of source code when Minute()=14 and Seconds()=55. I created this below to show what my program is seeing:

sComment = sComment + "MINUTE = " + DoubleToStr(Minute(),0) + NL; sComment = sComment + "SECONDS = " + DoubleToStr(Seconds(),0) + NL;

The seconds() comments go from 0 to 60, then back to 0 which is correct.

The minutes() comments go from 0 to 60 also, which is incorrect for what I want. I need for the minutes() to go from 0 to 15(TF of Graph) and then back to 0.

Can I get some help here??

Dave

<<<

 

countdown code

1Dave7:
TF=15. I am trying to activate a bit of source code when Minute()=14 and Seconds()=55. I created this below to show what my program is seeing:
sComment = sComment + "MINUTE = " + DoubleToStr(Minute(),0) + NL; sComment = sComment + "SECONDS = " + DoubleToStr(Seconds(),0) + NL;

The seconds() comments go from 0 to 60, then back to 0 which is correct.

The minutes() comments go from 0 to 60 also, which is incorrect for what I want. I need for the minutes() to go from 0 to 15(TF of Graph) and then back to 0.

Can I get some help here??

Dave

<<<

This should help - i suspect there are better ways to do it however this has worked for me.

m15=iTime(NULL,15,0)+15*60-TimeCurrent();

s=m15%60;

m15=(m15-m15%60)/60;

h=m15/60;

DoubleToStr(m15-(h*60),Digits/10) //minutes

DoubleToStr(s,Digits*Point) //seconds

 

Does there exsits a function (.mqh) collection?

Hello,

yesterday I found a file on the web called "common_functions.mqh" with some useful functions inside.

Does anyone know if there are more function collection for MT4?

Cheers and thanx,

Dario

Reason: