[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 118
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Afternoon.
I wrote code to open two pending orders (BuyStop and SellStop) on conditions a=true and b=true and after some time the EA closes both orders, until a new signal appears, but sometimes the EA opens 2 pending orders in the same direction. Why this happens and how to avoid this "bug"?
if (a=true && b=true)
{
int OrderCount = OrdersTotal();
if (OrderCount>1) return(0);
ticket1=OrderSend(Symbol(), OP_BUYSTOP, getLot(), PriceOpen_Buy, slippage, PriceOpen_Sell,0,0,Green);
Sleep(1000);
ticket2=OrderSend(Symbol(), OP_SELLSTOP, getLot(), PriceOpen_Sell, slippage, PriceOpen_Buy,0,0,Green);
Sleep(1000*59*TimeFrame);
for (int i=OrdersTotal()-1; i>=0; i--)
{
if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) break;
if (OrderType()==OP_BUYSTOP ) OrderDelete(OrderTicket());
if (OrderType()==OP_SELLSTOP ) OrderDelete(OrderTicket());
if (OrderType()==OP_SELL ) OrderClose(OrderTicket(),OrderLots(),Ask, slippage);
if (OrderType()==OP_BUY ) OrderClose(OrderTicket(),OrderLots(),Bid,slippage);
}
return(0);
}
Can you give me a hint?
Thank you in advance
Hello,
Is it possible to enter a schedule with a fixed weight 1:1 in the settings?
If it is possible, please tell me how.
Thanks in advance.
This library can.
Section "3.3 Function for setting chart properties" function ServiceSetScaleFix1To1().
The library works only with the Russian and English localizations. It may work in yours, too.
Here is the order opening function:
Here is the parameter printout:
Here you can clearly see that the TP and SL price are below and above the Ask and Bid respectively, i.e. everything is correct. But for some reason I get a modification error because the stop is wrong. How so?
Here is the order opening function:
Here is the parameter printout:
Here you can clearly see that the TP and SL price are below and above the Ask and Bid respectively, i.e. everything is correct. But for some reason I get a modification error because the stop is wrong. How so?
Do you read at all what is being scolded?
If you don't understand anything, we'll sort it out with the rest of the world...
ZZY. When you place a pending order, the string
if (price < Bid)
When you place a pending order, the string should not be quite relevant. It should be checked for the correspondence with minimal allowed distance set in MarketInfo(Symbol(), MODE_STOPLEVEL). The first thing that immediately caught my eye.
The second is to print the price at which the order is set. The Stop and Take should not be set relative to the Ask and Bid, but relative to the order setting price
This library can.
Section "3.3 Graph Property Setting Functions" function ServiceSetScaleFix1To1().
The library works only with Russian and English localizations. It may work in yours, too.
Do you even read what is being scolded?
Look at parameters passed to the called function. When nothing at all becomes clear, we'll sort it out in peace...
Of course I'm reading it, that's why I'm curious. I unlinked all input parameters.
This is what I got:
Here's what's in the log:
Some of the orders are modified and some are not. Values of ND(TP), ND(SL) in the beginning were returned to random values. Why?
The normalisation function, by the way, is mine:
Do you even read what is being scolded?
See the parameters passed to the function to be called.When nothing is clear at all, we'll sort it out with the world...
ZS. When you place a pending order the line
if (price < Bid)
This is not quite appropriate. You should check if the minimum allowed distance corresponds to that specified in MarketInfo(Symbol(), MODE_STOPLEVEL). The first thing that caught my eye right away.
I usually encounter such checks for order modification but not for opening. I've already seen it. If I set pending price to bystop, it will be a mistake. And if I set a 10 pips stop it will be surely higher than the StopLoss value. I do not trade on ticks :)
Secondly, print the price at which the order is set. Stop and Take should not be placed relative to the Ask and Bid, but relative to the price at which the order is set
I take it that this is for modification? After all, it is Bid and Ask that is important to us when we open the order. I have straightened out everything with the post above.
Good afternoon,
I want to make an EA work on several windows at the same time. But only one order can be open for each instrument. Therefore, now there is a condition:
int total = OrdersTotal();
if (total<1) { analysis and open position block} else { analysis and close position block }
Now, if it is opened on two symbols at the same time, opening on one will be blocked on the other. That's why I made up something similar:
int total = OrdersTotal();
int cnt;
if(total>0)
{
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol())
{
Symbol_FLAG = true;
}
}
}
if(total<1 || total>0 && Symbol_FLAG == false) { analysis and opening ptposition block}
but it doesn't work on the tester...
Maybe you can tell me, maybe I'm up to something unrealizable?