Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1423

 
mwwm #:

Please advise an example of using this function in EA.

You can look here.

Оцениваем ядра CPU для оптимизации - Попробуйте скомпилировать советники на Phenom 2 x4 975.
Оцениваем ядра CPU для оптимизации - Попробуйте скомпилировать советники на Phenom 2 x4 975.
  • 2022.09.29
  • www.mql5.com
должно получиться 6 результатов оптимизации - приложите логи журнала тестера стратегий. то проведите оптимизацию отдельно в течении часа - интересно сопоставить расчетное время на оптимизацию с реальным. По поводу журнала - вероятно не стоит галка - ставиться по нажатию ПКМ во вкладке Тестера стратегий
 
Hello!
Please help me to understand what I am doing wrong!

As soon as I paste a comment into the below attached code - my robot stops working.
Without the comment - everything works. I change the account to normal and fake.
What am I doing wrong?
   void OnTick()
     {
      if(AccountInfoInteger(ACCOUNT_LOGIN) != 12345678)
         Comment("На этом счете - робот не работает");
      return;
     }
 
Sprut 185 #:
Hello!
Please help me to understand what I am doing wrong!

As soon as I paste a comment into the below attached code - my robot stops working.
Without the comment - everything works. I change the account to normal and fake.
What am I doing wrong?


https://www.mql5.com/ru/search#!keyword=ACCOUNT_LOGIN&module=mql5_module_forum

 
Sprut 185 #:
Hello!
Please help me to understand what I am doing wrong!

As soon as I paste a comment into the below attached code - my robot stops working.
Without the comment - everything works. I change the account to normal and fake.
What am I doing wrong?
 

You forgot the parentheses in the if. If not equal to the score, then comment and then retourn. And if it is not equal to the score, it goes on and hits retourn.

void OnTick()
     {
      if(AccountInfoInteger(ACCOUNT_LOGIN) != 12345678) 
     {
         Comment("На этом счете - робот не работает");
      return;
     }
     }
 
Valeriy Yastremskiy #:

And after that OnTick finishes and waits for the next tick. It doesn't go any further!!!!

Thanks !!! Got it all figured out, fixed it and it works now.

It was just a glitch that went to my head.

 

Can you tell me if it is possible to make a call from the Expert Advisor

void OnTradeTransaction()

from an external file ?

I created a test file *mqh and added it there.

void OnTradeTransaction(const MqlTradeTransaction &trans,

                        const MqlTradeRequest &request,

                        const MqlTradeResult &result)

  {

  }

In the Expert Advisor I added this file

#include <тест.mqh>

But OnTradeTransaction is not called from the Expert Advisor.

How to do it correctly ?

 
TrederMT5 OnTradeTransaction Expert Advisor is not performed.

How to do it correctly ?

I would do the opposite. In the .mqh file write a class, for example CTest in the file test.mqh.

Connecting the class

#include <test.mqh>
CTest onTest;


void CTest::MyOnTradeTransaction(const MqlTradeTransaction &trans,
                                 const MqlTradeRequest &request,
                                 const MqlTradeResult &result)

  {

  }

And from the EA from the OnTradeTransaction function call my function

/*********************TradeTransaction function**********************/
void OnTradeTransaction(const MqlTradeTransaction& trans,
                        const MqlTradeRequest& request,
                        const MqlTradeResult& result)
 {
      onTest.MyOnTradeTransaction(trans, request, result);
 }/******************************************************************/
 
Alexey Viktorov #:

I would do the opposite. In the .mqh file I would write a class, for example CTest in the file test.mqh.

Connecting the class


And from the EA from the OnTradeTransaction function call my function

Thank you
 

I have dared to try a first simple EA and it works flawlessly.

But when I upload it to MQL in the market, I get an error message:


Why is that? Is it due to the netting account?

I have already read some forum posts about this, but I don't understand the problem.

The volume is fixed by the EA. Even 0.01 lot etc. does not work.
Would be grateful for someone to help me out.

 
Maik Kemper error message:


Why is that? Is it due to the netting account?

I have already read some forum posts about this, but I don't understand the problem.

The volume is fixed by the EA. Even 0.01 lot etc. does not work.
Would be grateful for someone to help me out.

It's because of how you calculate the volume (lots) - but without code?

Fixed lot size is probably not a solution, I guess you check with high and low account balance and different margin charges...

Reason: