Experts: N seconds N points

 

N seconds N points:

The Expert Advisor tracks positions of all symbols with all magic numbers. If a position has been open for "Waiting for seconds" and its profit has reached "Take Profit" points, the EA closes the position. If the profit has not reached "Take Profit" points, the EA moves the take profit level.

Author: Vladimir Karputov

 

Thanks, that's what I need.

But I don't understand the point "If the profit has not reached "Take Profit" points - then it transfers the level of take profit". Where exactly does it move TP?

Is there a version for MT4?

 
Valeriy Belozertsev:

Thanks, that's what I need.

But I don't understand the point "If the profit has not reached the "Take Profit" points - then it transfers the take profit level". Where exactly does it move TP?

Is there a version for MT4?


Adherents of the old terminal are deprived of support. As a punishment for laziness.

 
Valeriy Belozertsev:

Only I don't understand the point "If the profit has not reached the "Take Profit" points - then it transfers the take profit level". Where exactly does it move TP?

It's a mystery.
 
Vladimir Karputov:

Adherents of the old terminal have been deprived of support. As punishment for laziness.

That cut it.

 
Vladimir Karputov:

Adherents of the old terminal have been deprived of support. As punishment for laziness.


"Our answer to Chamberlain".

Without the support of "MT4 adepts" your codes will remain the best examples of "how not to do it better"

void OnTimer()
  {
//---
   for(int i=PositionsTotal()-1;i>=0;i--)
      if(m_position.SelectByIndex(i)) // selects the position by index for further access to its properties
         if(TimeCurrent()-m_position.Time()>InpSeconds)
           {
            double ExtTakeProfit=0;
            double m_adjusted_point;               // point value adjusted for 3 or 5 points
            if(!InitTrade(m_position.Symbol(),m_position.Magic(),m_adjusted_point,ExtTakeProfit))
               continue;
...
  }
//+------------------------------------------------------------------+
//| Init trade object|
//+------------------------------------------------------------------+
bool InitTrade(const string symbol,const ulong magic,double &adjusted_point,double &ext_take_profit)
  {
...
//--- tuning for 3 or 5 digits
   int digits_adjust=1;
   if(m_symbol.Digits()==3 || m_symbol.Digits()==5)
      digits_adjust=10;
   adjusted_point=m_symbol.Point()*digits_adjust;

   ext_take_profit=InpTakeProfit*adjusted_point;
//---
   return(true);
  }


Significance of quotes (5-digit) is known already at the OnInit() stage and it is not necessary to perform and execute them at the analysis of each position

 
Andrey F. Zelinsky:

"Our answer to Chamberlain".

Without the support of "MT4 adepts" your codes will remain the best examples of "how best not to do it"


Significance of quotes (5-digit) is known already at the OnInit() stage and it is not necessary to execute and perform them at the analysis of each position


Usually I do it this way: I define the digits once in OnInit(), but in this Expert Advisor there is a possible variant when positions for completely different symbols are opened in the terminal. Therefore, for each position I have to be safe and define the digit capacity.

 
Vladimir Karputov:

... but in this Expert Advisor there is a possibility that positions for completely different symbols are opened in the terminal. That is why for each position we have to be hedged and determine the digitisation.


Have you ever met any trading account where the digits of quotes (5-digit and 4-digit) were different for different symbols?

 
Andrey F. Zelinsky:

Significance of quotes (5-digit) are known already at the OnInit() stage and they do not need to be performed and executed at the analysis of each position

I could not understand why many people use such constructions (I have come across them many times) - they look at point/digits to do something with them additionally.

There must be a sense, but I could not realise why they write it this way. After all, it came from someone.

 
Andrey F. Zelinsky:

Have you ever come across a single trading account where the value of quotes (5-digit and 4-digit) were different for different symbols?


There are plenty of examples (you just need to lift the blinders from your eyes and look wider and wider). I'll wait until you realise :)

 
fxsaber:

I have never been able to understand why many people use such constructions (I have come across them more than once) - they look at point/digits to do something extra with them.

There must be a point, but I couldn't realise why they write like that. After all, it came from someone.


The logic there is simple -- 1) to make the same settings suitable for different digits and 2) many people are just more used to 4 digits.

It's just that some people use it correctly and unobtrusively, while others use it ugly.