[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

 
chief2000:

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?

Right, I'm falling asleep already, and I'm exhausted from the hardest negotiations with the customer, but I'll just say one thing: we open Buy position on Asc, we close it on Bid.
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"?
 
 
peshihod:
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:

OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, Bid-StopLoss, Bid+TakeProfit, ...)

Sell:

OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, Ask+StopLoss, Ask-TakeProfit, ...)

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!

 
chief2000:

chief2000:

I want to clarify one question - it's about opening a Stop order. . ..
Might be helpful!!! Try to base it on one price: let's say Bid. The opening price of OP_SELLSTOP will be Bid , and for OP_BUYSTOP - Bid+87*Point (or whatever you need).
 
temkin:

>>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++)

Reason: