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

 

Hi all. Guys, help me to combine 2 indicators. Been sitting for 3 days now and nothing works.

The first indicator shows the trend and the second one gives me an alert and shows me the entry point with an arrow. I need to make the second indicator gives out signals only for the trend.

I am trying to get them to be one indicator, or tell me what I did wrong.

 
jarikn:

Hi all. Guys, help me to combine 2 indicators. Been sitting for 3 days now and nothing works.

The first indicator shows the trend and the second one gives me an alert and shows me the entry point with an arrow. I need to make the second indicator gives out signals only for the trend.

Help me make them a whole or tell me what I did wrong.

Catch

 

What on earth are you talking about? Doesn't anyone read the documentation ?

Bars

Request the number of bars on a given interval

int  Bars( 
   string           symbol_name,     // имя символа 
   ENUM_TIMEFRAMES  timeframe,       // период 
   datetime         start_time,      // с какой даты 
   datetime         stop_time        // по какую дату 
   );

Returned value

If the start_time and stop_time parameters are given, the function returns the number of bars in a date range. If these parameters are not given, the function returns the total amount of bars.

Bars - Доступ к таймсериям и индикаторам - Справочник MQL4
Bars - Доступ к таймсериям и индикаторам - Справочник MQL4
  • docs.mql4.com
Bars - Доступ к таймсериям и индикаторам - Справочник MQL4
 

Please tell me what I'm doing wrong) or how to do it right


void Lvls(datetime data, double OPEN, double avg)
  {

   double hi = OPEN + avg;

   double lo = OPEN - avg;
   
   Print("ХАЙ РАВЕН :", hi," ЛОУ РАВЕН :", lo, "ЦЕНА ОТКРЫТИЯ : ", OPEN);
   
   string up = "LVL_UP_" + TimeToString(data);
   string low = "LVL_LOW_" + TimeToString(data);

//Хай
   ObjectCreate(NULL,up,OBJ_TREND,0,data,hi,data,hi,clrBlue,STYLE_SOLID,2,true,true,false,true,false,1);

//Лоу
  ObjectCreate(NULL,low,OBJ_TREND,0,data,lo,data,lo,clrRed,STYLE_SOLID,2,true,true,false,true,false,1);
  }
  


In general, firstly, the objects are created on the chart, but not displayed, and secondly, although I put a different colour line, line properties have their correct name, but their colour in both cases is red, in the third I can not understand what date to specify a 2-point binding if I want the line was continued to the right, but was not a ray?

 
MakarFX:

The function works correctly.

Try it like this

and add balance update to the order closing function

I will try it during the day, thanks

 
Alexey Viktorov:

I'm already lost in your wishes and advice to you... So maybe my advice is completely off-topic, but sorry...

I understand you need to fix the balance at the beginning of the day and count the profit/loss during the day, in accordance with which you need to make a decision about continuing trading ...

So here is the decision

If the Expert Advisor will be restarted during the day, you should consider calculation of profits/losses of today's orders taking into account swaps and commissions and calculate the balance for the beginning of the day in OnInit().

I believe in Makar's abilities, he can show all this already in the code...

I'll try it during the day, thanks

 
MakarFX:

Catch

That's it? I've been racking my brains for three days))))) uh, thank you very much
 
MakarFX:

Catch

I looked at the history, it's still not the same. when the trend is buy, it can give a signal to sell and vice versa. can you tell me which line to change? everything is fine. thank you very much.
 
jarikn:
I looked at the history, it's still not the same. when the trend is buy, it may give a signal to sell and vice versa. can you tell me which line to change? otherwise everything is super. thank you very much
I just merged them.
 
Алексей КоКоКо:

Please tell me what I'm doing wrong) or what is the right way In general, the first object is created on the chart, but do not appear, in the second although I put different colour lines in the properties have their own names, but their colour in both cases is red, in the third I can not understand what date to specify a 2-point anchor if I want the line to continue to the right, but was not a ray?

void Lvls(datetime data, double OPEN, double avg)
  {

   double hi = OPEN + avg;
   double lo = OPEN - avg;
   
   int shift = Period()*60*5;
   
   Print("ХАЙ РАВЕН :", hi," ЛОУ РАВЕН :", lo, "ЦЕНА ОТКРЫТИЯ : ", OPEN);
   
   string up = "LVL_UP_" + TimeToString(data);
   string low = "LVL_LOW_" + TimeToString(data);

//Хай
   ObjectCreate(NULL,up,OBJ_TREND,0,data,hi,data+shift,hi,clrBlue,STYLE_SOLID,2,true,true,false,true,false,1);

//Лоу
  ObjectCreate(NULL,low,OBJ_TREND,0,data,lo,data+shift,lo,clrRed,STYLE_SOLID,2,true,true,false,true,false,1);
  }
Reason: