Hello Barrow boy----I got an idea! can you please check it out for me?


Ps:I already sent this to you in the old threadbut decided to send it in a new one again incase you don't see the old one

hi Barrow boy,

I would be most grate full if you can help me with the code below.i have written some line but am not experienced in progamming,I would be most happy if you can help me look at it and correct any mistakes.

As can been seen in the code below(I hope it is clear enough).the idea is based on using a displaced simple moving average with a period of 5 and positive shift of 2.

for buy signals, the the difference between the dma value and the closing price of the security should be less than or equl toa certain number(for now I am experimenting with 22) and for sell signal, the diference ahould be greater than or equal that number.the maximum number open position should not exceed one.this should be part of the criteria for opening a postion.

An open buy trade should be closed when conditions for a sell trade(as mention above) exists conversely,a sell tposition should be closed when conditions for buy trade exists

I have difficulty in writting the following codes snipet for the EA:

1) code for verifying that an opnem position exist

2)code for closing an open postion

3)code for opening a positons when the conditions are met.

Thanks in advance.


//| DMA
//| Copyright © 2008, malachy

extern double Lots = 0.1;
extern int diffsell=+22;
extern int diffbuy=-22;

//| |
int start()
double ma_val; // value of displaced moving simple moving average
int total; // max order
int ticket;

ma_val=iMA( NULL,0,5,2,0,0,0); // data been put into external variables for easy manipulation

// now lets check for open position and close it if the conditions for exiting exists


if (total >= 1 && ma_val - PRICE_CLOSE >= diffsell)

} //close buy trade

if (total >= 1 && ma_val - PRICE_CLOSE <= diffsell)

return(0); //close sell trade

if (total <= 0 && ma_val - PRICE_CLOSE <= -22) // check for long possibility
OrderSend(Symbol(),OP_BUY,1,Ask, 5,0,0,NULL, 9055500, 0,Green);

// buy!
if (total >= 0 && ma_val - PRICE_CLOSE >= +22) // check for short possibility

ticket=OrderSend(Symbol(),OP_SELL, 1, Bid, 5,0,0,NULL, 9103525,0,Green); //sell!



// the end.

Brian Dee - Random Trader
Brian Dee - Random Trader  


Delete this one - its got the wrong paste-in and the real info is on the other post

AND... I think one 'branded' thread is quite enough....

There are loads of very able people on here, and everyone knows I just do the easy ones ;)