guide for a sample expert in mql5.com about number of bars,5-digit or 3-digit price chart and magic number

 
hi everyone.

Im trying to write an expert advisor and Im reading a sample in this link. (https://www.mql5.com/en/articles/100)

in this sample say we have to check if we have at least 60 bars or not.

I cant understand why. because we always have more than 60 bars.  

also they defined a magic number. what is it? why we need that?

In another part they use these codes: 

 STP = StopLoss;
   TKP = TakeProfit;
   if(_Digits==5 || _Digits==3)
     {
      STP = STP*10;
      TKP = TKP*10;
     }


and explain that by this sentence:  Digits or Digits() returns the number of decimal digits determining the accuracy of price of the current chart symbol. For a 5-digit or 3-digit price chart, we multiply both the Stop Loss and the Take Profit by 10.

why we need to multiply to 10 in 5-digit or 3-digit price chart?

it would be appreciated if you could guide me.

thanks
Step-By-Step Guide to writing an Expert Advisor in MQL5 for Beginners
Step-By-Step Guide to writing an Expert Advisor in MQL5 for Beginners
  • www.mql5.com
This article is aimed at beginners who wish to learn how to write simple Expert Advisors in the new MQL5 language. We will begin first by defining what we want our EA (Expert advisor) to do, and then move on to how we want the EA to do it. 1. Trading Strategy It will monitor a particular indicator, and when a certain condition is met (or...
 
ramin Beygi:
in this sample say we have to check if we have at least 60 bars or not. I cant understand why. because we always have more than 60 bars.  

also they defined a magic number. what is it? why we need that?

why we need to multiply to 10 in 5-digit or 3-digit price chart?
  1. You usually have more than 60. Try switching to the Mn1. What happens (in the code) if you don't? EAs must be coded to recover.

  2. Magic number only allows an EA to identify its trades from all others. Using OrdersTotal/OrdersHistoryTotal (MT4) or PositionsTotal (MT5), directly and/or no Magic number filtering on your OrderSelect / Position select loop means your code is incompatible with every EA (including itself on other charts and manual trading.)
              Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 programming forum
              PositionClose is not working - MQL5 programming forum
              MagicNumber: "Magic" Identifier of the Order - MQL4 Articles

  3. PIP, Point, or Tick are all different in general.
              What is a TICK? - MQL4 programming forum

    Unless you manually adjust your SL/TP for each separate symbol; using Point means code breaks on 4 digit brokers, exotics (e.g. USDZAR where spread is over 500 points,) and metals. Compute what a PIP is and use it, not points.
              How to manage JPY pairs with parameters? - MQL4 programming forum
              Slippage defined in index points - Currency Pairs - Expert Advisors and Automated Trading - MQL5 programming forum