[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 828
![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
Not exactly - for a Stop order, the opening price could be, for example in the case of Buy,
maximum of a previous fractal (=OpenPrice) + Spread
(provided that the Ask is lower than the fractal by the Stop_Level or more). I.e., the order is placed not on the Ask, but on some "external" condition.
But more to the point I would like to know about accounting for Spread in TakeProfit and StopLoss:
- In the case of Buy:
OrderSend(Symbol (), OP_BUYSTOP, Lots, OpenPrice+Spread, Slippage, OpenPrice-StopLoss, OpenPrice+TakeProfit+Spread, ...)
- Sell:
- Correct or am I missing something?
And the difference between Asc and Bid is the spread... That's how we do it...
Do I have to press "reply" to write a message? How can I add a message to a thread without pressing "reply"?
At the bottom of the editor window and the "Add comment" button
I read and try to understand, but I come across abbreviations and incomprehensible words. TK, TF, flotsam, etc.
Is there anything like a dictionary of basic abbreviations, little understood words?
A wise man once said: "Give a precise definition to every word and you will rid mankind of half of its misconceptions!"
At current prices, not a pending order, so:
Buy:
Sell:
For pending orders - it depends on the programmer, on what prices the account is kept.
In any case StopLoss and TakeProfit are counted from one price, and OpenPrice differs from it (the price) by a spread.
Hello! I'm new to MQL4 and programming in general, so I have this question:
I wrote code that by a certain time, let's say 21.15, closes all open positions 0 to 3 in the list:
if((TimeHour(TimeCurrent()) == MyHour)&&(TimeMinute(TimeCurrent())== MyMinute))
{
for(int j=0;j<4;j++)
{
if((OrderSelect(j,SELECT_BY_POS,MODE_TRADES)==true))
{
Print("Order:",OrderTicket());
OrderClose(OrderTicket(),MyLots,Bid,5,color3);
}
else
Print("OrderSelect() vernul oshibku - ",GetLastError());
}
On the tester the following happens: orders 0 and 1 are closed at the specified time, and orders 2 and 3 are closed at the same time, but a day later.
I also wrote a code section that modifies stop loss for all orders 0 through 3 in the list:
if(Diff2 <= 0.0012)
{
int pos1;
int total = OrdersTotal();
for(pos1=0; pos<total; pos1++)
{
if(OrderSelect(pos1,SELECT_BY_POS,MODE_TRADES)==true)
{
Print("Order1:",OrderTicket());
OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),Ask-Point*TakeProfit,0,color3);
}
else
Print("OrderSelect() vernul oshibku - ",GetLastError());
}
}
On the tester, the following happens: In the "Result" tab, the tester writes all orders, then hangs and the
"OrderSelect() vernul oshibku - 0".
Please advise what is wrong here or what may be the reason for this behavior?
chief2000:
I just want to clarify one question - it's about opening a Stop order. ...Thank you all very much!
>>Wrote a code that closes all open positions 0 to 3 in the list by a certain time, let's say 21.15:
>>The following happens on the tester: Orders 0 and 1 are closed at the specified time, and orders 2 and 3 are closed at the same time, but 24 hours later.
OrderClose() closes only open orders. OrderDelete() is used to delete pending orders. The other two orders must be pending. After a day they are opened and then close OrderClose()?
>>The code section which modifies a stop loss for all orders from 0 to 3 is also written
for(pos1=0; pos<total; pos1++)
Для "pos1" в условии цикла пропустил единицу:
for(pos1=0; pos1<total; pos1++)