Wave Labels
Download scriptThis script is designed as a visual labeling tool for traders who use chart analysis to identify specific price patterns. Its primary purpose is to allow you to manually mark and organize "Wave" sequences on your trading screen with customized text labels.
How the Logic Works
The script functions based on a user-initiated action on the chart. Instead of automatically analyzing the market, it waits for you to interact with the platform to define a starting point. Here is the step-by-step breakdown of its logic:
1. User Interaction and Placement When you trigger the script, it captures the exact coordinates—both the price and the specific moment in time—where you have interacted with the chart. This serves as "Point A," your anchor for the sequence.
2. Automated Horizontal Alignment Once the starting point is established, the script automatically calculates four subsequent positions to the right of your initial mark. It uses pre-defined spacing intervals (measured in bars) to determine exactly where the next letters should appear. This ensures that your labels are perfectly spaced and aligned linearly across the timeline.
3. Customizable Visual Branding The tool is highly adjustable to fit your personal charting style. You can modify several visual parameters, including:
- Content: Choose what letters or characters (e.g., A, B, C, D, E) appear on the chart.
- Style: Set the specific font name, text size, and color to ensure the labels are easily readable against your background.
- Spacing: Adjust how many bars of distance should exist between each consecutive letter.
4. Unique Label Generation To prevent technical conflicts on the chart, the script automatically assigns a unique internal ID to every set of labels it creates by incorporating the current system time into the name. This allows you to place multiple different wave sequences on the same chart without them interfering with one another.
Summary of Use
In simple terms, this is a "stamping" tool. You tell the script where the start of a pattern is, and it automatically lays out a perfectly formatted sequence of labels ahead of that point, saving you the manual effort of placing each individual character by hand.
//+------------------------------------------------------------------+
//| Wave Labels.mq4 |
//| Copyright 2012, bdeyes |
//| http://www.mql4.com/users/bdeyes |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, bdeyes"
#property link "http://www.mql4.com/users/bdeyes"
#include <stdlib.mqh>
//+------ CHANGE HERE CHARACTER PARAMETERS -----------------------+
string Text1 = "A"; // Enter Text to place on screen - leave only quotes to not print (i.e "A" > "" )
string Text2 = "B"; // Enter Text to place on screen
string Text3 = "C"; // Enter Text to place on screen
string Text4 = "D"; // Enter Text to place on screen
string Text5 = "E"; // Enter Text to place on screen
string Text_font = "Arial Bold"; // font of text
int Text_fontsize = 14; // size of text
color Text_color = Red; // color of text
int TextBarsAhead2 = 7; // # bars to space 2nd letter from first
int TextBarsAhead3 = 14; // # bars to space 3rd letter from first
int TextBarsAhead4 = 21; // # bars to space 4th letter from first
int TextBarsAhead5 = 28; // # bars to space 5th letter from first
//+------------------------------------------------------------------+
//+-----------------------------SCRIPT CODE--------------------------+
int start()
{
double price = WindowPriceOnDropped(); // find the price point where dropped
datetime Time1 = WindowTimeOnDropped(); // find the time point where dropped
int TimeNow = TimeCurrent(); // get the current time ( makes name unique)
datetime Time2 = Time1+TextBarsAhead2*Period()*60;
datetime Time3 = Time1+TextBarsAhead3*Period()*60;
datetime Time4 = Time1+TextBarsAhead4*Period()*60;
datetime Time5 = Time1+TextBarsAhead5*Period()*60;
string gap = " "; // spacing between text characters
string text = Text1+gap+Text2+gap+Text3+gap+Text4+gap+Text5; // put the text in a line
TextToPrint ("Wave labels1" + TimeNow, Text1, Text_fontsize, Text_font, Text_color, Time1, price); //print 1st letter
TextToPrint ("Wave labels2" + TimeNow, Text2, Text_fontsize, Text_font, Text_color, Time2, price); //print 1st letter
TextToPrint ("Wave labels3" + TimeNow, Text3, Text_fontsize, Text_font, Text_color, Time3, price); //print 1st letter
TextToPrint ("Wave labels4" + TimeNow, Text4, Text_fontsize, Text_font, Text_color, Time4, price); //print 1st letter
TextToPrint ("Wave labels5" + TimeNow, Text5, Text_fontsize, Text_font, Text_color, Time5, price); //print 1st letter
return(0);
}
//+------------------------------------------------------------------+
void TextToPrint(string TextName, string LabelText, int FontSize, string FontName, color TextColor, datetime Time0, double Price0)
{
if(StringLen(LabelText)<1) return(0);
ObjectCreate(TextName, OBJ_TEXT, 0, Time0, Price0);
ObjectSetText(TextName, LabelText, FontSize, FontName, TextColor);
}
Comments