RK_MindHero mail
Download scriptThis script is a custom trading indicator designed for the MetaTrader platform. Its primary purpose is to analyze price action and market volatility to identify potential trend reversals, providing visual signals and automated notifications for traders.
Core Logic and Mechanism
The tool operates by monitoring three main components: Price Movement, Volatility Scaling, and Trend Direction.
1. Volatility Analysis (ATR Calculation) The script begins by calculating a specialized version of the Average True Range (ATR). Unlike a standard average, this logic uses a weighted calculation. It looks at recent price fluctuations—specifically the distance between high and low prices, as well as the gaps between closing prices—to determine how much "room" the market is moving in. This ensures that the signals are adjusted based on whether the market is currently calm or highly volatile.
2. The "River" Trend Logic The script uses a unique conceptual logic referred to in the code as a "river." This represents the prevailing direction of the price flow:
- Upward Flow: If the price pushes significantly above a specific threshold (calculated using the volatility data), the "river" is considered to be moving upward.
- Downward Flow: Conversely, if the price drops significantly below a set threshold, the "river" is considered to be moving downward. The script constantly updates these thresholds based on the most recent significant highs and lows, allowing the indicator to "track" the market's momentum dynamically.
3. Signal Generation (Buy and Sell) The tool places visual markers (arrows) on the chart when the price interacts with these trend boundaries in specific ways:
- Long Signals (Blue): When the trend is upward, the script looks for instances where the price dips slightly but remains within the overall bullish flow. If a condition is met, it plots a signal suggesting an entry for a long position.
- Short Signals (Red): When the trend is downward, the script monitors for slight price bounces that do not break the bearish momentum. If these occur, it plots a signal suggesting an entry for a short position.
User Interface and Alerts
To ensure the trader does not have to watch the screen constantly, the script includes a comprehensive notification system:
- Visual Cues: It places specific arrows on the price chart to highlight entries.
- Audio Alerts: It can trigger a sound file (e.g., an alert beep) when a new signal appears in real-time.
- Email Notifications: The script can be configured to send an automated email to your connected account, notifying you of "Go Long" or "Go Short" opportunities immediately.
- On-Screen Comments: It can display text directly on the trading chart (e.g., "Mind Hero > Go Long!") to provide a clear, instant summary of the current recommendation.
Summary of Operation
In simple terms, this script acts as an automated trend-follower that filters out market "noise" by using weighted volatility. It identifies when the price is moving with strength in one direction and alerts you when the price offers a favorable entry point to join that existing momentum.
//+------------------------------------------------------------------+
//| Mindhero.mq4 |
//| www.mindrends.com |
//| superhero |
//+------------------------------------------------------------------+
#property copyright "Mindherostar Inc."
#property link "www.mindrends.com"
//----
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- input parameters
extern int NumBars=500;
//added by rosdikasim@gmail.com
extern bool Play_Sound = true;
extern int Maximum_Alert = 5;
extern string Sound_WAV = "expert.wav";
extern bool Send_Email = false;
extern bool Display_Comment = true;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double spread;
int noOfAlert;
bool emailAlreadySent = false;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init() {
SetIndexStyle(0,DRAW_ARROW);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexArrow(0,233);
SetIndexStyle(1,DRAW_ARROW);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexArrow(1,234);
noOfAlert = Maximum_Alert;
return(0);
}
int deinit() {
return(0);
}
int start() {
int counted_bars = IndicatorCounted();
int artp = 7;
int numOfBars = 0;
int Shift = 0;
int glava = 0;
int J = 0;
int Curr = 0;
int plotted = -1; //1 = plotted long, 2 = plotted short, -1 = not plotted
bool river = True;
double Emaxtra=0;
double widcha=0;
double trueRange=0;
double Values[100];
double averageTrueRange=0;
double Weight=0;
double dartp=7.0;
double cecf=0.7;
double Range1=0;
double val1=0;
double val2=0;
double r1=0;
double s=2;
spread = MarketInfo(Symbol(),MODE_SPREAD) * Point;
if(Bars < NumBars) {
numOfBars = Bars;
}else{
numOfBars = NumBars;
}
if(Close[numOfBars - 2] > Close[numOfBars - 1]) {
river = True;
}else{
river = False;
}
Emaxtra = Close[numOfBars - 2];
Shift = numOfBars - 3;
while(Shift >= 0) {
trueRange = spread + High[Shift] - Low[Shift];
if(MathAbs(spread + High[Shift] - Close[Shift + 1]) > trueRange){
trueRange = MathAbs(spread + High[Shift] - Close[Shift + 1]);
}
if(MathAbs(Low[Shift] - Close[Shift + 1]) > trueRange) {
trueRange = MathAbs(Low[Shift] - Close[Shift + 1]);
}
if (Shift == numOfBars - 3) {
for(J=0; Shift <= artp-1; J++) {
Values[J] = trueRange;
}
}
Values[glava] = trueRange;
averageTrueRange = 0;
Weight = artp;
Curr = glava;
for(J=0; J<=artp - 1; J++) {
averageTrueRange += Values[Curr] * Weight;
Weight -= 1.0;
Curr--;
if (Curr == -1) { Curr = artp - 1; }
}
averageTrueRange = 2.0 * averageTrueRange /(dartp * (dartp + 1.0));
glava++;
if (glava == artp) { glava = 0; }
widcha = cecf * averageTrueRange;
if (river && Low[Shift] < Emaxtra - widcha) {
river = False;
Emaxtra = spread + High[Shift];
}
if (!river && spread+ High[Shift] > Emaxtra + widcha) {
river = True;
Emaxtra = Low[Shift];
}
if (river && Low[Shift] > Emaxtra) {
Emaxtra=Low[Shift];
}
if (!river && spread+ High[Shift] < Emaxtra) {
Emaxtra=spread+ High[Shift];
}
Range1 = iATR(NULL,0,10,Shift);
val1=0;
val2=0;
if (river) {
if (plotted != 1) {
r1 = Low[Shift] - Range1 * s/3.0;
} else if (plotted == 1) {
r1 = -1.0;
}
if (r1 > 0) {
val1 = r1;
val2 = 0;
if(Shift == 0) {
if(Play_Sound && noOfAlert > 0) {
PlaySound(Sound_WAV);
noOfAlert -= 1;
}
if(Send_Email && !emailAlreadySent) {
SendMail("RK MindHero: " + Symbol(), "Go long on " + Symbol() + " now!");
emailAlreadySent = true;
}
if(Display_Comment) { Comment("Mind Hero > Go Long!"); }
}
} else {
val1 = 0;
val2 = 0;
if(Shift == 0) {
noOfAlert = Maximum_Alert;
emailAlreadySent = false;
}
}
ExtMapBuffer1[Shift] = val1;
plotted = 1;
} else {
if (plotted!=2) {
r1 = spread + High[Shift] + Range1 * s/3.0;
} else if (plotted == 2) {
r1 = -1.0;
}
if (r1 > 0) {
val1 = 0;
val2 = r1;
if(Shift == 0) {
if(Play_Sound && noOfAlert > 0) {
PlaySound(Sound_WAV);
noOfAlert -= 1;
}
if(Send_Email && !emailAlreadySent) {
SendMail("RK MindHero: " + Symbol(), "Go short on " + Symbol() + " now!");
emailAlreadySent = true;
}
if(Display_Comment) { Comment("Mind Hero > Go Short!"); }
}
} else {
val1 = 0;
val2 = 0;
if(Shift == 0) {
noOfAlert = Maximum_Alert;
emailAlreadySent = false;
}
}
ExtMapBuffer2[Shift]=val2;
plotted = 2;
}
Shift--;
}
return(0);
}
Comments