Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 594

 

Hello, could you please tell me how to make the indicator in the tester work with data of another currency pair?

The picture shows a normal MACD, but with the "GBPUSD" symbol written on it. On the "EURUSD" chart, it's drawing exactly the same way as on the "GBPUSD" chart.

But it does not want to work in the Strategy Tester. When I press pause and place indicator on EURUSD chart, at first everything is drawn correctly, but as soon as I start test

It just draws a straight line like in the picture. Or maybe you can tell me another indicator that works. It's not the MACD that is important but the principle of drawing.

Files:
 
Who is able to use oil futures (#BRNM4) in the tester? I get error 4107.
 

Can you tell me how to write the current time into a global variable GlobalVariableSet, for example? It doesn't give out the date at all but a set of digits...

 
ClanVi:

Can you tell me how to write the current time into a global variable GlobalVariableSet, for example? It doesn't give out the date at all but a set of digits...


Time is stored as an integer value
 

Hello. Happy Victory Day, everyone!

With the new build, the objects in the bottom right corner have crawled to the right. It is necessary to move them slightly to the left so that all the text in them was readable.

As it was and as it should be done:

Now they have crawled away:

Code:

#include <stdlib.mqh>
#include <stderror.mqh>
#include <WinUser32.mqh>
//--------------------------------------------------------------- 3 --
#include <Variables_AU.mqh>          // Описание переменных 
#include <Terminal.mqh>              // Учёт ордеров
#include <Events.mqh>                // Функция слежения за событиями, обновлен.
#include <Inform.mqh>                // Информационная функция
#include <Trade.mqh>                 // Торговая функция
#include <Open_Ord.mqh>              // Открытие одного ордера заданного типа
#include <Open_Ord_balance_line.mqh> //Доливка по линии баланса -  установка одного отложенного ордера  
#include <Close_All.mqh>             // Закрытие  всех ордеров заданного типа
#include <Tral_Stop_All.mqh>         // Модификация лимитного ордера
#include <Lot_MM.mqh>                // Вычисление количества лотов
#include <Criterion.mqh>             // Торговые критерии
#include <Errors.mqh>                // Функция обработки ошибок.
//--------------------------------------------------------------- 4 --
int init()                             // Спец. функция init
  {
  
   IsExpertStopped = false;
   if (!IsTradeAllowed())  {Comment("Необходимо разрешить советнику торговать");IsExpertStopped = true; return (0);}      
  // if (!IsTesting()){if (IsExpertEnabled())    Comment("Советник запустится следующим тиком");else  Comment("Отжата кнопка \"Разрешить запуск советников\"");}   
      
   // Определяем переменные окружения
   Level_old=MarketInfo(Symbol(),MODE_STOPLEVEL );//Миним. дистаниция 
   Level_Freeze = MarketInfo(Symbol(),MODE_FREEZELEVEL ); 
   Spread = MarketInfo(Symbol(),MODE_SPREAD);
   Tick = MarketInfo(Symbol(), MODE_TICKSIZE);    //Mинимальный тик   
   // Пересчеты пунктов для пятизначного ДЦ   
   if ((Digits == 3) || (Digits == 5)){SlipPips = SlipPips*10; indent_Hight = indent_Hight * 10; indent_Low = indent_Low * 10;}    
  
   Terminal();                         // Функция учёта ордеров 
//----------------------------------------------Мониторинг---------------------  
   if(Monitor==true)
    {
    int a,y;
    for(a=0,y=5;a<=4;a++)
      {
      string N=DoubleToStr(a,0);
  
      ObjectCreate(N,OBJ_LABEL,0,0,0,0,0,0,0);
      ObjectSet(N,OBJPROP_CORNER,3);
      ObjectSet(N,OBJPROP_XDISTANCE,5);
      ObjectSet(N,OBJPROP_YDISTANCE,y);
      y+=20;
      }  
    }
      
   return(0);                             // Выход из init() 
  }
//-----------------------------------------------------------------------------
int start()                            // Спец. функция start
  {  
     
//------------- Вызов ф-ий учёта ордеров, принятия торговых решений и информации ----------   
  Terminal();                         // Функция учёта ордеров 
  Events();                           // Информация о событиях
  Trade (Criterion());                // Торговая функция
  Inform(0);                          // Для перекрашивания объектов
   
//-------------  МОНИТОРИНГ  --------------------------------------------------------------
  if(Monitor==true)
    {
     string str="Balance: "+DoubleToStr(AccountBalance(),2)+" $";
     ObjectSetText("0",str,10,"Arial Black",DarkOrange);
    
     str="Profit: "+DoubleToStr(AccountProfit(),2)+" $";
     ObjectSetText("1",str,10,"Arial Black",Salmon);
    
     str="Free Margine: "+DoubleToStr(AccountFreeMargin(),2)+" $";
     ObjectSetText("2",str,10,"Arial Black",Gold);
    
     str="OrdersTotal: "+DoubleToStr(OrdersTotal(),0);
     ObjectSetText("3",str,10,"Arial Black",MediumAquamarine);
    
     if (Lot_MM()==false)              // Средств не хватает на миним.
             return(0);                   // Выход из пользов. функции 
     str="Lots_Next: "+DoubleToStr(Lots_New,2);
     ObjectSetText("4",str,10,"Arial Black",Olive);
    }
   
   return(0);                             // Выход из start()
  }
//-------------------------------------------------------------------------------------------
int deinit()                           // Спец. функция deinit()
  {
   Inform(-1);                         // Для удаления объектов
   //----------------------------------------------------------------------------------------
  if(Monitor==true)
    {
    for(int a=0;a<=4;a++)
      {
      string N=DoubleToStr(a,0);
      ObjectDelete(N);
      } 
    }
//-------------------------------------------------------------------------------------------
   return(0);                             // Выход из deinit()
  }
//-------------------------------------------------------------------------------------------
 

I managed it myself by changing the reference angle and setting the coordinate distances:

//----------------------------------------------Мониторинг---------------------  
   if(Monitor==true)
    {
    int a,y;
    for(a=0,y=50;a<=4;a++)
      {
      string N=DoubleToStr(a,0);
  
      ObjectCreate(N,OBJ_LABEL,0,0,0,0,0,0,0);
      ObjectSet(N,OBJPROP_CORNER,0);
      ObjectSet(N,OBJPROP_XDISTANCE,50);
      ObjectSet(N,OBJPROP_YDISTANCE,y);
      y+=20;
      }  
    }
      
   return(0);                             // Выход из init() 
  }


 

And how do you change the size and background (colour is probably unlikely) of object comments?


Well the Start # ticket number in the picture is theirs.

Function:

//+------------------------------------------------------------------+
   void SetTLine(color cl, long chartID, int wnd, string nm,
                 datetime t1, double p1, datetime t2, double p2,
                 bool ry=False, int st=0, int wd=1,string tx="",int sz=0) {
      if(DrawGraphics==0) return;
      if (ObjectFind(nm)<0) ObjectCreate(chartID, nm, OBJ_TREND, wnd, 0, 0, 0, 0);
      ObjectSetInteger(chartID,nm,OBJPROP_TIME1,t1);
      ObjectSetDouble(chartID,nm,OBJPROP_PRICE1,p1);
      ObjectSetInteger(chartID,nm,OBJPROP_TIME2,t2);
      ObjectSetDouble(chartID,nm,OBJPROP_PRICE2,p2);
      ObjectSetInteger(chartID,nm,OBJPROP_COLOR,cl);
      ObjectSetInteger(chartID,nm,OBJPROP_RAY,ry);
      ObjectSetInteger(chartID,nm,OBJPROP_STYLE,st);
      ObjectSetInteger(chartID,nm,OBJPROP_WIDTH,wd);
      ObjectSetString(chartID,nm,OBJPROP_TEXT,tx);
      ObjectSetString(chartID,nm,OBJPROP_FONT,"Tahoma");
      ObjectSetInteger(chartID,nm,OBJPROP_FONTSIZE,sz);
   }
//+------------------------------------------------------------------+

Last three, parameters thought they affect somehow. No way...

 
pako:


This is a text object. But I need to change it in OBJ_TREND. I would like to be able to do this in one object, instead of adding another text object to the trend line.
 

The Debugger has stopped working - why?

Since the middle of the day on 5 May, the Debugger has stopped giving out variable values at the breakpoint. In all programs for all variables. At the same time, the programs themselves work as before. At that time (and until now) Editor was "ver. 5.00 build 934" and MetaTrader "ver. 4.00 build 646" .

Here is a simple script, and this is what the Debugger shows. Can you please tell me what's wrong?

 
realgentleman:

The Debugger has stopped working - why?

Since the middle of the day on 5 May, the Debugger has stopped giving out variable values at the breakpoint. In all programs for all variables. At the same time the programs themselves work as before. At that time (and until now) Editor was "ver. 5.00 build 934" and MetaTrader "ver. 4.00 build 646" .

Here is a simple script, and this is what the Debugger shows. Can you please tell me what's wrong?