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

 
Mickey Moose:


That's right, that's why I want to get it out.

to get the source code from this file is much harder than solving this type of problem)

you can make a cool thing in general: an EA (or whatever you have without sources) will send mail to a nearby chart :-)

just at my leisure did http://luxtrade.tk/atcl:start (forum thread: https://www.mql5.com/ru/forum/224745)

and there in packages is SMTP-server(https://core.tcl.tk/tcllib/doc/tcllib-1-18/embedded/www/tcllib/files/modules/smtpd/smtpd.html)

In other words, you can use Eval("package require smtpd") in the indicator, then set the callback for deliver and receive the necessary mail at once, without leaving MetaTrader, in the same process

ATcl
  • luxtrade.tk
Рад представить вам библиотеку ATcl v1 beta - интерпретатор Tcl для MT4. Расширяте возможности ваших программ MQL, используйте СУБД, дополняйте сетевыми средствами, интегрируйте их с любыми программами используя Tcl.
 
Maxim Kuznetsov:

you could do a fun thing in general: an EA (or whatever you have without source code) will send mail to a neighbouring chart :-)

just did http://luxtrade.tk/atcl:start (forum thread: https://www.mql5.com/ru/forum/224745) at my leisure

and there's an SMTP server in the packages(https://core.tcl.tk/tcllib/doc/tcllib-1-18/embedded/www/tcllib/files/modules/smtpd/smtpd.html)

In other words, you can use Eval("package require smtpd") in an indicator, then specify the callback for deliver and receive the necessary mail at once, without leaving MetaTrader, in the same process

I will try to work it out and if necessary, I will be able to share the results

 
Artyom Trishkin:

This one should just dot the entire history on the distance in bars that you set in the settings.

Thanks, but I'm trying to find out the number of the bar where the arrow is and only then compare it to a 10 (for example) I can't do without a nested loop.

I need to know at the current moment in time which bar the arrow of the called indicator is on.

I guess I'm not very good at expressing myself ). With an example, I think, it will be clearer what I want to do

For example, by a condition if(Open[i+1]>Cloce[i+1]) I want to set Text to High[i+1] with the bar number where the arrow is located
 
Mickey Moose:

I'll try to figure it out, and if I do I can share the results

If you have any questions, you can ask in person or contact me in my profile. I visit the site often, but I don't look at the whole forum - it's hard to keep track of it and I might accidentally miss a question
 

Can you tell me how to implement in MQL5 to close all deals on all currency pairs when they reach a certain profit for all trades, no matter if they are opened by this Expert Advisor or any other way?

I did it like this, is it right?

   if(AccountInfoDouble(ACCOUNT_PROFIT)>profit_close_all)
         for(int i=0; i<OrdersTotal(); i++)
            trade.PositionClose(OrderGetTicket(i),40);
 

Artyom Trishkin, decided. Nested loops are indeed unnecessary. Thank you )

 
Roman Sharanov:

Can you tell me how to implement in MQL5 to close all deals on all currency pairs when they reach a certain profit for all trades, regardless of whether they are opened by this Expert Advisor or any other way?

I did it like this, is it right?

No, it is not. In mql5, OrdersTotal() is the number of pending orders, and the active ones are called positions. Accordingly, the loop should be built by the number of positions, PositionsTotal()
 
Roman Sharanov:

I did this, is it right?

if(AccountInfoDouble(ACCOUNT_PROFIT)>profit_close_all)
         for(int i=PositionsTotal()-1; i>=0; i--)
            trade.PositionClose(PositionGetTicket(i),40);

Something like this.

You are using a loop from zero, while you need to go from more to zero, because you are closing orders right in the loop. And the second, you have already been told to use PositionsTotal().

 
Got it, thanks for the help!
 
Roman Sharanov:
Understood, thanks for the help!

Just don't forget to change OrderGetTicket() to PositionGetTicket() in the highlighted line.

Forum on trading, automated trading systems & strategy testing

Any questions for beginners on MQL4, help and discussion on algorithms and codes

Konstantin Nikitin, 2018.02.03 08:38

if(AccountInfoDouble(ACCOUNT_PROFIT)>profit_close_all)
         for(int i=PositionsTotal()-1; i>=0; i--)
            trade.PositionClose(OrderGetTicket(i),40);

Something like this.

You use the cycle from zero and vice versa, from more to zero, because you close orders right in the cycle. And the second, you have already been told to use PositionsTotal().


Reason: