Printing Excersise

 

From the Expert Adviser Wizard, I have selected custom indicator and only put this print line on it. I dropped it on a chart which has an EA running and a trade progressing opened by that EA. I got nothing printed on the chart. Is it because of the magic # or something else? Can you tell me what I can do to make it print the total number of opened and pending orders?

int start()
  {
   Print (OrdersTotal());
   return(0);
  }

Thanks,

 
tapo:

Can you tell me what I can do to make it print the total number of opened and pending orders?

Print doesn't print to the screen it prints to the Experts tab (Journal tab if running in the Strategy Tester) https://docs.mql4.com/common/Print if you want to "print" to the screen try Comment : https://docs.mql4.com/common/Comment or if you want to control the position use Objects : https://docs.mql4.com/objects
 
Thank you Raptor. comment worked.
 

Доброго времени суток уважаемые форумчане!

Меня зовут Герман, мне 23 года, я являюсь трейдером компании "Инстафорекс"

Помогите в поиске нужного скрипта! Скрипт нужен для сетки отложенных ордеров.

 

I have a demo account with a 5 digit broker, and been trying to print the ask and bid on the chart. When I code

Comment(Ask, " ", Bid);

I get the numbers rounded to 4 digits, but when I code

Comment(Ask + " " + Bid);

I get them rounded to 8 digits! and the last 3 digits of them are 0s.

What's the right or standard syntax in which we print stuff in mql?

Regards,

tapo

 

Use https://docs.mql4.com/convert/DoubleToStr

Comment("Ask: ", DoubleToStr(Ask, Digits), " Bid: ", DoubleToStr(Bid, Digits));
 
tapo:
What's the right or standard syntax in which we print stuff in mql?
Print/Alert/Comment defaults to 4 digits. You must adjust for 4/5 digit brokers.
string  PriceToStr(double p){ return( DoubleToStr(p, Digits) ); }
//or
string  PriceToStr(double p){
    string pFrc = DoubleToStr(p, Digits);       if(Digits.pips==0) return(pFrc);
    string pPip = DoubleToStr(p, Digits-1);
    if (pPip+"0" == pFrc)       return(pPip);           return(pFrc);          }
//with
//++++ These are adjusted for 5 digit brokers.
int     pips2points;    // slippage  3 pips    3=points    30=points
double  pips2dbl;       // Stoploss 15 pips    0.015      0.0150
int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)
int     init(){
     if (Digits % 2 == 1){      // DE30=1/JPY=3/EURUSD=5 https://www.mql5.com/en/forum/135345
                pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
    } else {    pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; }
    // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
//---- These are adjusted for 5 digit brokers.
    /* On ECN brokers you must open first and THEN set stops
    int ticket = OrderSend(..., 0,0,...)
    if (ticket < 0)
       Alert("OrderSend failed: ", GetLastError());
    else if (!OrderSelect(ticket, SELECT_BY_TICKET))
       Alert("OrderSelect failed: ", GetLastError());
    else if (!OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0)
       Alert("OrderModify failed: ", GetLastError());
     */
 

Thank you!

WHRoeder, please see my reply on the other thread.

 

Hi guys,

I added the following block of code to an EA and backtested it. I can find neither the log file nor tester\files folder!!

Can you help?

   int handle = FileOpen("Log.txt", FILE_CSV|FILE_WRITE, ';');
   if (handle > 0)
   {
      FileWrite(handle, Close[0]);
      FileClose(handle);
   }
 

check if there is some error

if (handle < 0) Print ("Error Opening File");
 

to avoid filling my Expert tab with printings, I put the following line within the if statement and got the the sentence printed on the chart all the way through the backtest

Comment("handle is greater than 0.");

that means there was no error. The strange thing is that I'm not finding the tester\files folder in the first place. It's not only the file which is missing.

Reason: