Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 676

 

Artyom Trishkin:

It looks like I've overworked...

Looks like... ))))))

When you create an EA according to the instructions in the help and tutorials of all sorts, it creates exactly the template in question. That's how I understood it. Then some places in this template are corrected. I personally do not like that OnDeinit() stands before OnTick() and I move it to the very end of the code. And I also don't like some non-essential .... Anyway, I've got my own little bugs in my head...

 
Andrey Sokolov:

It's obvious, I'm also interested in the template itself

about 5 years ago, exactly was a template in the folder metaeditora, before rules for myself, now dug all in the folder terminal - have not found, but it should be somewhere, there was a plain text file

ZS:

found my old terminals, not in distribution - already deployed

there used to be expert templates/indicators/scripts/libraries, everything was on the way:

....\experts\templates

and the files were located there:

Include.mqt

Library.mqt

Expert.mqt

Indicator.mqt

Script.mqt


I tried to copy the templates folder to the folder of installed MT4... no luck (((

Files:
templates.zip  7 kb
 
Igor Makanu:

about 5 years ago there was a template in the meta editor folder, I used to edit it for myself, now I've searched the terminal folder and couldn't find it, but it must be somewhere, it was just a text file

ZS:

found my old terminals, not in distribution - already deployed

there used to be expert templates/indicators/scripts/libraries, everything was on the way:

....\experts\templates

and the files were located there:

Include.mqt

Library.mqt

Expert.mqt

Indicator.mqt

Script.mqt


I tried to copy the templates folder to the folder of installed MT4... no luck (((

It's a long time since the MCs abandoned such templates.

 
Igor Makanu:

about 5 years ago there was a template in the meta editor folder, I used to edit it for myself, now I've searched the terminal folder and couldn't find it, but it must be somewhere, it was just a plain text file

ZS:

found my old terminals, not in distribution - already deployed

there used to be expert templates/indicators/scripts/libraries, everything was on the way:

....\experts\templates

and the files were located there:

Include.mqt

Library.mqt

Expert.mqt

Indicator.mqt

Script.mqt


I tried to copy the templates folder to the folder of installed MT4... Alas, nothing (((

Alas, again "alas, nothing" - even within MT4!

I do not understand what is going on!

Igor!

You need to "upgrade"!

Otherwise, it would not be good! They say different things about you at the Forum!!!

 
Igor Makanu:

It doesn't matter what people say about you, what matters is what people say about you. (С)

When quoting the thoughts of intelligent people (as opposed to yourself) - you should make a reference!!!

According to the rules of publications it must be so. To distinguish the fools from the smart ones.

https://socratify.net/quotes/iuristy-bostona/171580

Although Mussolini said the same thing.

Не важно, что о тебе говорят, главное, что о тебе говорят
  • socratify.net
Если хочешь узнать человека, не слушай, что о нём говорят другие, послушай, что он говорит о других. Не важно, что тебе скажут другие о начале твоего пути. Важно, что они скажут после того когда ты добьешься своей цели. Вы знаете, что такое обаяние? Умение почувствовать, как тебе говорят «да», хотя ты ни о чем не спрашивал. Настоящий друг — это...
 
neverness:

When quoting the thoughts of intelligent people (unlike yourself), you should make a reference!!!

That's the way it's supposed to be by the rules of publishing. To distinguish the fools from the smart ones.

Are we on a first-name basis now? OK

You chose the wrong forum to vent your bile, as you asked: "It's funny to watch a man who wants to offend you. Like a monkey throwing poo. You're behind the glass and he's got all his paws in the ***" (internet)

 
Igor Makanu:

SELECT_BY_POS is to select an order "by order" in the order list, and in your design:

You are trying to select an order that is by order queue # ... and you are using ticket no. here, and you have only 1 order and ticket no. 10023444... so what ? here you need a number from 1 to 2,3 ... well, how many orders you have in the market ,... corrected the number from 0,1,2 ... - Numbering starts with 0 and goes up toOrdersTotal()-1...

SELECT_BY_TICKET should work, but only up to the moment when you have the ticket number, i.e. the order you have in the market, and above you have a check for order sending, and if the order is not sent, the ticket = -1 !

And all in all, your design for working with orders is not correct. If you decided to study MQL, here are ready-made examples for working with ordershttps://www.mql5.com/ru/forum/131859

Thanks for the help! The thing is, the order did open. I checked. The ticket was assigned. But further on when trying to select it I got a -1 message. Unlike the example you gave, I am not selecting a symbol etc. I have 1 order, with a known lot, transaction, no Stop Loss/Take Profit etc. It is in this design (it is chosen for simplicity) that I get a 4051 error when using the SELECT_BY_TICKET parameter. I understand that using SELECT_BY_POS in this case is not correct. This was an experiment to better understand how the strategy tester works. This experiment showed that the strategy tester doesn't assign tickets allocated by the server when it cannot contact the server, but simply assigns ordinal numbers. Nevertheless, the question remains why the 4051 error occurs. In addition I tried putting 0 in OrderSelect in combination with SELECT_BY_POS as the first parameter. The answer is the same 4051.
 
ski1973:
Thanks for the help! The thing is, the order did open. I checked. A ticket was assigned. But further I got a -1 message when trying to select it. Unlike the example you gave, I am not selecting a symbol etc. I have 1 order, with a known lot, transaction, no Stop Loss/Take Profit etc. It is in this design (it is chosen for simplicity) that I get a 4051 error when using the SELECT_BY_TICKET parameter. I understand that using SELECT_BY_POS in this case is not correct. This was an experiment to better understand how the strategy tester works. This experiment showed that the strategy tester doesn't assign tickets allocated by the server when it cannot contact the server, but simply assigns ordinal numbers. Nevertheless, the question remains as to why the 4051 error occurs. In addition I tried putting 0 in OrderSelect in combination with SELECT_BY_POS as the first parameter. The answer is the same 4051.

If I'm not mistaken, the strategy tester generates tickets simply by order queue: 1,2,3...

alas, you need to look for error 4051 yourself, reprint all variables that you pass to OrderSelect

Alternatively, you have already selected a closed order and the closing time of the closed order will be >0,

But still I would advise to start studying with already existing (working) codes, it was easier for me!

 
ski1973:
Thank you for your help! The thing is, the order did open. I checked. The ticket was assigned. But further on when trying to select it I got a -1 message. Unlike the example you gave, I am not selecting a symbol etc. I have 1 order, with a known lot, transaction, no Stop Loss/Take Profit etc. It is in this design (it is chosen for simplicity) that I get a 4051 error when using the SELECT_BY_TICKET parameter. I understand that using SELECT_BY_POS in this case is not correct. This was an experiment to better understand how the strategy tester works. This experiment showed that the strategy tester doesn't assign tickets allocated by the server when it cannot contact the server, but simply assigns ordinal numbers. Nevertheless, the question remains as to why the 4051 error occurs. In addition I tried putting 0 in OrderSelect in combination with SELECT_BY_POS as the first parameter. The answer is the same 4051.

You have a problem in your code.

double Lots=0.01;
int slippage=30;


void OnTick()
{
int numer=-10;//На каждом новом тике из за этого присвоения процедура Subr2 будет возвращать ошибку!!!
if(OrdersTotal()==0)numer=Subr1();
if(OrdersTotal()>0)Subr2(numer);
return;
}

int Subr1()
{
int result=-1;
int_result=OrderSend(_symbol,OP_BUY,Lots,slippage,0,0);
if(int_res<0){PrintFormat("OrderSend error = ",GetError());}
return int_result;
}
void Subr2(int order)
{
if(!OrderSelect(order,SELECT_BY_TICKET,MODE_TRADES)){PrintFormat("OrderSelect error %d",GetLastError());return;} else PrintFormat("Ok, OrderTicket = ",OrderTicket());
}
 
hello, any info on whether mql4 will be supported in the future, when it seems that mt4 sales have stopped?