Questions from Beginners MQL5 MT5 MetaTrader 5 - page 933

 
Vladimir Karputov:

So in the EA discussion thread) you should ask.

I understand the author is from Brazil
 
People don't get the following, why after every time the Terminal is switched off the Toolbar, Tools, Navigator, Market Watch disappear and so I have to constantly manually arrange these things??? Thanks for the help!!!
 
noran919:
People don't get the following, why after every time the Terminal is switched off the Toolbar, Tools, Navigator, Market Watch disappear and so I have to constantly manually arrange these things??? Thank you for your help!

Maybe the terminal is in a directory which is not writable? Looks like it can't overwrite the last profile file.
If so, move the terminal to a directory that you have access to.

 
noran919:
People don't get the following, why after every time the Terminal is switched off the Toolbar, Tools, Navigator, Market Watch disappear and so I have to constantly manually arrange these things??? Thank you for your help!
Have you pressed F11?
 
Please tell me how to write a correct code for indicator to make it calculate not every tick, but every second, if you can show an example, let's say indicator every second add 1+1
 
gonsharov:
Please tell me how to correctly write the code of indicator to make it calculate not every tick, but every second, if you can show by example, let's say the indicator adds 1+1 every second.

Two approaches:

  1. In OnCalculate, estimate the difference between the current time and the last time used: how it works - let's say 2018.09.28 15-30-31 was the last calculation. New tick came - check time - and we still have the same 2018.09.28 15-30-31 - so we don't do anything, and only when current time becomes more than 2018.09.28 15-30-31 - do calculate and remember this time.
  2. Use OnTimer(). I am personally against this method.

 

Faced a similar problem.

//---------

I want to have a remote variable with seconds (for optimizer).

Input ushort Time = 120;

Suppose the time is 120 seconds in this variable.

Next -

void OnTick()

{

Remember the current time.

Check current time.

If time passed over Time , then -

BuyBuff=0;

//----------

Can you give me a code sample? It looks simple in words, but in code it is difficult for me.

 
EgorKim:

Faced a similar problem.

//---------

I want to have a remote variable with seconds (for optimizer).

Input ushort Time = 120;

Suppose the time is 120 seconds in this variable.

Next -

void OnTick()

{

Remember the current time.

Check current time.

If time passed over Time , then -

BuyBuff=0;

//----------

Can you give me a code sample? It looks simple in words, but in code it is difficult for me.

Example:

//+------------------------------------------------------------------+
//|                                      Example Pause in OnTick.mq5 |
//|                              Copyright © 2018, Vladimir Karputov |
//|                                           http://wmua.ru/slesar/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2018, Vladimir Karputov"
#property link      "http://wmua.ru/slesar/"
#property version   "1.00"
//--- input parameters
input int      InpTime=120;   // minimum pause (in seconds)
//---
datetime m_prev_time=0;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- 
   m_prev_time=0;
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   datetime time_0=TimeCurrent();
   if(m_prev_time+InpTime>time_0)
      return;
   m_prev_time=time_0;
   Print(m_prev_time);
  }
//+------------------------------------------------------------------+
 

Thank you very much.

One more request.

Please add this advisor for mt5 to the codebase.

https://www.mql5.com/ru/code/14085

 
EgorKim:

Thank you very much.

One more request.

Please add this advisor for mt5 to the codebase.

https://www.mql5.com/ru/code/14085

1. Completing your posts is a bad thing. Then no one can understand why the topic has been updated, but there is no new post.

2) Study the article:How to copy signals using EAs according to your own rules?

Reason: