HELP - want simple code for sl / tp

 

hi everyone


does anybody have a simple piece of code that I can insert into my EA that will:

1. scan all open positions

2.determine if trade has reach predefined sl / tp

3. close trade accordingly



btw, Im a ex cobol programmer and still new to mql4


thanks

 

buju, in many cases you can predefine sl / tp with OderSend command



int OrderSend( string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment=NULL, int magic=0, datetime expiration=0, color arrow_color=CLR_NONE)


as you see while creating the order you define and broker stops / exits the position for you. This is better because your code cannot be that fast as your broker. Only disadvantage is that many brokers require minimum points of sl/tp like 10 points. So if you want quit with +.5 pips you cannot do that automtically.

 

fx1.net, yes I can do that but I have to put in 30+ pips sl and tp .....