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

 
voron_026:

HelloAleksey Vyazmikin I have recently started programming. I am slowly getting into the subject.

I tried to do it this way:

The first rectangle is drawn. The rest are not drawn. I am still trying to figure out how to do it. Thank you for the tips and what do you mean by non-typical style?


Are you sure that one object is drawn and not many at the same coordinates?

You have points constants.

datetime time0 = iTime(Symbol(),PERIOD_H4,0);
datetime time1 = iTime(Symbol(),PERIOD_H4,1);
double open0 = iOpen(Symbol(), PERIOD_H4,0);
double open1 = iOpen(Symbol(), PERIOD_H4,1);
double close1 = iClose(Symbol(), PERIOD_H4,1);
double high1 = iHigh(Symbol(), PERIOD_H4,1);
double low1 = iLow(Symbol(), PERIOD_H4,1);

Define them either in a function or directly in the code when creating an object...

About typicality - your calculation function is twisted and such expression if(!...) not many of beginners use it according to my observations.

 

Hello!


Can you please advise:

How can you calculate the position of one indicator(I-1), relative to another indicator(I-2) built on it(I-1).


For example:

The position of RSI relative to the Bollinger.

I thought you can substitute the data instead of price calculations

 RSI = iRSI(Symbol(), TimeFrame, 14, PRICE_CLOSE, 1);
 BB  = iBands(Symbol(), TimeFrame, 34, 1, 0, RSI, MODE_UPPER, 1);
But it gives me an error.
 
Ras al Ghul:

Hello!


Can you please advise:

How can you calculate the position of one indicator(I-1), relative to another indicator(I-2) built on it(I-1).


For example:

The position of RSI relative to Bollinger.

I thought it was possible to substitute the data instead of the price of calculation

but there is an error.

It is not even clear how you built bb on RSI, i.e. the picture is clear how done...


double  iBands( 
   string       symbol,           // имя символа 
   int          timeframe,        // таймфрейм 
   int          period,           // период 
   double       deviation,        // кол-во стандартных отклонений 
   int          bands_shift,      // сдвиг относительно цены 
   int          applied_price,    // тип цены 
   int          mode,             // индекс линии 
   int          shift             // сдвиг 
   );

your price type is not correct - you have to do it with

double  iBandsOnArray( 
   double       array[],          // массив 
   int          total,            // количество элементов 
   int          period,           // период 
   double       deviation,        // кол-во стандартных отклонений 
   int          bands_shift,      // сдвиг относительно цены 
   int          mode,             // индекс линии 
   int          shift             // сдвиг 
   );
 
Aleksey Vyazmikin:

About typicality - your calculation function is twisted and such an expression if(!...) is used by very few beginners according to my observations.


I see what you mean. Maybe I'm developing my own style. I like using the if(!...) operator in this format. And I got the calculation function from someone else, but I like this logic

 
Aleksey Vyazmikin:

It's not even clear how you built the RSI bb, i.e. the picture is clear as done...


Your price type is not correct - you have to do it through

Thank you for your reply!

It became clear where my thoughts are directed.


The picture is for illustration with standard MT4 tools (According to previous/first indicator).


I am familiar with arrays only from java... I am familiar with arrays in Java, and only just at a glance.

How do I create it and what do I need to put there?

F1 in MetaEditor and MQLQLQL Wizard did not give me any clarity...

 
voron_026:

I see your point. Maybe I'm developing my own style. I like using the if(!...) operator in this format. I got the calculation function from someone else, but I liked its logic.


I can see that you're a deep thinker - good luck!

 
Ras al Ghul:

Thank you for your reply!

It has become clear where to direct my thoughts.


The picture is for illustration with standard MT4 tools (According to previous/first indicator).


I am familiar with arrays only from java... I am familiar with arrays in Java, and only just at a glance.

How do I create it and what do I need to put there?

F1 in MetaEditor and MQLQL-learning did not give me any clarity...


Create an array and through a loop (for example, for) fill it with the indicator value. And then useiBandsOnArray() function.

 
Aleksey Vyazmikin:

Create an array and use a loop (for example, for) to fill it with the indicator value. And then useiBandsOnArray() function.


Either your version is very complex or I do not understand the value you are talking about...


double Array[], BB;  


 Array[1] = iRSI(Symbol(),TimeFrame,14,PRICE_CLOSE,1);
BB = iBandsOnArray(Array[1],0,34,1,0,MODE_UPPER,1);

My variant generates an error on the selected fragment:

'Array' - array required.

Isn't that how we get an indicator value into an array?


 
Aleksey Vyazmikin:

Are you sure that one object is being drawn and not many at the same coordinates?



Yes, you are right. Rectangles are drawn on the same coordinates. I have solved the problem in the following way:

void OnTick()
{
Fun_New_Bar();

   if(UseDojiCandles = true && Doji() == 1 && New_Bar == true)
     {
      datetime time0 = iTime(Symbol(),TimeFrame,0);
      datetime time1 = iTime(Symbol(),TimeFrame,1);
      double open0 = iOpen(Symbol(), TimeFrame,0);
      double open1 = iOpen(Symbol(), TimeFrame,1);

      if(!ObjectCreate(ChartID(),"Doji_"+IntegerToString(DojiCandle),OBJ_RECTANGLE,0,time1,open1,time0,open0))
         {
         Print("Не удалось создать метку вверх");
         }
         ObjectSetInteger(ChartID(),"Doji_"+IntegerToString(DojiCandle),OBJPROP_COLOR,clrRed);//--- установим цвет прямоугольника 
         ObjectSetInteger(ChartID(),"Doji_"+IntegerToString(DojiCandle),OBJPROP_STYLE,STYLE_SOLID);//--- установим стиль линий прямоугольника 
         ObjectSetInteger(ChartID(),"Doji_"+IntegerToString(DojiCandle),OBJPROP_WIDTH,1);//--- установим толщину линий прямоугольника 
         ObjectSetInteger(ChartID(),"Doji_"+IntegerToString(DojiCandle),OBJPROP_BACK,false);//--- отобразим на переднем (false) или заднем (true) плане 
         
         DojiCandle ++;
     }
   

   
   if(UseDojiCandles = true && Doji() == -1 && New_Bar == true)
     {
      datetime time0 = iTime(Symbol(),TimeFrame,0);
      datetime time1 = iTime(Symbol(),TimeFrame,1);
      double open0 = iOpen(Symbol(), TimeFrame,0);
      double open1 = iOpen(Symbol(), TimeFrame,1);
      
      if(!ObjectCreate(ChartID(),"Doji_"+IntegerToString(DojiCandle),OBJ_RECTANGLE,0,time1,open1,time0,open0))
         {
         Print("Не удалось создать метку вниз");
         }
         ObjectSetInteger(ChartID(),"Doji_"+IntegerToString(DojiCandle),OBJPROP_COLOR,clrRed);//--- установим цвет прямоугольника 
         ObjectSetInteger(ChartID(),"Doji_"+IntegerToString(DojiCandle),OBJPROP_STYLE,STYLE_SOLID);//--- установим стиль линий прямоугольника 
         ObjectSetInteger(ChartID(),"Doji_"+IntegerToString(DojiCandle),OBJPROP_WIDTH,1);//--- установим толщину линий прямоугольника 
         ObjectSetInteger(ChartID(),"Doji_"+IntegerToString(DojiCandle),OBJPROP_BACK,false);//--- отобразим на переднем (false) или заднем (true) плане 

         DojiCandle ++;
     }
     

   
}
I added a variableTimeFrame, to quickly change the calculated timeframe
 
Ras al Ghul:

Either your variant is very complicated, or I don't understand the value you're talking about...


In my variant, the highlighted piece is sworn out:

'Array' - array required.

Isn't that how we get an indicator value into an array?


Array[1] = iRSI(Symbol(),TimeFrame,14,PRICE_CLOSE,1);
BB = iBandsOnArray(Array,0,34,1,0,MODE_UPPER,1);