Questions from Beginners MQL5 MT5 MetaTrader 5 - page 755

 

Good afternoon!

Need some help/advice. In the terminal there is an option to mix several indicators. In this case it is possible to fix the ranges.

For example, CCI min=-300 max=300 and RSI min=0 max=100.

Is it possible to implement in the Expert Advisor to cross 2 indicators. Suppose the CCI crosses the RSI from bottom to top => open a Bay order.

Is it possible?

Or is it not possible, because these indicators have a different range of values. With rsi the range of values is limited from 0 to 100, and with cci the values can be both positive and negative and are not limited to max/min value...

 
lomaxx7:

Good afternoon!

Need some help/advice. In the terminal there is an option to mix several indicators. In this case it is possible to fix the ranges.

For example, CCI min=-300 max=300 and RSI min=0 max=100.

Is it possible to implement in the Expert Advisor to cross 2 indicators. Suppose the CCI crosses the RSI from bottom to top => open a Bay order.

Is it possible?

Or is it not possible as these indicators have a different range of values. With rsi the range of values is limited from 0 to 100, and with cci the values can be both positive and negative and are not limited to max/min value...

If you write your own iRSI for this purpose, you may subtract 50 from iRSI value and get indicator with zero level. One question remains: what is the use of mixing indicators in this way?

 
Alexey Viktorov:

If you write your own iRSI for this very purpose, you can subtract 50 from the iRSI value and get a zero-level indicator. One question remains: what is the use of mixing indicators in this way?

Thank you. There are some ideas that need to be worked out.
 

lomaxx7:

Is it possible to implement in an EA the function of crossing 2 indicators. Suppose CCI crosses RSI from bottom to top => opens Bay order...

Is this possible?

Or is it not possible as these indicators have a different range of values. With rsi the range of values is limited from 0 to 100, and with cci the values may be both positive and negative and are not limited to max/min value...

Not complicated. You can calculateCCI throughRSI and vice versa. Look at the documentation. There is an explanation for each indicator, which prices can be used.

https://www.mql5.com/ru/docs/indicators/irsi

applied_price

[in]Priceused . It can be any of the price constants ENUM_APPLIED_PRICE or it can be a handle of another indicator.

For example, we substitute the CCI handle in theRSI:

int OnInit()
h_cci=iCCI(_Symbol, _Period, cci_ma_period, cci_applied_price);
h_rsi=iRSI(_Symbol, _Period, rsi _ma_period, h_cci);
Далее
void OnTick() 
if(CopyBuffer(h_cci,0,0,to_copy, cci_buf)<=0) return(0);
if(CopyBuffer(h_rsi,0,0,to_copy, rsi _buf)<=0) return(0);
Далее сравниваете значения:
if(cci_buf>rsi_buf) {...ваши действия; ...buy; ...sell;} 
else
if(cci_buf<rsi_buf) {...ваши действия; ...buy; ...sell;}

The range of values in this case is not important as the next oscillator already uses the values of the previous oscillator.

Документация по MQL5: Технические индикаторы / iRSI
Документация по MQL5: Технические индикаторы / iRSI
  • www.mql5.com
Технические индикаторы / iRSI - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
 //+------------------------------------------------------------------+
class A
  {
public: int       propA;
public:
                     A(void) {propA = 15;};
                    ~A(void) {};
  };
//+------------------------------------------------------------------+
class B: public A
  {
public:
                     B(void){};
                    ~B(void){};
  };
//+------------------------------------------------------------------+
void OnStart()
  {
   B newObj;
   GetA(newObj);
//---
   //B newObjArray[3];
   //GetA_Array(newObjArray);
  }
//+------------------------------------------------------------------+
void GetA(A &obj)
  {
   Print(obj.propA);
  }
//+------------------------------------------------------------------+
void GetA_Array(A &obj[])
  {
   for(int i=0;i<ArraySize(obj);i++)
      Print(obj[i].propA);
  }
//+------------------------------------------------------------------+

If we uncomment the remaining lines in OnStart() we get "newObjArray - parameter conversion not allowed".

Two questions: why, and how to fix it?
 

Can you please tell me how to get a position report from the terminal?

The thing is that in the terminal I see a normal position, but in the Excel report it is split into parts, which is not convenient for me.

 

Hello 2017.06.30_18:11 GMT+3. Forum connoisseurs. I tested my EA in MT5 in the strategy tester. It opens and closes trades, but seems to be only on the first condition to open and close trades. So I decided to test the EA on a demo account. However, the EA immediately disappears from the chart on the demo account. It turns out it has an error on the demo account: 2017.06.30 18:08:17.878 Late_raw3 (GOLD,M1) array out of range in 'Cross.mqh' (18,12).
Strangely, no such error was found in the strategy tester. I tried to look for the error but failed to understand it. The question is as dumb as it gets. It was very confusing to me. Could MetaQuotes programmers mess up in this case? The standard Moving Average.mq5 Expert Advisor has the same code (I rewrote it from there). It has no error on the demo account. But it was not traded. I traded on М1. I have not waited long, though. What is the problem? I'll be waiting for your answers. Looking forward to it. Attached are the files, although not thoroughly all of them. 18:26 GMT+3. I've tried different ways to change the code, but the result is two: either it goes outside the array, or writes the error "No indicator data". And in the strategy tester's journal you can see how the "overshoots" are obtained. The opening price of the first trade is taken. It differs from the opening price of the second trade. This "deviation" (it is larger than my 130 points) is called an "overshoot". You should also say "thank you" to MetaQuotes programmers? You will not be bored. Everything you do is slow. I am going to finish the Expert Advisor sooner. 18:45 GMT+3. If you need any clarifications, please do not hesitate to contact me. That's all. 18:51 GMT+3.

 
Николай Никитюк:

Hello 2017.06.30_18:11 GMT+3. Forum connoisseurs. I tested my EA in MT5 in the strategy tester. It opens and closes trades, but seems to be only on the first condition to open and close trades. So I decided to test the EA on a demo account. However, the EA immediately disappears from the chart on the demo account. It turns out it has an error on the demo account: 2017.06.30 18:08:17.878 Late_raw3 (GOLD,M1) array out of range in 'Cross.mqh' (18,12).
Strangely, no such error was found in the strategy tester. I tried to look for the error but failed to understand it. The question is as dumb as it gets. It was very confusing to me. Could MetaQuotes programmers mess up in this case? The standard Moving Average.mq5 Expert Advisor has the same code (I rewrote it from there). It has no error on the demo account. But it was not traded. I traded on М1. I have not waited long, though. What is the problem? I'll be waiting for your answers. Looking forward to it. Attached are the files, although not thoroughly all of them. 18:26 GMT+3. I've tried different ways to change the code, but the result is two: either it goes outside the array, or writes the error "No indicator data". And in the strategy tester's journal you can see how the "overshoots" are obtained. The opening price of the first trade is taken. It differs from the opening price of the second trade. This "deviation" (it is larger than my 130 points) is called an "overshoot". You should also say "thank you" to MetaQuotes programmers? You will not be bored. Everything you do is slow. I am going to finish the Expert Advisor sooner. 18:45 GMT+3. If you need any clarifications, please do not hesitate to contact me. That's all. 18:51 GMT+3.


So far it seems that "rates" (file "Cross.mqh", line 18, cursor position 12) is declared somewhere at global level - so all questions come down to: "How is this "rates" actually filled in?".

 

I'm trying to calculate the angle of intersection of two curves. The task is not even to find the angle itself, but to check whether it is acute or obtuse. I even drew this. I can find the tangent of B and the tangent of C. How do I know these tangents, to determine if the angle A is acute. Help me, I'm not very good at trigonometry. Of course, without finding the angles themselves - because of the difference in scales their values are inadequate.


 
igorbel:

I'm trying to calculate the angle of intersection of two curves. The task is not even to find the angle itself, but to check whether it is acute or obtuse. I even drew this. I can find the tangent of B and the tangent of C. How do I know these tangents to determine if the angle A is acute. Help me, I'm not very good at trigonometry. Of course, without finding the angles themselves - because of the difference in scales their values are inadequate.


To find tangents, do you have a right triangle?
Reason: