Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1267

 
Vladimir Karputov:

An indicator for this must have an input colour parameter. That is, it should be a custom indicator.

THANK YOU! but if I don't have access to the source code, it's not feasible?

 
Tango_X:

THANK YOU! But if I don't have access to the source code, it's not implementable?

Yes, you have to have either open source or a ready-made implementation.

 
Vladimir Karputov:

Yes, you need to have either open source code or a ready-made implementation.

When I set the colour clrNONE in the tester, the colour is still displayed! So clrNONE doesn't work in the tester? I can't check it in real life - it's the weekend...

If I set any colour instead of clrNONE, this colour is displayed, but the empty value = does not work... strange...
 
Aleksey Mavrin:

Answer: also repeatedly reload the macro)

But it's better to just use the + operator for strings and convert everything to strings, then you don't need a function (and macro) version with lots of parameters

Thanks. I didn't know that macro can be reloaded.

 
pivomoe:

Thank you. I didn't know the macro could be reloaded.

typo - reload, not reload)

 

sorted out the examples at the end of this help sectionhttps://www.mql5.com/ru/docs/constants/structures/mqltraderequest

on Metacquot server, everything is OK

on another server, after analyzing error codes of trade request, I found out that the problem is in filling MqlTradeResult field :

request.type_filling = ORDER_FILLING_IOC;

a forum search did not find an unambiguous solution - how to determine server settings for the MqlTradeResult field programmatically

ENUM_ORDER_TYPE_FILLING       type_filling;     // Тип ордера по исполнению 


UPD: found a working solutionhttps://www.mql5.com/ru/forum/168912/page2#comment_4062864

@fxsaber thanks!

 
Could you please tell me how to set the Fibo levels for autobuilding?
 
VVT:
Please tell me how to set the Fibo levels for autobuilding

Example in theFibonaci RR code -

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   long chart_id=ChartID();
   datetime time1=ChartTimeOnDropped();
   double price1=ChartPriceOnDropped();
   if(ObjectFind(chart_id,InpFiboName)<0)
      FiboLevelsCreate(chart_id,InpFiboName,0,time1,price1,time1+InpAddSecond,price1-InpStopLoss*Point(),InpColor);
   else
     {
      ObjectDelete(chart_id,InpFiboName);
      ChartRedraw(chart_id);
      FiboLevelsCreate(chart_id,InpFiboName,0,time1,price1,time1+InpAddSecond,price1-InpStopLoss*Point(),InpLevelsColor);
     }
//---
   int               levels   = 6;                                                                    // number of level lines
   double            values[6]= {1.0,0.0,2.0,3.0,4.0,5.0};                                            // values of level lines
   color             colors[6];                                                                       // color of level lines
   for(int i=0; i<6; i++)
      colors[i]=InpLevelsColor;
   ENUM_LINE_STYLE   styles[6];                                                                       // style of level lines
   for(int i=0; i<6; i++)
      styles[i]=InpLevelsStyles;
   int               widths[6]= {2.0,2.0,2.0,2.0,2.0,2.0};                                            // width of level lines
   string            texts[6] = {"BREAK EVEN","STOP LOSS","TP1 1.1","TP2 2.1","TP3 3.1","TP4 4.1"};   // text of level lines
//---
   FiboLevelsSet(levels,values,colors,styles,widths,texts,chart_id,InpFiboName);
  }


can be set for the levels: number of lines, line value, line colour, line style, line width, line text.

 
int OnInit()
  {
//---
   ChartSetInteger(ChartID(), CHART_EVENT_OBJECT_CREATE, true);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
  }
//+------------------------------------------------------------------+

/***********************OnChartEvent function************************/
void OnChartEvent(const int id,         // идентификатор события
                  const long& lparam,   // параметр события типа long
                  const double& dparam, // параметр события типа double
                  const string& sparam  // параметр события типа string
                 )
  {
   if(id == CHARTEVENT_OBJECT_CREATE)
     {
      I++;
      string result[];      //  массив для получения строк
      StringSplit(sparam, ' ', result); //  получим из имени созданного объекта подстроки
      ulong timeCreate = ObjectGetInteger(0, sparam, OBJPROP_CREATETIME); //  получим время создания объекта
      string newName = result[0]+" "+result[1]+" "+string(I); //  сформируем новое имя объекта
      ObjectSetString(0, sparam, OBJPROP_NAME, newName);  //  переименуем объект

      //----------------------------------------------------------------------------------------
      double   Level_0= ObjectGetDouble(
                                0,          // идентификатор графика
                                newName,              // имя объекта
                                OBJPROP_PRICE,           // идентификатор свойства
                                0     // модификатор свойства
                             );


      double   Level_1= ObjectGetDouble(
                                0,          // идентификатор графика
                                newName,              // имя объекта
                                OBJPROP_PRICE,           // идентификатор свойства
                                1     // модификатор свойства
                             );
      //------------------------------------------------------------------------------------------------------
      if(Level_0 > Level_1)
        {
         ObjectSetInteger(0,newName,OBJPROP_COLOR,clrDeepSkyBlue);
        }
      else
        {
         ObjectSetInteger(0,newName,OBJPROP_COLOR,clrYellow);
        }
     }/******************************************************************/
  }

Hi, could you tell me why when debugging the code, going step by step the lines are recoloured in both colours depending on coordinate values. And throwing EA on graph, lines condition if(Level_0 > Level_1) is never true ?
 
Kira27:

Hey, could you tell me why in debugging, when passing the code step by step, lines are repainted in both colours depending on coordinate values. And throwing EA on a graph, the line condition if(Level_0 > Level_1) is never true ?

It is very likely that after renaming an object, it is not yet available to be accessed. You can try putting ChartRedraw after renaming. If it doesn't work, you need to build the sequence in some other way.

ps; Another option: first repaint with sparam name and then rename it.