How to code? - page 225

 

newbie...

first of all happy new year to all!

then thank you for all the knowledge you're sharing in this forum

I'm approaching mql4, I'm not a coder.

I would appreciate a little support writing this very simple strategy:

long entries:

(ask-bid) <= Z_pips /* spread check */

and

(bollinger_up-bollinger_down) <= K_pips /* volatily check */

and

ask < (bollinger_down + X_pips) /* price check */

and

ma_Qperiods >= ma_Wperiods /* trend check */

exits:

Trailing SL = 15 pips

Does anybody have time to give me a chance?

Thanks in advance

neeverr

 

need some help with my nr7 indicator

hello

i am codng indicator for nr7.

the algo is

-calculate range and store it in array

- if current range <= last 7 ranges, then current bar is nr7

but the indicator seems to be flagging every bar as nr7. dunno where i made a mistake.

screenshot is here

2010-01-18_0531

Files:
nr7.mq4  3 kb
 

advancedsar EA

Hi friends,

I need all your help, if any of you can help me to modify an EA which I got from other thread, but unfortunately i don't have its mql file.

From the original logic of this EA, I want to make a bit modification as below :

- This EA only working on 4 digits, help to improve they can work on 5 digits as well.

- This EA working according to common martingale system, I need to add more 2X methode operation mode,

1. If the EA opens order on the last trade, and they hit TP, then EA will start new cycle and open trade as the same order as the last order. Example : if the last trade is buy order, and they hit TP, then the EA will keep going open buy trade unless they hit SL and EA will change the order to opposite direction sell order. the same thing on the sell order, as longs as they profit on the sell order, then they continue opening sell order with new cycle until they got SL and direction change to buy order.

2. Second mode operation. The EA working on sequence logic buy-sell-buy-sell-buy, this mode is designed for market ranging with no trend.

will be appreciated for all your help.

thanks

yoha

Files:
 

any idea why this EA won't place orders?

hey guys, it's been a while since I am back in this game .... anyway just starting to refresh on mql....lot has changed here.

basically i want to place pending buy and sell orders 10 pip away from the opening of a bar on both sides. Takeprofit is 15 pips away from pending orders.

the problem is orders are never placed...

int counted_bars = IndicatorCounted();

int pos = Bars - counted_bars + 1;

if (counted_bars == 0) pos = Bars - 10;

if (counted_bars>0) counted_bars--;

double currentPrice = iClose("EURUSD",PERIOD_M1,0);

while(pos>0)

{

//Putting Pending LongOrder

Print("Long...");

OrderSend("EURUSD",OP_BUYLIMIT,1,Open+10*Point,3,0,Open+25*Point,"Pending Long Order", 888, 0, Green);

Print("Short...");

//Putting Pending ShortOrder

OrderSend("EURUSD",OP_SELLSTOP,1,Open-10*Point,3,0,Open-25*Point,"Pending Short Order", 999, 0, Red);

pos--;

}
 

I'm not sure what counted bars has to do with an EA? Isn't it designed for use in indicators?

I think if you took that part out you might be OK.

 

datetime variable

Hi,

I want to write the actual data and the time

extern int starthour = 8;

extern int startminute = 0;

[/CODE]

in my variable

[CODE]

datetime starttime= 0;

How can I write this?

But how can I write this:

starttime = Date of the day + starthour + startminute;

 

Not quite sure what you're asking but I'll guess you're trying to increment a date by a number of hours and minutes. If you look at the help file for TimeCurrent() you'll see that it returns the time as seconds. So logically you can then deduce that to add minutes you would multiply by 60 and for hours it would be by 3600 (60*60).

So you would have something like...

TimeCurrent()+(starthour*3600)+(startmin*60);

Just replace TimeCurrent() with whatever time you've designated as 'startdate'.

Lux

 
sunshineh:
Hi,

I want to write the actual data and the time

extern int starthour = 8;

extern int startminute = 0;

[/CODE]

in my variable

[CODE]

datetime starttime= 0;

How can I write this?

But how can I write this:

starttime = Date of the day + starthour + startminute;

Use StrToTime function. If you won't pass day to this function but only hour and minute, it will use current day. Like this:

datetime startTime = StrToTime( StartHour+":"+ StartMinute);

Where StartHour and StartMinute are strings:

string StartHour = 8;

string StartMinute = 0;

 

Lot's of thanks!!

I have another question, too.

How can I code it, if I want my EA only to buy or sell at the close-Price of the candle?

I thought I can write

if(!Close[0]) return;

but it doesn't work.

 
sunshineh:
Lot's of thanks!!

I have another question, too.

How can I code it, if I want my EA only to buy or sell at the close-Price of the candle?

I thought I can write

if(!Close[0]) return;
but it doesn't work.

You need to define a variable lets say it will be:

int barsNumber = 0;

in the global section (eg. right before init function)

and then in the start function where you have your part with sendOrder function you need to check this condition

if(Bars>barsNumber)

and if it is true then set our variable barsNumber to Bars

barsNumber = Bars;

So all would look like this:

#some properties

int barsNumber = 0;

int init()

{

}

int deinint()

{

}

int start()

{

if(Bars>barsNumber)

{

SendOrder(...);

barsNumber = Bars;

}

}

Reason: