I am working with the MT5 bridge, and currently I am struggling to place Buy Limit and Sell Limit orders.
When I run my code, the Buy/Sell Limit order is placed almost directly at the current price, instead of at a 0.2% distance from the current price.
Furthermore, I am wondering how to program Buy/Sell Stop orders in Zorro. The manual doesn't seem to provide proper code examples. Can anyone of you help me out with this?
Best regards, steyr
Code
if(priceC(0) <= priceO(0) and NumPendingShort <= 0)
{
OrderLimit = priceO(0)-(priceC(1)*(0.2/100)); // 0.2% Distance from current Price
MaxShort = 1;
enterShort(OrderLimit);
}
else if(priceC(0) >= priceO(0) and NumPendingLong <= 0)
{
OrderLimit = priceO(0)+(priceC(1)*(0.2/100));// 0.2% Distance from current Price
MaxLong = 1;
enterLong(OrderLimit);
}
Last edited by steyr; 10/19/2319:00.
Re: Placing BuyStop and SellStop Orders
[Re: steyr]
#487866 10/19/2320:0510/19/2320:05
I see, unfortunately, changing the approach as you said before hasn't resolved the issue with the inexplicable placement of OrderLimit. Even though the correct price level is displayed in the print statement, it's not being placed accurately in the market.
In the attached image, priceO(0) and the OrderLimit variable are printed, showing a difference of 0.02%. Despite this, a sell position is opened at 0.00006 immediately afterward. What could be going wrong here?
Code
if(priceC(0) <= priceO(0) and NumPendingShort <= 0)
{
OrderLimit = priceO(0)-(priceO(0)*(0.2/100)); // 0.2% Distance from current Price
MaxShort = 1;
enterShort();
}
else if(priceC(0) >= priceO(0) and NumPendingLong <= 0)
{
OrderLimit = priceO(0)+(priceO(0)*(0.2/100));// 0.2% Distance from current Price
MaxLong = 1;
enterLong();
}
Last edited by steyr; 10/20/2315:40.
Re: Placing BuyStop and SellStop Orders
[Re: steyr]
#487872 10/20/2317:4910/20/2317:49