Questions from Beginners MQL5 MT5 MetaTrader 5 - page 543

 
edutak:

I'm sorry, I don't really understand. The closing price of the candle must be greater than the indicator's 70 level.

And level 70=70. What should it be equal to?

Close[1] refers to the price of the instrument. In this case, it is the close price on the 1st bar. But not to the indicator. The indicator is a derivative of the price.

In your case, the RSI ranges from 0 to 100, while the price is 1.43406. Which is way below 70.

The level of 70 is the value of the indicator. And Close[1] is the close price on the 1st bar. They are completely different things and cannot be compared. Like kilograms with meters.

 
Vitalii Ananev:

Close[1] refers to the price of the instrument. In this case the close price on the 1st bar. But not to the indicator. The indicator is a derivative of the price.

In your case, the RSI ranges from 0 to 100, but the price is like in the picture 1.43406. Which is way below 70.

I see, Thank you, so redone, seems to have opened it correctly, but why is the level 50 indicator not reflected?

void OnTick()
  {
   int kolpos=0;
   double rsi=0,uroven70=70,uroven30=30,uroven50=50;
   rsi=iRSI(Symbol(),0,10,PRICE_CLOSE,1);
   for(int pos=0; pos<OrdersTotal(); pos++) 
     {
      OrderSelect(pos,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
         kolpos++;
     }
   if(kolpos==0)
     {
      if((rsi>uroven70) &&   (Open[1]<uroven70) && Volume[0]<3)
         OrderSend(Symbol(),OP_BUY,Lots,Ask,30,0,0,"",Magic,0,clrGreen);
      if((rsi<uroven30) &&   (Open[1]>uroven30) && Volume[0]<3)
         OrderSend(Symbol(),OP_SELL,Lots,Bid,30,0,0,"",Magic,0,clrRed);
     }
 }
 

Is this correct? Will the advisor work correctly?

void OnTick()
  {
   int kolpos=0;
   double rsi=0,uroven70=70,uroven30=30,uroven50=50;
   rsi=iRSI(Symbol(),0,10,PRICE_CLOSE,1);
   for(int pos=0; pos<OrdersTotal(); pos++) 
     {
      OrderSelect(pos,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
         kolpos++;
     }
   if(kolpos==0)
     {
      if (rsi>uroven70)// && Volume[0]<3)
         OrderSend(Symbol(),OP_BUY,Lots,Ask,30,0,0,"",Magic,0,clrGreen);
      if (rsi<uroven30)// &&   (Open[1]>uroven30) && Volume[0]<3)
         OrderSend(Symbol(),OP_SELL,Lots,Bid,30,0,0,"",Magic,0,clrRed);
     }
 }
 
edutak:

I see, Thank you, so redone, seems to have opened it correctly, but why isn't the level 50 indicator reflected?

I don't see what you got me just changed > to <. What you have redone, utter nonsense. Do not even think of putting it on the real.

The level of 50 is set in the indicator itself. The Expert Advisor knows where this level is in the indicator.

 
edutak:

Is this correct? Will the advisor work correctly?

That's better. You should also create a filter. It would open a buy order only if there is an uptrend and sell only if there is a downtrend.
 
Vitalii Ananev:

I don't see what you got me just changed > to <. What you have redone is complete nonsense. Don't even think about putting it on real.

Level 50 is set in the indicator itself. The Expert Advisor knows where this level is in the indicator.

Here, I think I opened it correctly, but I can't see the 50 level, while 30 and 70 are there.
 
Vitalii Ananev:
That's better. Make another filter. It would open buy trades only if there is an uptrend and sell trades only if there is a downtrend.

Here's the trend. Right?

if (rsi>uroven70)

if (rsi<uroven30)
 
edutak:
Here, I think I opened it correctly, but I can't see level 50. 30 and 70 are there.
The level has to be set manually in the indicator settings. By default there is no level 50. I showed in the picture above.
 
edutak:

Here's the trend. Right?

RSI is an oscillator, it does not show a trend.

Add another trend indicator like the MA.

double MA = iMA(......)

if (rsi>uroven70 && Close[1]<MA)
{
 ///SELLL
 
}

if (rsi<uroven30 && Close[1]>MA)
{
///BUY

}
 
Please advise what to do if trades are not automatically copied with the lot size that the trader has positioned, but with larger volumes?
Reason: