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

 
anton777:

I will explain how to write MQL4 code in MQL4 Expert Advisor. An order is opened on zero bar, i.e. on the current bar. The indicators will close it on the signal on THIS current bar ( 0 ). I need them to close it in a new bar or in subsequent bars, BUT not this one where it opened. Thanks in advance.


Remember the time of the bar at which the order was opened and until the zero bar time has changed, do not take any action, something like this:

datetime t0;
// обьявим переменную t0 глобальной - в самом верху кода
int init(){
// проинизилизируем пременную t0, чтобы при первом вызове 
// ф-ции start() выполнить необходимые действия
   t0 = 0;
....
}

int start(){
if(t0!=Time[0]){
// новый бар, выполняем действия при появлении 
// нового бара
//........


// в самом конце проверки условия запоминаем новое время нулевого бара   
   t0=Time[0];
...
}
 
IgorM:


remember the time of the bar at which the order was opened and do not take any action until the time of the zero bar has changed, approximately like this:


Just what I need! Thank you Igor. I do not know yet what to do with the code.
 
Doberman101:

Why such a negative response? A grown man... and no one has taught you respect in life?
That's the end of the despute. I treat my elders with respect, no matter how "rotten" they are.

Respectful to call your elders rotten? Don't be a hypocrite, you don't have a shred of respect. They tried to make it clear to you that the question "Help me write my advisor" is being directed to an empty space because it contains nothing but a question mark. Formulate your question in as much detail as possible and get an answer if you learn to ask it respectfully.
 
Hello all! Please tell me if there is a script, so that each transaction was accompanied by an arrow at the opening and closing, as well as the line at the closing? Well, as in testing ... I've already got sick of googling! Damn. Already started quietly myself from other scripts to collect :))) I built a script that opens the deal;)but I can't find any ready-made one.... Please help me!!!
 

Somebody answer me, this is the third time I've written.

How should we make the orders open and close at regular intervals during the whole week?

If we run the Expert Advisor in the middle of the week, the orders should also open in the same intervals with the start of counting from the beginning of the week.

At least give us some code or script for the example.

 
r.ig.h:

Somebody answer me, this is the third time I've written.

How should we make the orders open and close at regular intervals during the whole week?

If we run the Expert Advisor in the middle of the week, the orders should also open in the same intervals with the start of counting from the beginning of the week.

At least give us some code or script for the example.

The solution will not be written down, and no one will specify what you need either.
 

Hm, ok.

I want for example in Mon an order was opened (no matter where, or any action happened simply), after, say, 9 hours the order was closed and a new one was opened, after another 9 hours the old one was closed and a new one was opened immediately and so it continued until the end of trading on Friday.

Everything will be restarted in Mon. If we launch the Expert Advisor on Wednesday, it will calculate these timeframes in 9 hours from the beginning of the week and make a deal again as soon as the next timeframe is reached. Here.

 

r.ig.h:

I want to open an order in Mon (no matter where, or any action occurred simply), after, say, 9 hours the order closed and opened a new one, after another 9 hours the old one closed and immediately opened a new one, and so it continued until the end of trading on Friday.

Everything will be restarted in Mon. If we launch the Expert Advisor on Wednesday, it will calculate these time slots in 9 hours from the beginning of the week and make a deal again as soon as the next time slot is reached. Here.

Don't you think it is nonsense?

 

No) But still, is it possible to write an algorithm on this nonsense?

Or is there still something unclear in the description?

 
r.ig.h:

No) But still, is it possible to write an algorithm on this nonsense?

Or is there something not clear in the description?


If they tell you to search the forum, will that make you feel better? ;)

As for the subject - if you need a clock, it is optimal to take the opening time of a bar and analyse the opening hour to make a decision,

you can use the tutorial https://book.mql4.com/ru/functions/datetime

Reason: