1-2-4!
Download scriptThis script is designed to automatically identify and map specific historical price levels on a financial chart based on three primary user-defined price points. It essentially performs a geometric "traceback" to find significant structural coordinates in past market data.
Core Logic Overview
1. Identification of Primary Anchors The script begins by scanning the chart history to find exactly where the three prices you provided (Level 1, Level 2, and Level 3) occurred. It identifies both the specific time these prices were reached and whether the price hit those levels from above (a high) or below (a low).
2. Geometric Calculation & Recursive Search Once the primary points are locked in, the script uses a mathematical formula to calculate "shadow" levels (Levels 4, 5, and 6). Instead of just looking at the prices you entered, it calculates new targets based on the distance and proportions between your chosen points.
- Level 4: The script calculates a specific price point relative to the distance between Level 2 and Level 3, then scans backward through history to find the most relevant "low" that matches this calculation.
- Level 5: Using the newly discovered Level 4 as a base, it performs a second calculation to find a corresponding "high" in the data.
- Level 6: Finally, it repeats this logic one last time using the distance between the other points to find a final historical "low."
3. Visual Mapping After finding all six coordinates (the three you provided and the three it calculated automatically), the script draws labeled markers directly on your chart. It places numbered text labels (1 through 6) at the precise historical moments these prices were hit. These markers are dynamically positioned to ensure they remain visible and do not overlap with the price candles.
4. Real-Time Data Feed In addition to the visual markers, the script generates a text summary in the corner of your screen. This provides a data readout of every coordinate found, showing you the exact price and the specific time index for all six points simultaneously.
Summary of Workflow
- Input: You provide 3 price levels.
- Processing: The script finds them, calculates 3 additional related levels based on geometric ratios, and searches history for those matching prices.
- Output: It marks all 6 points on your chart and displays their numerical data in a text box.
//+------------------------------------------------------------------+
//| maloma 4 vicont 1-2-3.mq4 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, maloma."
extern double Óðîâåíü_1=1.2937;//1.2937;
extern double Óðîâåíü_2=1.2725;//1.2630;
extern double Óðîâåíü_3=1.2874;//1.2829;
int start(){
int time_1=0; int time_2=0; int time_3=0;
int p1d=0; int p2d=0; int p3d=0;
double Óðîâåíü_4=0; double Óðîâåíü_5=0; double Óðîâåíü_6=0; double Óðîâåíü_t=0;
int time_4=0; int time_5=0; int time_6=0;
int i=0; int j=0; int k=0;
while (time_3==0){
if (High[i] == Óðîâåíü_3) {time_3=i; p3d=1;}
if (Low[i] == Óðîâåíü_3) {time_3=i; p3d=-1;}
i++;}
while (time_2==0){
if (High[i] == Óðîâåíü_2) {time_2=i; p2d=1;}
if (Low[i] == Óðîâåíü_2) {time_2=i; p2d=-1;}
i++;}
while (time_1==0){
if (High[i] == Óðîâåíü_1) {time_1=i; p1d=1;}
if (Low[i] == Óðîâåíü_1) {time_1=i; p1d=-1;}
i++;}
i=time_3-1;
Óðîâåíü_4=Óðîâåíü_3-(Óðîâåíü_3-Óðîâåíü_2)*1.62;
while (i>=0 && time_5<i)
{// while start äëÿ ïîèñêà 4
if (Low[i]<=Óðîâåíü_4)
{// íà÷àëî Åñëè íàøëè òî÷êó 4
Óðîâåíü_4=Low[i];
time_4=i;
j=time_4-1;
Óðîâåíü_t=Óðîâåíü_3-(Óðîâåíü_3-Óðîâåíü_4)/2;
Óðîâåíü_5=Óðîâåíü_t-(Óðîâåíü_2-Óðîâåíü_t);
while (j>=0 && time_6<j)
{// while start äëÿ ïîèñêà 5
if (High[j]>=Óðîâåíü_5)
{// íà÷àëî Åñëè íàøëè òî÷êó 5
Óðîâåíü_5=High[j];
time_5=j;
k=time_5-1;
Óðîâåíü_t=Óðîâåíü_4-(Óðîâåíü_4-Óðîâåíü_5)/2;
Óðîâåíü_6=Óðîâåíü_t-(Óðîâåíü_1-Óðîâåíü_t);
while (k>=0)
{// while start äëÿ ïîèñêà 6
if (Low[k]<=Óðîâåíü_6)
{// íà÷àëî Åñëè íàøëè òî÷êó 6
Óðîâåíü_6=Low[k];
time_6=k;
}// êîíåö Åñëè íàøëè òî÷êó 6
k--;
}// while end äëÿ ïîèñêà 6
}// êîíåö Åñëè íàøëè òî÷êó 5
j--;
}// while end äëÿ ïîèñêà 5
}// êîíåö Åñëè íàøëè òî÷êó 4
i--;
}// while end äëÿ ïîèñêà 4
if (ObjectFind("Point_6")==-1){
ObjectCreate ("Point_6",OBJ_TEXT,0,Time[time_6],Óðîâåíü_6+50*Point*p2d,0,0,0,0);
ObjectSetText("Point_6", "6", 14, "Times New Roman", Gold);}
else {
ObjectMove("Point_6", 0, Time[time_6],Óðîâåíü_6+50*Point*p2d);}
if (ObjectFind("Point_5")==-1){
ObjectCreate ("Point_5",OBJ_TEXT,0,Time[time_5],Óðîâåíü_5+50*Point*p3d,0,0,0,0);
ObjectSetText("Point_5", "5", 14, "Times New Roman", Gold);}
else {
ObjectMove("Point_5", 0, Time[time_5],Óðîâåíü_5+50*Point*p3d);}
if (ObjectFind("Point_4")==-1){
ObjectCreate ("Point_4",OBJ_TEXT,0,Time[time_4],Óðîâåíü_4+50*Point*p2d,0,0,0,0);
ObjectSetText("Point_4", "4", 14, "Times New Roman", Gold);}
else {
ObjectMove("Point_4", 0, Time[time_4],Óðîâåíü_4+50*Point*p2d);}
if (ObjectFind("Point_3")==-1){
ObjectCreate ("Point_3",OBJ_TEXT,0,Time[time_3],Óðîâåíü_3+50*Point*p3d,0,0,0,0);
ObjectSetText("Point_3", "3", 14, "Times New Roman", Gold);}
else {
ObjectMove("Point_3", 0, Time[time_3],Óðîâåíü_3+50*Point*p3d);}
if (ObjectFind("Point_2")==-1){
ObjectCreate ("Point_2",OBJ_TEXT,0,Time[time_2],Óðîâåíü_2+50*Point*p2d,0,0,0,0);
ObjectSetText("Point_2", "2", 14, "Times New Roman", Gold);}
else {
ObjectMove("Point_2", 0, Time[time_2],Óðîâåíü_2+50*Point*p2d);}
if (ObjectFind("Point_1")==-1){
ObjectCreate ("Point_1",OBJ_TEXT,0,Time[time_1],Óðîâåíü_1+50*Point*p1d,0,0,0,0);
ObjectSetText("Point_1", "1", 14, "Times New Roman", Gold);}
else {
ObjectMove("Point_1", 0, Time[time_1],Óðîâåíü_1+50*Point*p1d);}
Comment("Óðîâåíü_1=",Óðîâåíü_1,"; time_1=",time_1,"\n",
"Óðîâåíü_2=",Óðîâåíü_2,"; time_2=",time_2,"\n",
"Óðîâåíü_3=",Óðîâåíü_3,"; time_3=",time_3,"\n",
"Óðîâåíü_4=",Óðîâåíü_4,"; time_4=",time_4,"\n",
"Óðîâåíü_5=",Óðîâåíü_5,"; time_5=",time_5,"\n",
"Óðîâåíü_6=",Óðîâåíü_6,"; time_6=",time_6);
return (0);
}
//+------------------------------------------------------------------+
Comments