Need Help on Straddle advisor

 

The advisor does not put the Straddle (buy and sell) in at the proper time on InterbankFX charts. It was programmed it to put in a Buy Stop and Sell Stop simotaniously at the TimeAHour, TimeAMin. Can someone help with the problem?? I am willing to give the strategy once fixed I use to one who fixes it that I use live trading now averaging 15 pips per day.

Files:
news.mq4  11 kb
 

Hi,

I have fixed your EA. Small bug was in spread calculation.

Try to test and any proposal please.

Igor

Files:
news_v1.mq4  11 kb
 

How to use this?

Could you please post instructions on how to use this?

What Time frequency should it be used on? 1 min, 5 min?

What do the input parameters mean? Such as MagicNumber, TimaAHour, TimeAMin, GMTShift, LiveHour, LiveMin?

I'm sorry, I am new to using the Expert Advisors. I have successfully compiled and attached your EA to a chart, but I can't seem to get it to make any trades.

Thanks!

 

Hi Igor,

Sorry about the lag in testing it.

It works on the times but I tried when I had it built to not put in more than 1 Buy Stop and Sell Stop when the time is hit.

It puts in more when the S/L or T/P is hit or the pendings are deleted. I want it to put in 1 Buy Stop and Sell Stop at the time set then not put in anymore trades til the time comes around again.

Thank you

 

MQL programming help if possible

igorad:
Hi,

I have fixed your EA. Small bug was in spread calculation.

Try to test and any proposal please.

Igor

Hi Igor,

Sorry to trouble you but i am reallly stuck in this MQL programming thing and hope if you can help.

How do i add a code into my MT4 EA if i only want the trades to be active for a certain time period of a day...say maybe only to trade from (broker time- 7pm to 9pm daily)?

Many thanks in advance if you are able to help...

Grateful,

Ed

 
eooojj:
Hi Igor,

Sorry to trouble you but i am reallly stuck in this MQL programming thing and hope if you can help.

How do i add a code into my MT4 EA if i only want the trades to be active for a certain time period of a day...say maybe only to trade from (broker time- 7pm to 9pm daily)?

Many thanks in advance if you are able to help...

Grateful,

Ed

You may use this code:

if (UseHourTrade){

if(!(Hour()>=FromHourTrade&&Hour()<=ToHourTrade)){

Comment("Non-Trading Hours!");

return(0);

}

}[/CODE]

to be inserted after int

start()[/CODE]

For example:

[CODE]int start()

{

if (UseHourTrade){

if(!(Hour()>=FromHourTrade&&Hour()<=ToHourTrade)){

Comment("Non-Trading Hours!");

return(0);

}

}

And in the settings of EA type the following:

[CODE]extern bool UseHourTrade = True;

extern int FromHourTrade = 19;

extern int ToHourTrade = 21;
 

this is a good straddle EA.

i used it always on the 1min chart

the settings:

CTCBN = Numbers Candles to check Before News For determining High & Lows , when it is 1 it check 2 candles the current candle and the 1 last one

SecBPO = Seconds Before News Which EA Will Place Pending Orders

SecBMO = Seconds Before News Which EA Will Stop Modifying Orders

STWAN = Seconds To Wait After News to Delete Pending Orders

OCO = One Cancel The Other , will cancel the other pending order if one of them is hit

BEPips = Pips In profit which EA will Move SL to BE+1 after that

but i think the last version has a bug and you cant change the lot size in the EA. or you change the lot size it in the code at this place and compile it:

// lot at this point is number of standard lots

return(0.10);

maybe someone here who can fix it?

 
newdigital:
You may use this code:
if (UseHourTrade){

if(!(Hour()>=FromHourTrade&&Hour()<=ToHourTrade)){

Comment("Non-Trading Hours!");

return(0);

}

}[/CODE]

to be inserted after int

start()[/CODE]

For example:

[CODE]int start()

{

if (UseHourTrade){

if(!(Hour()>=FromHourTrade&&Hour()<=ToHourTrade)){

Comment("Non-Trading Hours!");

return(0);

}

}

And in the settings of EA type the following:

[CODE]extern bool UseHourTrade = True;

extern int FromHourTrade = 19;

extern int ToHourTrade = 21;

Hi NewDigital,

I can't thank you enough! thanks!

 

mins with hours

newdigital:
You may use this code:
if (UseHourTrade){

if(!(Hour()>=FromHourTrade&&Hour()<=ToHourTrade)){

Comment("Non-Trading Hours!");

return(0);

}

}[/CODE]

to be inserted after int

start()[/CODE]

For example:

[CODE]int start()

{

if (UseHourTrade){

if(!(Hour()>=FromHourTrade&&Hour()<=ToHourTrade)){

Comment("Non-Trading Hours!");

return(0);

}

}

And in the settings of EA type the following:

[CODE]extern bool UseHourTrade = True;

extern int FromHourTrade = 19;

extern int ToHourTrade = 21;

Hi NewDigital,

Thanks for your help..

The example you gave is from 1900hrs to 2100hrs.

What if i would like to trade from 1930 to 2130hrs?

Thanks in advance....sorry if my post is dumb...cos i am new to mql.

warmest regards,

ed

 

Favor needed

Hi NewDigital,

Thanks for your previous help again.

Would like to ask you a favor again as i could not find the code to include if i want to close all trades at the end of the day like at 2355hrs?

Thanks in advance.

warmest regards,

ed

newdigital:
You may use this code:
if (UseHourTrade){

if(!(Hour()>=FromHourTrade&&Hour()<=ToHourTrade)){

Comment("Non-Trading Hours!");

return(0);

}

}[/CODE]

to be inserted after int

start()[/CODE]

For example:

[CODE]int start()

{

if (UseHourTrade){

if(!(Hour()>=FromHourTrade&&Hour()<=ToHourTrade)){

Comment("Non-Trading Hours!");

return(0);

}

}

And in the settings of EA type the following:

[CODE]extern bool UseHourTrade = True;

extern int FromHourTrade = 19;

extern int ToHourTrade = 21;
 
eooojj:
Hi NewDigital,

Thanks for your help..

The example you gave is from 1900hrs to 2100hrs.

What if i would like to trade from 1930 to 2130hrs?

Thanks in advance....sorry if my post is dumb...cos i am new to mql.

warmest regards,

ed

In the codes I posted from 10 till 21 means from 10 (first bar - 10;01 for example) till last bar in 21st (21:59 for example).

So EA may open the order at 21:38.