[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 339

 
future >> :
Gentlemen, I'm still agonizing over a question. How to write the following? If the price at xx.xx of the current day is higher than the price at yy.yy of the same day....then...I need these prices to be compared every day. I don't know how to avoid mentioning the date. Tried datetime Time 1=D'().().() 12:00 '; but it doesn't work in tester. Doesn't write errors, but when testing it feels like this time data is just ignored.

It works like this:

int time=iTime(NULL,PERIOD_D1,0)+60*(60*hours+minutes);

double price=iOpen(NULL,PERIOD_M1,iBarShift(NULL,PERIOD_M1,time));

 


I am following exactly this article, but as I said above,

channel=ddeinit('MT4','BID'); - everything is fine, channel = 7.2920e-304 - connection is established

but

rc = ddeadv(channel, 'EURUSD','disp(x)','x',[1 1]); - nothing happens,

in spite of rc = 1.

Although it seems to work in the article. what is wrong?

 


Hi!

Could you please tell me how to keep track of when a trade closes at stop loss or profit in the loop?

What function should be used to do it correctly?

Thank you.

 
Klinskih писал(а) >>

Hi!

Could you please tell me how to keep track of when a trade closes at stop loss or profit in the loop?

What function should be used to do it correctly?

Thank you.

There is no event for closing orders at stop loss or take profit, but you can monitor the availability of open orders.

int OrdersTotal( )

Returns the total number of open and pending orders.

bool OrderSelect( int index, int select, int pool= MODE_TRADES) 

The function selects an order for further processing. Returns TRUE if the function completes successfully. Returns FALSE if the function fails. To get the information about the error, you need to call the GetLastError() function.
The pool parameter is ignored if the order is selected by the ticket number. The ticket number is a unique identifier for the order. To determine from which list an order is selected, we should analyze its closing time. If the time of closing of the order is 0, then the order is open or pending and is taken from the list of open positions of the terminal. An open position can be distinguished from a pending order by its type. If the time of closing is not equal to 0, then the order is closed or pending and has been selected from the history of the terminal. The distinction between a closed order and a deleted pending order can also be made by order type.

You can also find ready-made solutions, for example from KimIV - https://www.mql5.com/ru/forum/107476/page2.

 
xeon >> :

There is no event to close the order at stop or takeout, but you can monitor the availability of open orders

Returns the total amount of open and pending orders.

This function selects an order to work with it. Returns TRUE if the function completes successfully. It returns FALSE if the function fails. To get the information about the error, you need to call the GetLastError() function.
The pool parameter is ignored if the order is selected using the ticket number. The ticket number is a unique identifier for the order. To determine from which list an order is selected, we should analyze its closing time. If the time of closing of the order is 0, then the order is open or pending and is taken from the list of open positions of the terminal. An open position can be distinguished from a pending order by its type. If the time of closing is not equal to 0, then the order is closed or pending and has been selected from the history of the terminal. The difference between a closed order and a deleted pending order can also be made by the order type.

You can also see ready-made implementations, e.g. from KimIV - https://www.mql5.com/ru/forum/107476/page2

Thank you so much for the comprehensive answer!

 
xeon >> :

There is no event to close the order at stop or takeout, but you can monitor the availability of open orders

Returns the total amount of open and pending orders.

This function selects an order to work with it later. Returns TRUE if the function completes successfully. It returns FALSE if the function fails. To get the information about the error, you need to call the GetLastError() function.
The pool parameter is ignored if the order is selected by the ticket number. The ticket number is a unique identifier for the order. To determine from which list an order is selected, we should analyze its closing time. If the time of closing of the order is 0, then the order is open or pending and is taken from the list of open positions of the terminal. An open position can be distinguished from a pending order by its type. If the time of closing is not equal to 0, then the order is closed or pending and has been selected from the history of the terminal. The difference between a closed order and a deleted pending order can also be made by the order type.

You can also see ready-made implementations, e.g. from KimIV - https://www.mql5.com/ru/forum/107476/page2

Thank you so much for the comprehensive answer!

 
future >> :
Gentlemen, I am still agonising over a question. How to write the following? If the price at xx.xx of the current day is higher than the price at yy.yy of the same day....then...I need these prices to be compared every day. I don't know how to avoid mentioning the date. Tried datetime Time 1=D'().().() 12:00 '; but it doesn't work in tester. Doesn't write errors, but when testing it feels like this time data is just ignored.

For the tester it's ok.

int час=15; час2=20;
int мин=21; мин2=00;

if(Hour()> час-1&&Hour()< час+1&&Minute()> мин-1&&Minute()< мин+1)
double цена_инструмента=Bid;
if(Hour()> час2-1&&Hour()< час2+1&&Minute()> мин2-1&&Minute()< мин2+1)
double цена_инструмента2=Bid;

if( цена_инструмента> цена_инструмента2)....
if( цена_инструмента< цена_инструмента2)....
 

Hello.

How do I know if the SL or TP is triggered. For example, if an order is closed by

SL or TP, then execute this and that. I didn't find such a function.

 

Suppose, a set of Indicators was saved in the Template and the Template was loaded for a currency pair.

- After that, do the Indicators in this window have any relation to the parameters saved in the Template or they become completely independent?

 
chief2000 >> :

Suppose, a set of Indicators was saved in the Template and the Template was loaded for a currency pair.

- Do the Indicators in this window have any relation to the parameters saved in the Template or they become completely independent?


The saved pairs are "entered" into the indicators once at the initialization of the template, then "they become completely independent".

All the changed indicator parameters are saved in the template, if you have changed the indicator parameters, resave the template.