Making a support/resistance EA

 

Hello again,

I have an indicator here, only I don't know if I'm allowed to post it here or not, so here goes:

#property copyright "Support and Resistance none"
#property link "nourl"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue

//---- buffers
double v1[];
double v2[];
double val1;
double val2;
int i;

int init()
{

IndicatorBuffers(2);

SetIndexArrow(0, 119);
SetIndexStyle(0,DRAW_ARROW,STYLE_DOT,1,Red);
SetIndexDrawBegin(0,i-1);
SetIndexBuffer(0, v1);
SetIndexLabel(0,"Resistance");

SetIndexArrow(1, 119);
SetIndexStyle(1,DRAW_ARROW,STYLE_DOT,1,Blue);
SetIndexDrawBegin(1,i-1);
SetIndexBuffer(1, v2);
SetIndexLabel(1,"Support");

return(0);
}

int start()
{

i=Bars;
while(i>=0)
{

val1 = iFractals(NULL, 0, MODE_UPPER,i);
if (val1 > 0)
v1[i]=High[i];
else
v1[i] = v1[i+1];

val2 = iFractals(NULL, 0, MODE_LOWER,i);
if (val2 > 0)
v2[i]=Low[i];
else
v2[i] = v2[i+1];

i--;
}

return(0);
}

//+------------------------------------------------------------------+

Now as you can see, this indicator draws support and resistance lines on the MT4 chart. A red line indicates the resistance line, and the green line indicates the support line. Now here's what I want to do, and this is where I need your help.....

* When the red line appears on the chart, I want the EA to execute a sell... but as soon as the green bar appears, I want to the sell to end and close out.

* When the green line appears, I want the EA to execute a buy... but as soon as the red bar appears, I want the buy to end and close out

* I want the EA to have stop loss capacities so I can put a S/L of about, say 100-200 pips... or however much.

Not so hard to make, but for someone like me who doesn't know MLQ4, it's not the same ;)

Thanks

PS