Ask! - page 3

 

Disable alert once hit.

ONE VITAL QUESTION.

In case for an alert in EA, we can mark ''disable alert once hit''.

how we can do that on indicator alerts???

Many tks in advance.

 
hua:
ONE VITAL QUESTION.

In case for an alert in EA, we can mark ''disable alert once hit''.

how we can do that on indicator alerts???

Many tks in advance.

Hua,

Please refer to my reply here.

I can make a demo for you if you want, Please tell me the indicator you want to add to ''disable alert once hit''.

 

Hi - a simple question (I hope...)

How can I code a time base exit command ?

I want to know the duration of an open position expresse by the number of bars that position already open.

Actually, I want to close a position automatically after 30 bars (in my expert-advisor)

How can I code that in mql4?

10X !

 

BarsCountDown Function (by codersguru)

yaniv_av:
How can I code a time base exit command ?

I want to know the duration of an open position expresse by the number of bars that position already open.

Actually, I want to close a position automatically after 30 bars (in my expert-advisor)

How can I code that in mql4?

10X !

Hi yanuv_av,

I'm so sorry for the delay in replaying you; I've spent all the day fixing my damn car to reach my office and reply your questions .

Now you have an EA and want to close the order after 30 bars (or whatever count you want), Right?

Well

Place this function on the top of start() function:

bool BarsCountDown(int count)

{

static bool first_call = true;

static int start_bar = 0;

if(first_call)

{

start_bar=Bars;

first_call=false;

}

if(Bars == (start_bar+count))

{

Print("(TRUE) Bars= " + Bars + " : start_bars = " + start_bar);

first_call=true;

return (true);

}

else

{

Print("(FALSE) Bars= " + Bars + " : start_bars = " + start_bar);

return (false);

}

}[/PHP]

How to use this function:

bool BarsCountDown(30);

The line above returns falseif the current bar hasn't exceeded the number 30 from the first call of the function (the 30 bars not yet counted)

And returns trueif the current bar has exceeded the 30 bars

So, when you get true, close the position

In your start() function you may use code like this:

[PHP]start()

{

....

if(BarsCountDwon(30))

OrderClose(OrderTicket(),OrderLots(),Bid,3,Red); // close position

.....

}

I hope you've got it.

 

Worked?

codersguru:
Hi yanuv_av,

I'm so sorry for the delay in replaying you; I've spent all the day fixing my damn car to reach my office and reply your questions .

Now you have an EA and want to close the order after 30 bars (or whatever count you want), Right?

Well

Place this function on the top of start() function:

bool BarsCountDown(int count)

{

static bool first_call = true;

static int start_bar = 0;

if(first_call)

{

start_bar=Bars;

first_call=false;

}

if(Bars == (start_bar+count))

{

Print("(TRUE) Bars= " + Bars + " : start_bars = " + start_bar);

first_call=true;

return (true);

}

else

{

Print("(FALSE) Bars= " + Bars + " : start_bars = " + start_bar);

return (false);

}

}[/PHP]

How to use this function:

bool BarsCountDown(30);

The line above returns falseif the current bar hasn't exceeded the number 30 from the first call of the function (the 30 bars not yet counted)

And returns trueif the current bar has exceeded the 30 bars

So, when you get true, close the position

In your start() function you may use code like this:

[PHP]start()

{

....

if(BarsCountDwon(30))

OrderClose(OrderTicket(),OrderLots(),Bid,3,Red); // close position

.....

}
I hope you've got it.

yanuv_av,

Did that work for you?

 

ema cross

Hello,

First of all I am very imprest with this site and also with coder, who is helping us to test and make difference code

I am looking to have a code to open and close my position with the following deffination

ema = 3

ema = 13

when ema 3 cross from down to ema 13 plus move 5 pips up, the order will open automatically eample ema 3 and ema 13 cross at 1.1705 for euro/usd my order will be open at 1.1710 it is something like bunnygirl system but I dont know how to make expert please help me.

same technique for selling but all technique reverse

Thanks

 

Triggerlines Alert

Dear CodersGuru, can we hv an alert when this indicator changes colour pls??

Files:
 
 
 

Could not find lesson 2

Hi Codesguru,

The links that you provided in lessons section for lesson 1 and 2 are not working. I found lesson 1 (welcome.pdf) on the thread, but could not locate lesson 2....would you pl post the message and thread for the same?

Thanks,

Maratha.

Reason: