Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 610

 

@Aleksey Semenov,@Galim_V, thanks for the tips.

Is this ok?Or do I need to limit the number of attempts?


int k=0;

while(k==0)

{

if ( !OrderModify(...) ) k=0; else k=1;

}

 
Roman Sharanov:

how to convert int to date?

how to find the number of bars between dates taken from the current period? i did this and of course it does not work

Read the documentation.

int  Bars(
   string           symbol_name,     // имя символа
   ENUM_TIMEFRAMES  timeframe,       // период
   datetime         start_time,      // с какой даты
   datetime         stop_time        // по какую дату
   );
Bars - Доступ к таймсериям и индикаторам - Справочник MQL4
Bars - Доступ к таймсериям и индикаторам - Справочник MQL4
  • docs.mql4.com
Если указаны параметры start_time и stop_time, то функция возвращает количество баров в диапазоне дат. Если эти параметры не указаны, то функция возвращает общее количество баров. Если данные для таймсерии с указанными...
 
Alexey Viktorov:

Read the documentation.

Got it, thanks.

But what is the problem with what I wrote?

 
Roman Sharanov:

Understood, thank you.

But what's the problem with what I wrote?

I don't know - I'd like to know. At first glance, nothing special, but to understand it you have to run and observe. And I'm lazy.

But there is a question about implementation of this approach. Why should we swap variable values via temp if we can just take the absolute value of the difference...

 

Please help!!!

I am using my trading robot on MT4


Why, when I try to optimize a strategy in the tester, only part of the passes (the first 20-30) are made,

and the rest do not. My data is already loaded. The strategy works correctly, I checked it separately from the optimization, everything works. Can this be some kind of restriction? Please help!

 
Good afternoon. I have a question: when trading several instruments, there is a constant need to control the risk of each instrument. Can anyone suggest a ready script that calculates the risk percentage?
 
Виктор:
Afternoon. I have a question: when trading several instruments I need to control the risk of each one. Can someone suggest a ready script that calculates the risk percentage?

(Same question)

Looking for a universal formula to calculate a lot, but nothing works

 
only for each currency to be prescribed separately
 
Roman Sharanov:

Same question)

I am looking for a universal formula for calculating a lot, but nothing works.

Roman Sharanov : You got me wrong. I need a script not for lot calculation but for calculation of % of already set stop from the deposit size for any instrument.

I.e., there is a set of instruments for which trades with set stops are opened. I have a script that calculates total stop loss and take profit as well as their relation to the deposit. I need the same for only one instrument. If there is only one open trade on the instrument, there are no difficulties, but as soon as you start using pyramiding, it becomes difficult to calculate the risk.

 

Good afternoon. Can you tell me what's wrong. I want to colour the Fibo levels in different colours, but they are not colored in any way. Below is the code of what I am doing. Thanks in advance for the help.

         double            values[]  ={1,0.236,0.382,0.5,0.618,0,0.786,0.86,-0.18,-0.27,-0.618};
         string            deskript[]={"100","23.6 [%$]","38.2 [%$]","50.0 [%$]","61.8 [%$]","0","78.6 [%$]","86.0 [%$]","18.0 [%$]","27.0 [%$]","61.8 [%$]"};
         color             colors[]={clrDarkGray,clrLime,clrLime,clrLime,clrLime,clrDarkGray,clrOrangeRed,clrRed,clrRed,clrOrangeRed,clrBlue};
         ENUM_LINE_STYLE   styles[]={STYLE_DOT,STYLE_DOT,STYLE_DOT,STYLE_DOT,STYLE_DOT,STYLE_DOT,STYLE_DOT,STYLE_DOT,STYLE_DOT,STYLE_DOT,STYLE_DOT};
         int               levels =ArraySize(values);     

            ObjectCreate(0,"Fb_"+InpName,OBJ_FIBO,window,time1,price1,time2,price2);
            ObjectSet("Fb_"+InpName,OBJPROP_COLOR,clrDimGray);
            ObjectSet("Fb_"+InpName,OBJPROP_STYLE,STYLE_DOT);
            ObjectSet("Fb_"+InpName,OBJPROP_LEVELS,levels);
            ObjectSet("Fb_"+InpName,OBJPROP_RAY_RIGHT,false);
            for(int k=0;k<levels;k++)
              {
               //--- значение уровня
               ObjectSetDouble(0,"Fb_"+InpName,OBJPROP_LEVELVALUE,k,values[k]);
               ObjectSetInteger(0,"Fb_"+InpName,OBJPROP_LEVELCOLOR,k,colors[k]);
               ObjectSetInteger(0,"Fb_"+InpName,OBJPROP_LEVELSTYLE,k,styles[k]);
               ObjectSetFiboDescription("Fb_"+InpName,k,deskript[k]);
              }