I want a function

 

Can you help?

that returns a value. & time The last two peaks in the RSI indicator 

 

 
  • Usually people who can't code don't receive free help on this forum.
  • If you show your attempts and describe your problem clearly, you will most probably receive an answer from the community. Use the CODE button (Alt-S) when inserting code.
  • To learn MQL programming, you can research the many available Articles on the subject, or examples in the Codebase, as well as reference the online Documentation.
  • If you do not want to learn to code, that is not a problem. You can either look at the Codebase if something free already exists, or in the Market for paid products (also sometimes free). However, recommendations or suggestions for Market products are not allowed on the forum, so you will have to do your own research.
  • Finally, you also have the option to hire a programmer in the Freelance section.
 
عمرو الشرقاوى:

Can you help?

that returns a value. & time The last two peaks in the RSI indicator 

 

// Function to find the last two peaks in RSI
void FindLastTwoRSIPeaks(int period, double &peak1Value, datetime &peak1Time, double &peak2Value, datetime &peak2Time)
{
    int arraySize = iBars(_Symbol, period);

    double rsiBuffer[];
    ArraySetAsSeries(rsiBuffer, true);

    // Calculate RSI values
    int startIndex = iBarShift(_Symbol, period, iTime(_Symbol, period, 0));
    int count = CopyBuffer(_Symbol, period, startIndex, arraySize, rsiBuffer);

    // Initialize variables to store peak values and times
    double currentPeakValue = 0.0;
    datetime currentPeakTime = 0;
    double previousPeakValue = 0.0;
    datetime previousPeakTime = 0;

    // Loop through RSI values to find peaks
    for (int i = 1; i < count - 1; i++)
    {
        if (rsiBuffer[i] > rsiBuffer[i - 1] && rsiBuffer[i] > rsiBuffer[i + 1])
        {
            // Found a peak
            previousPeakValue = currentPeakValue;
            previousPeakTime = currentPeakTime;

            currentPeakValue = rsiBuffer[i];
            currentPeakTime = iTime(_Symbol, period, startIndex + i);
        }
    }

    // Assign values to output parameters
    peak1Value = previousPeakValue;
    peak1Time = previousPeakTime;
    peak2Value = currentPeakValue;
    peak2Time = currentPeakTime;
}


This could help

 
Fernando Carreiro #:
  • Usually people who can't code don't receive free help on this forum.
  • If you show your attempts and describe your problem clearly, you will most probably receive an answer from the community. Use the CODE button (Alt-S) when inserting code.
  • To learn MQL programming, you can research the many available Articles on the subject, or examples in the Codebase, as well as reference the online Documentation.
  • If you do not want to learn to code, that is not a problem. You can either look at the Codebase if something free already exists, or in the Market for paid products (also sometimes free). However, recommendations or suggestions for Market products are not allowed on the forum, so you will have to do your own research.
  • Finally, you also have the option to hire a programmer in the Freelance section.

When I ask for help with us, it is because I am a programmer and I did not just ask for a complete expert

I am good at MQL4

 
Mohammed Abdulwadud Soubra #:


This could help

Thanks