Here's an explanation of what the script does, in plain language, for someone who doesn't know how to program:
This script is designed to identify potential buy and sell signals on a price chart within a trading platform (MetaTrader). It does this by looking for recent highs and lows in the price, and then plotting arrows to indicate these potential turning points.
Here's a breakdown of the steps the script takes:
-
Setup: The script first defines some settings, like the colors and thickness of the arrows it will draw on the chart. It also sets up some "inputs" that the user can change, such as the distance the script looks back to find highs and lows, and whether to trigger alerts.
-
Finding Highs and Lows: The core of the script is identifying recent highest and lowest prices.
- It looks back a certain number of periods (defined by the
dist1
anddist2
inputs) to find the highest high and the lowest low. Essentially, it's scanning a small window of past prices.
- It looks back a certain number of periods (defined by the
-
Plotting Arrows:
- If a high is found, the script plots a red arrow above the high price. This suggests a potential sell signal, as the price might be reversing downwards.
- If a low is found, the script plots a yellow arrow below the low price. This suggests a potential buy signal, as the price might be reversing upwards.
- The script uses Average True Range to make more accurate the arrow positioning.
-
Alerts: The script can also trigger alerts based on the signals. The user can customize the alerts in the settings to produce pop-up windows.
In essence, this script is a visual tool that automatically identifies potential support and resistance levels (highs and lows) and marks them on the chart as possible buy or sell opportunities. The user then needs to interpret these signals within their broader trading strategy.
//+------------------------------------------------------------------+
//| super-signals_v2.mq4 |
//| Copyright © 2006, Nick Bilak, beluck[AT]gmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Nick Bilak"
#property copyright "alterations by Mark Tomlinson"
#property link "http://www.forex-tsd.com/"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Yellow
#property indicator_width1 5
#property indicator_width2 5
//input properties
extern int dist2 = 59;// was 21 250
extern int dist1 = 59;// was 14
extern bool alertsOn = true;
extern bool alertsOnCurrent = true;
extern bool alertsMessage = true;
extern bool alertsSound = true;
extern bool alertsEmail = false;
double alertBar;
extern int SignalGap = 3;
double b1[];
double b2[];
int init()
{
SetIndexBuffer(0,b1);
SetIndexBuffer(1,b2);
SetIndexStyle(0,DRAW_ARROW); SetIndexArrow(0,222);
SetIndexStyle(1,DRAW_ARROW); SetIndexArrow(1,221);
return(0);
}
int start()
{
int counted_bars=IndicatorCounted();
int i,limit,hhb1,llb1;
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
limit=MathMax(limit,dist1);
limit=MathMax(limit,dist2);
for (i=limit;i>=0;i--)
{
hhb1 = Highest(NULL,Period(),MODE_HIGH,dist2,i-dist2/2);
llb1 = Lowest(NULL,Period(),MODE_LOW,dist1,i-dist2/2);
b1[i] = EMPTY_VALUE;
b2[i] = EMPTY_VALUE;
double tr = iATR(NULL,0,5,i);
if (i==hhb1) b1[i]=High[hhb1] + tr/2;
if (i==llb1) b2[i]=Low[llb1] -tr/2;
if(i == 0 && b1[i]!=0 && b2[i] != 2147483647 && Bars>alertBar) {Alert("Super_Signal UP Alert " + Symbol() + " on the " + Period() + " minute chart ");alertBar = Bars;}
if(i == 0 && b2[i]!=0 && b1[i] != 2147483647 && Bars>alertBar) {Alert("Super_Signal DOWN Alert " + Symbol() + " on the " + Period() + " minute chart ");alertBar = Bars;}
}
return(0);
}
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---