3bar break

 

High, i made this simple expert for a friend, and now he wants to only allow one trade on the same direction.

So if there's a buy position open, the expert wont open another buy position; and if there's a sell position open, the expert wont open another sell position.

Could someone help me?

Thanks in advance,

JCC

Files:
3break.mq4  10 kb
 
 

Hi

Its pretty simple, if you have 3 consecutive bars making higher closes, then it buys, if you have 3 consecutive bars making lower closes, then it sells.

Closes positions on reverse signals.

The thing is that i must limit this EA to just 1 open trade at a time, and to only open 1 trade in the same direcction.

If someone could helpme add that code to the ea i'll be thankful.

As for timeframe you can use anyone, i didnt fully test this ea, because it's just for a friend that asked me for it.

I guess it should work well with the limit i just said, and with really tight stops and tight trailing stops (sl arround 10-14 pips for 1h tf, 20-25 for 1d tf, and ts arround 20 for 1h, 40 for 1d tf).

Thanks in advance,

 

Limiting existing positions

You can try to put your order opening instructions inside this if loop. In that way, your order will go through only if there is no existing position. .

if (!ExistPositions()){

}

 

the requested change.

juanchoc:
High, i made this simple expert for a friend, and now he wants to only allow one trade on the same direction.

So if there's a buy position open, the expert wont open another buy position; and if there's a sell position open, the expert wont open another sell position.

Could someone help me?

Thanks in advance,

JCC

Hi,

I've added 2 parameters : maxBuys and maxSells, i check for those values

where you set the entry signals, and i assign count the orders in the order loop before that.

hope this helps,

CJ.-

Files:
3break.mq4  11 kb
 

Wow!

Thanks, just what i was looking for.

Thanks a lot ZeeJay

Reason: