Help with Programming Straddle in Zerocode?

 

How do I program a straddle in Zerocode to put a Buy Stop 10 pips above the current price and a Sell Stop below the current price? Also can I program this only to happen at a certain time (7:29am CST)?

Thank you

Todd

 

Only market order is possible for now. But in your case, you can produce same system with just market order.

1. Enter this in ZeroCode:

Buy logics:

Bid > LastPrice + (10 * Point)

Sell logics:

Bid < LastPrice - (10 * Point)

2. In the mql file, find // Calculate indicators' value

3. Below that, add these code:


var: LastPrice(0), LastTime(0);
if TimeDay(LastTime) != Day() and Hour()=7 and Minute()=29 then
{
LastPrice = Bid;
LastTime = CurTime();
}

4. In above code, you may change Hour()=7 and Minute()=29 to whatever time you like. But it's in broker's timezone, not CET! So be sure to modify this to correct time.

 

Do you also want to limit one trade per day?

 

The EA attached has the pending orders I am looking for except I want them to go off the current price. Anyway to marry this code into Zerocode?

Files:
 

Scorp,

i would like help compling something simular using MT4. buy when current price is (x) pips above the bar open price, and sell when current price is (x) pips below the open price. i would like the number of pips to be user definable so i can use the optimize function in MT4. any help would be appreciated.

todd

 

Here you go rondio and Toddr: https://www.mql5.com/en/forum/194289