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

[Deleted]

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.

Malachy

//+------------------------------------------------------------------+
//| DMA
//|
//+------------------------------------------------------------------+

extern double Lots = 0.1;
extern int diffsell=+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

total=OrdersTotal();

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

{
return(0);

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

{
OrderClose(ticket,1,Bid,1,Red);

if (total <= 0 && ma_val - PRICE_CLOSE <= -22) // check for long possibility
{
}

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!
}

return(0);
}

}

// the end.

1756

NF

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 ;)

-BB-