EA Assistance

 

Hello,


I am trying to make an EA based on one indicator but with two different settings.


Let me see if I can explain correctly:


The indicators are show the trend of two timeframes. M5 and M15. Now I have managed to get the EA to trade when the two match (as shown below in the picture) and it Closes the trade when one of the indicators shows a reversal (in this case green)


So that is exactly what i want. Now you see in the picture after the trade is closed and the green patch lasts for 11 bars and then turns to RED again.

I want to know why my EA doesn't open another trade at this point? Is there some piece of code I need to add so that the EA is actively seeking possible trades again?

The only time the EA makes another trade, are when both indicators show the exactly opposite so in this case. BOTH indicators show RED ( TRADE OPENS); another trade will not open until BOTH indicators show green?


You get me?


Any help would be greatly appreciated


Regards


Pete

 

Hi

without the code...i'ts a little bit difficult !

 

Let me show you my opening and closing code:


double SITE1=iCustom(NULL,0,":D",25,30,5,0,1);
double SITE2=iCustom(NULL,0,":D",25,30,5,1,1);
double SITE3=iCustom(NULL,0,":D",25,30,5,0,2);
double SITE4=iCustom(NULL,0,":D",25,30,5,1,2);

double SPITE1=iCustom(NULL,0,":D",25,30,15,0,1);
double SPITE2=iCustom(NULL,0,":D",25,30,15,1,1);
double SPITE3=iCustom(NULL,0,":D",25,30,15,0,2);
double SPITE4=iCustom(NULL,0,":D",25,30,15,1,2);



bool BUY=false;
bool SELL=false;


if(

SITE1 < SITE2 && SITE3 > SITE4 && SPITE1 < SPITE2 && SPITE3 > SPITE4
)BUY=true;
if(

SITE1 > SITE2 && SITE3 < SITE4 && SPITE1 > SPITE2 && SPITE3 < SPITE4
)SELL=true;


{

if(SITE1 > SITE2 && SITE3 < SITE4) CloseBuyOrders(Magic);
if(SPITE1 > SPITE2 && SPITE3 < SPITE4) CloseBuyOrders(Magic);
if(SITE1 < SITE2 && SITE3 > SITE4) CloseSellOrders(Magic);
if(SPITE1 < SPITE2 && SPITE3 > SPITE4) CloseSellOrders(Magic);


}

 

I think the problem is in :

SITE1 < SITE2 && SITE3 > SITE4 && SPITE1 < SPITE2 && SPITE3 > SPITE4
)BUY=true;
if(

SITE1 > SITE2 && SITE3 < SITE4 && SPITE1 > SPITE2 && SPITE3 < SPITE4
)SELL=true;

This need two indicator changing at the same time. You have to complete the code with first indicator change and not the second but both are red or green.

 

Yes, I think this is the case too, like you say it is looking for both of them to change in conjunction with one another.


However, a lot of the time as you can see in the picture, one stays the same (green) and the other indi fluctuates between red and green.


Do you have any idea how to change the code to correct this?


My brain is just not working today :DD


thanks

 

I have had a thought.


If i can set up the second indicator (m15) as a pre-condition for trading. That if GREEN only buy and RED only sell.


Then i can just use the m5 indicator to make the trades.


I have no idea how to code this bit though

grrrr :(

 

Do you have any idea how to change the code to correct this?

Add some "or" conditions... :)

 
please can you explain? :(
 
Can anyone elaborate on what Matutin says? I am still finding no solution :/
Reason: