Last active
July 1, 2023 17:19
-
-
Save UchePhilz/95908bbe9c30bfb35a2d562cf0a1bd39 to your computer and use it in GitHub Desktop.
MT5 Alert RSI Overbought and Undersold
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//+------------------------------------------------------------------+ | |
//| Powers EA | | |
//| Copyright 2020, PowersEA | | |
//| http://www.uchepowers.com | | |
//+------------------------------------------------------------------+ | |
#include <Trade/Trade.mqh> | |
CTrade trade; | |
int rsiHandle; | |
double rsi; | |
const int FLOOR = 30; | |
const int ROOF = 60; | |
//+------------------------------------------------------------------+ | |
//| | | |
//+------------------------------------------------------------------+ | |
int OnInit() { | |
rsiHandle = iRSI(_Symbol,PERIOD_CURRENT,14,PRICE_CLOSE); | |
Print("RSI EA Started"); | |
return(INIT_SUCCEEDED); | |
} | |
//+------------------------------------------------------------------+ | |
//| | | |
//+------------------------------------------------------------------+ | |
void OnDeinit(const int reason) { | |
Print("RSI EA Stopped"); | |
} | |
bool playAlert = true; | |
string pos = ""; | |
void OnTick() { | |
double rsiArr[]; | |
CopyBuffer(rsiHandle,0,0,1,rsiArr); | |
double rsi = rsiArr[0]; | |
if(rsi <= FLOOR) { // if rsi is <= 30 | |
ringer("low","alert.wav"); | |
printf("RSI low : %f ",rsi); | |
} else if((rsi > FLOOR) && (rsi < ROOF)) { | |
ringer("mid","stops.wav"); | |
printf("RSI normal : %f ",rsi); | |
} else if(rsi >= ROOF) { | |
ringer("high","alert2.wav"); | |
printf("RSI high : %f ",rsi); | |
} | |
} | |
//+------------------------------------------------------------------+ | |
//| | | |
//+------------------------------------------------------------------+ | |
void ringer(string newPos,string alert) { | |
if(pos != newPos) { | |
playAlert = true; | |
} | |
if(playAlert) { | |
PlaySound(alert); | |
playAlert = false; | |
} | |
pos = newPos; | |
} | |
//+------------------------------------------------------------------+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment