[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 50

 

In the EA itself, the entire code is laid out.

Thank you all very much for all your help.

 
Sergstuddek:

Hello. Please help a suffering person.

I just started to learn MQL and have decided to write my first Expert Advisor.

I want to explain why it does not open pending orders and what the problem is.

int OpenStops()
{
if(OrderSelect(CalculateCurrentOrders1(Symbol(),SELECT_BY_POS,MODE_TRADES)==true && OrderType()==OP_BUY) // check for an open Buy order
int ticket;
double LotSize=OrderLots(); // open order lot size
double OpenPrice=OrderOpenPrice(); // Open order open price
ticket=OrderSend(Symbol(),OP_SELLSTOP,LotSize*2,OpenPrice-DS*Point,0,SL*Point,TP*Point,"",MAGIC,0,Red); // Open a Sell position in the opposite direction before the open order
ticket=OrderSend(Symbol(),OP_BUYSTOP,Lot,OpenPrice+TP*Point,0,SL*Point,TP*Point,"",MAGIC,0,Blue); // open a buy position for the continuation to the open order

if(OrderSelect(CalculateCurrentOrders1(Symbol())SELECT_BY_POS,MODE_TRADES)==true && OrderType()==OP_SELL) // Check for an open Sell order
ticket=OrderSend(Symbol(),OP_SELLSTOP,Lot,OpenPrice-TP*Point,0,SL*Point,TP*Point,"",MAGIC,0,Red); // open a buying pending order
ticket=OrderSend(Symbol(),OP_BUYSTOP,LotSize*2,OpenPrice+DS*Point,0,SL*Point,TP*Point,"",MAGIC,0,Blue); // open a buy reverse pending order before the open order
}


First, learn how to insert the code correctly - via Counter+Alt+M - then everything else...
 
Roman.:
First, learn how to insert the code correctly - via Counter+Alt+M - then everything else...
Вот в этом окошке будет код, если воспользоваться кнопкой SRC на верхней панели
 

Can you suggest a script or an EA to display information on the screen (spread, stop level, open trades, profit on trades, profit for the day, etc.)? Thanks.

 
granit77:



Thank you for your help, it helped me a lot
 
Hello. Please help a suffering person.

I just started to learn MQL and decided to write my first Expert Advisor, but I have a problem

in the code, pending orders do not open, please tell me why and what the problem is.
int OpenStops()
{
if(OrderSelect(CalculateCurrentOrders1(Symbol()),SELECT_BY_POS,MODE_TRADES)==true && OrderType()==OP_BUY) // Проверка на то что открытый ордер на покупку
int ticket;
double LotSize=OrderLots(); // Размер лота открытого ордера
double OpenPrice=OrderOpenPrice(); // Цена открытия открытого ордера
ticket=OrderSend(Symbol(),OP_SELLSTOP,LotSize*2,OpenPrice-DS*Point,0,SL*Point,TP*Point,"",MAGIC,0,Red); // Открытие отложки на продажу в противополжну сторону до открытого ордера 
ticket=OrderSend(Symbol(),OP_BUYSTOP,Lot,OpenPrice+TP*Point,0,SL*Point,TP*Point,"",MAGIC,0,Blue); // Открытие отложки на покупку в сторону продолжения до открытого ордера

if(OrderSelect(CalculateCurrentOrders1(Symbol()),SELECT_BY_POS,MODE_TRADES)==true && OrderType()==OP_SELL) // Проверка на то что открытый ордер на продажу
ticket=OrderSend(Symbol(),OP_SELLSTOP,Lot,OpenPrice-TP*Point,0,SL*Point,TP*Point,"",MAGIC,0,Red); // Открытие отложки на покупку в сторону продолжения до открытого ордера
ticket=OrderSend(Symbol(),OP_BUYSTOP,LotSize*2,OpenPrice+DS*Point,0,SL*Point,TP*Point,"",MAGIC,0,Blue); // Открытие отложки на покупку в противополжну сторону до открытого ордера
}
This is better.
Files:
 
Sergstuddek:

I can't see the problem with pending orders in the code, I just need to ask why.

In order:

if(OrderSelect(CalculateCurrentOrders1(Symbol()),SELECT_BY_POS,MODE_TRADES)==true && OrderType()==OP_BUY) // Проверка на то что открытый ордер на покупку
int ticket;

OrderSelect has CalculateCurrentOrders1 out of range, the maximum "POS" would be CalculateCurrentOrders1(Symbol())-1. The if construct itself: if the condition is met, do you declare a "ticket" variable? A curly brace is clearly needed somewhere. I just can't even understand what you are trying to do. You are obviously at the beginning of a long way, I could have written it for you, but there is no sense in this code, so it's a "learning task", so you want to do it yourself. And rightly so. If you have more specific questions, we will be glad to help.

I got confused by your brackets myself, so I fixed the post.

 
prom18:

Can you suggest a script or an EA to display information on the screen (spread, stop level, open trades, profit on trades, profit for the day, etc.)? Thank you.

Everything except the spread display is in the tabs of the terminal. I doubt that the script displays it more clearly.

And spread in pips can be displayed on a chart through an additional line in the EA:

Comment((Ask - Bid) / Point);

 
Sorento:

I am proud to know you.

it's not a pity to take the time to chew on everything.

Way to go!

Thanks!



Me too.

sergeev - respect and respect)))

P.S. Sorry if I'm a bit off-topic))

 
Figar0:

In order:

OrderSelect has CalculateCurrentOrders1 out of range, the maximum "POS" would be CalculateCurrentOrders1(Symbol())-1. The if construct itself: if the condition is met, do you declare a "ticket" variable? A curly brace is clearly needed somewhere. I just can't even understand what you are trying to do. You are obviously at the beginning of a long way, I could have written it for you, but there is no sense in this code, so it's a "learning task", so you want to do it yourself. And rightly so. If you have more specific questions, we will be glad to help.

Z.I. I got confused by your brackets myself, I have corrected the post.

Thank you very much for pointing out my message.

The idea is probably much simpler than my code)))) The idea of this code is to set the pending orders relative to the last open order, respectively relative to the opening price and volume of the last order already open.

Reason: