Questions from Beginners MQL4 MT4 MetaTrader 4 - page 23

 
scomoroh:
Yes, thanks, all fixed, no errors. It slows down, yes, very much. Would you advise which direction to go to optimize it or will you have to rewrite everything?

Too many objects are created and deleted on every tick, it should be limited in some way, for example, not all objects are deleted, but only those drawn on the last 1-2 bars.

For example, in similar case I used such function instead ofObjectsDeleteAll() in start():

void deletelast()
{
   for(int i=ObjectsTotal()-1;i>=0;i--)
   {
      string name=ObjectName(i);
      if(StringFind(name,"Shadows.",0)>-1)
      {
         datetime crtm=(datetime)ObjectGetInteger(0,name,OBJPROP_CREATETIME);
         if(crtm>=iTime(Symbol(),0,1))
         if(!ObjectDelete(name)) Print("ObjectDelete error# ",_LastError);
      }
   }
}
 

Could you tell me if it is possible to manage the trading permission for this EA from the EA?

i.e. to use MQL_TRADE_ALLOWED variable ?

For example if spread is large, then prohibit trade (but not to stop expert advisor)

I just don't know how to set this variable. Direct assignment of 1 or 0 does not work.
 
harbor:

Could you tell me if it is possible to manage the trading permission for this EA from the EA?

i.e. to use MQL_TRADE_ALLOWED variable ?

For example, if spread is large, then prohibit trade (but not to stop the EA)

I just don't know how to set this variable. I can't set it directly to 1 or 0.

This state

https://www.mql5.com/ru/docs/runtime/tradepermission

Документация по MQL5: Программы MQL5 / Разрешение на торговлю
Документация по MQL5: Программы MQL5 / Разрешение на торговлю
  • www.mql5.com
Программы MQL5 / Разрешение на торговлю - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 

But it is possible to control it.

You just have to make a program algorithm.

At any point in the algorithm and under any condition, you can exit the program with the command

return(0);
 
Hello! I am new to this difficult business and am constantly facing new obstacles. I am trying to write an EA, but I cannot solve the problem with the timeframe of the indicator that my EA uses to enter. The essence of the problem is the following: According to the conditions, I need that on the 15-minute time frame on the indicator Stochasstic Signal line was below the level of 20. Exactly at 15 min. TF! In fact, it turns out that the signal line crosses the level 20 in other timeframes (1; 5; 30 min.) and my Expert Advisor works falsely. I need to filter out all of the timeframes, and only leave 15 min. That advisor would not take into account crossovers in other timeframes. I would appreciate any help
 
TimBerg:
Hello! I am new to this difficult business and am constantly facing new obstacles. I am trying to write an EA, but I cannot solve the problem with the timeframe of the indicator that my EA uses to enter. The essence of the problem is the following: According to the conditions, I need that on the 15-minute time frame on the indicator Stochasstic Signal line was below the level of 20. Exactly at 15 min. TF! In fact, it turns out that the signal line crosses the level 20 in other timeframes (1; 5; 30 min.) and my Expert Advisor works falsely. I need to filter out all of the timeframes, and only leave the 15 min. That EA has not considered crossovers on other TFs. I would appreciate your help.
Show a code snippet on how you read the signal from the indicator in your EA
 
Renat Akhtyamov:
Show me a code fragment on how you read the signal from the indicator in your Expert Advisor
I can't remember it from memory, I will show it to you when I get home
 
Renat Akhtyamov:

But it is possible to control it.

You just have to make a program algorithm.

At any point in the algorithm and under any condition, you can exit the program with the command

return(0);

then the program will stop executing, but I need it to continue.

I guess I'd have to make a bunch of conditions.

 
harbor:

then the program will stop executing, but I need it to continue

I guess I'll have to make a bunch of conditions.

What can we continue if the spread has gone up? If you have to continue, what does spread have to do with it?

(c)then prohibit trading (but not stop the EA)= If you prohibit trading, how will it continue to work? What is the point?

 
harbor:

then the program will stop executing, but I need it to continue

I guess I'll have to make a bunch of conditions.

That's right, it's a program.)

Reason: