EA RSI strategy.

 
Hi Everyone

I'm on develop my EA for RSI and i got 1 issue, when i print this code i found that RSI = 10 all the time

#include <Trade\Trade.mqh> // Include the trade functions

input int RSI_Period = 14; // RSI period
input double RSI_Buy_Level = 30.0; // RSI level to buy
input double RSI_Sell_Level = 70.0; // RSI level to sell
input double Lot_Size = 0.1; // Lot size for trading
input int StopLoss_Pips = 100; // Stop loss in pips
input int TakeProfit_Pips = 200; // Take Profit in pips

double rsiBuffer[];

CTrade trade; // Create an instance of the trade class
void OnTick()
  {
   double rsi = iRSI(Symbol(),PERIOD_CURRENT, RSI_Period, PRICE_OPEN);
   double ask = SymbolInfoDouble(Symbol(), SYMBOL_ASK);
   double bid = SymbolInfoDouble(Symbol(), SYMBOL_BID);
   double point = SymbolInfoDouble(Symbol(), SYMBOL_POINT);
   double profit = PositionGetDouble(POSITION_PROFIT);
   
    // Print the RSI value and current prices
   Print("RSI: ", rsi, " Ask: ", ask, " Bid: ", bid);
 }

2024.10.10 16:48:36.920 RSI Ver 1 (XAUUSD,H1) RSI: 10.0 Ask: 2616.84 Bid: 2616.69
2024.10.10 16:48:47.530 RSI Ver 1 (XAUUSD,H1) RSI: 10.0 Ask: 2616.75 Bid: 2616.6

Not quite sure, where i'm wrong

Please help to give me some advises

Thanks and Best regards
HieuNguyen
 
Your topic has been moved to the section: Expert Advisors and Automated Trading
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 

You are mixing MQL4 and MQL5 code. Indicator functions return a handle, not buffer values. Please stop using ChatGPT.

Read the documentation on how to properly use the function "iRSI" in conjunction with "CopyBuffer"

Documentation on MQL5: Technical Indicators / iRSI
Documentation on MQL5: Technical Indicators / iRSI
  • www.mql5.com
The function returns the handle of the Relative Strength Index indicator. It has only one buffer. Parameters symbol [in] The symbol name of the...
 
Fernando Carreiro #:

You are mixing MQL4 and MQL5 code. Indicator functions return a handle, not buffer values. Please stop using ChatGPT.

Read the documentation on how to properly use the function "iRSI" in conjunction with "CopyBuffer"

Dear Fernando

Appreciate for your guidance.

Thank you so much
HieuNguyen