For [login to view URL], I need code that will do the same thing for use in Alerts.
[login to view URL] can be used to limit the amount of open buy orders and sell orders.
[login to view URL](id = "Buy", long = true, qty = 1, oca_name = "Group1", when = [login to view URL] >= 0 and [login to view URL] <= 1 and buycondition
A maximum of 2 Buy trades will remain open at any time.
Sell trades will need to close 1 Buy trade before another Buy trade can be executed.
B B B S S B
The first 2 Buys executed. The 3rd Buy ignored. The last 2 Sells closed 1 of the Buys (see [login to view URL] Sell settings below). Since one of the Buys has now been closed, the last Buy will be allowed to be executed. This continues forever.
Note: “Executed” means I get an alert to buy or sell. "Ignored" means I don't get an alert to buy or sell.
[login to view URL](id = "Sell", long = false, qty = 0.5, oca_name = "Group1", oca_type = [login to view URL], when = [login to view URL] >= 1 and [login to view URL] <=4 and sellcondition
A maximum of 4 Sell trades will execute.
Additional Sells will be ignored if there are no Buys.
B S B B S S S S S B S S S S S
The first 4 Sells closed the first 2 Buys. The 3rd Buy was ignored. The 5th and 6th Sells are ignored. The 4th Buy executes. The 7th and 8th Sell closed the 4th Buy. The 9th, 10th, and 11th Sells are ignored.
Hi, I'm a software developer with focus on metatrader platform. I've got many years experience both in trading and coding. Programming languages - MQL4/5, AFL, PineScript.