SQ9 (Time)
Download scriptThis script is designed to project specific time-based markers onto a trading chart based on a price point you provide. It essentially takes a single price and "calculates" future dates where certain mathematical relationships might occur, displaying them as vertical lines to help traders identify potential areas of interest.
How the Logic Works
1. The Foundation (Price to Degrees) The process begins with two pieces of information: a specific Start Price and a Start Time. The script takes the price you entered and converts it into a numerical "Degree" value. It adjusts this calculation automatically depending on whether you are trading a Japanese Yen pair or another currency to ensure the accuracy of the resulting angle.
2. Calculating Projections Once the script has the starting degree, it performs a series of mathematical projections. Instead of just looking at one point in time, it calculates multiple "rotations" (the number of which you can choose in the settings). It uses a specific formula to determine how far into the future these points should land based on the initial angle.
3. Time Interval Mapping The script is versatile and allows you to see these projections across different timeframes. You can toggle whether you want the calculated dates to appear as:
- Weeks
- Days
- Hours
- Minutes
Each of these will be plotted on your chart as vertical lines. By choosing which ones to enable, you can customize the density of the information shown on your screen.
4. Geometry and Offsets (The 90-Degree Rule) One of the key features of this script is its ability to plot "Offsets." If enabled, the logic doesn't just project the primary angle; it also calculates perpendicular points (at 90, 180, and 270 degrees relative to the start). This creates a geometric web of lines on your chart, helping you see multiple related points of interest simultaneously.
5. Visual Organization To keep the chart readable, the script assigns different colors to the various timeframes (e.g., Weeks might be Lime, Days might be Red, etc.). It also distinguishes between "Primary" projections (solid lines) and "Offset" projections (dashed/dotted lines).
Summary for the User
Think of this tool as a geometric calendar. You give it a starting point in price and time, and the script "rotates" that data forward into the future. It then draws vertical markers on your chart so you can visually see where those mathematical rotations land on different time horizons, allowing for a more structured way to visualize potential market coordinates.
//+------------------------------------------------------------------+
//| SQ9 (Time).mq4 |
//| Copyright © 2006, Matt Trigwell |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Matt Trigwell"
#property link "m.trigwell@gmail.com"
#property indicator_chart_window
extern datetime StartTime=D'2006.08.21 08:00';
extern double StartPrice=1.2939;
extern int NumberOfProjections=5;
extern bool Plot90DegreeOffsets=true;
extern bool SquareWeeks=false;
extern bool SquareDays=true;
extern bool SquareHours=false;
extern bool SquareMinutes=false;
extern color Color_Weeks=Lime;
extern color Color_Days=Red;
extern color Color_Hours=Yellow;
extern color Color_Minutes=Blue;
int init()
{
return(0);
}
int deinit()
{
int RotationIndex=0;
for(RotationIndex=1;RotationIndex<=NumberOfProjections;RotationIndex++)
{
ObjectDelete(RotationIndex + " wVLine");
ObjectDelete(RotationIndex + " dVLine");
ObjectDelete(RotationIndex + " hVLine");
ObjectDelete(RotationIndex + " mVLine");
}
return(0);
}
int start()
{
int Degrees=0;
int RelationshipNumber=0;
int OffsetNumber=0;
int RotationIndex=0;
int FutureDate=0;
Degrees = ConvertToDegrees(StartPrice);
for(RotationIndex=1;RotationIndex<=NumberOfProjections;RotationIndex++)
{
RelationshipNumber = AngleRelationship(RotationIndex,Degrees);
if(SquareWeeks==true)
{
FutureDate = DateAdd("w",RelationshipNumber,StartTime);
if(ObjectFind(RotationIndex + " wVLine") != 0)
{
ObjectCreate(RotationIndex + " wVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " wVLine", OBJPROP_STYLE, STYLE_SOLID);
ObjectSet(RotationIndex + " wVLine", OBJPROP_COLOR, Color_Weeks);
}
else
{
ObjectMove(RotationIndex + " wVLine", 0, FutureDate, 0);
}
//PLOT THE 90 DEGREE OFFSETS TO THE FIRST ANGLE
if(Plot90DegreeOffsets==true)
{
if(Degrees < 90)
{
OffsetNumber = AngleRelationship(RotationIndex,Degrees+90);
FutureDate = DateAdd("w",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " wOffVLine") != 0)
{
ObjectCreate(RotationIndex + " wOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " wOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " wOffVLine", OBJPROP_COLOR, Color_Weeks);
}
else
{
ObjectMove(RotationIndex + " wOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees+180);
FutureDate = DateAdd("w",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " wOffVLine") != 0)
{
ObjectCreate(RotationIndex + " wOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " wOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " wOffVLine", OBJPROP_COLOR, Color_Weeks);
}
else
{
ObjectMove(RotationIndex + " wOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees+270);
FutureDate = DateAdd("w",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " wOffVLine") != 0)
{
ObjectCreate(RotationIndex + " wOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " wOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " wOffVLine", OBJPROP_COLOR, Color_Weeks);
}
else
{
ObjectMove(RotationIndex + " wOffVLine", 0, FutureDate, 0);
}
}
else if(Degrees >=90 && Degrees < 180)
{
OffsetNumber = AngleRelationship(RotationIndex,Degrees-90);
FutureDate = DateAdd("w",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " wOffVLine") != 0)
{
ObjectCreate(RotationIndex + " wOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " wOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " wOffVLine", OBJPROP_COLOR, Color_Weeks);
}
else
{
ObjectMove(RotationIndex + " wOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees+90);
FutureDate = DateAdd("w",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " wOffVLine") != 0)
{
ObjectCreate(RotationIndex + " wOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " wOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " wOffVLine", OBJPROP_COLOR, Color_Weeks);
}
else
{
ObjectMove(RotationIndex + " wOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees+180);
FutureDate = DateAdd("w",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " wOffVLine") != 0)
{
ObjectCreate(RotationIndex + " wOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " wOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " wOffVLine", OBJPROP_COLOR, Color_Weeks);
}
else
{
ObjectMove(RotationIndex + " wOffVLine", 0, FutureDate, 0);
}
}
else if(Degrees >=180 && Degrees < 270)
{
OffsetNumber = AngleRelationship(RotationIndex,Degrees-180);
FutureDate = DateAdd("w",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " wOffVLine") != 0)
{
ObjectCreate(RotationIndex + " wOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " wOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " wOffVLine", OBJPROP_COLOR, Color_Weeks);
}
else
{
ObjectMove(RotationIndex + " wOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees-90);
FutureDate = DateAdd("w",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " wOffVLine") != 0)
{
ObjectCreate(RotationIndex + " wOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " wOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " wOffVLine", OBJPROP_COLOR, Color_Weeks);
}
else
{
ObjectMove(RotationIndex + " wOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees+90);
FutureDate = DateAdd("w",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " wOffVLine") != 0)
{
ObjectCreate(RotationIndex + " wOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " wOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " wOffVLine", OBJPROP_COLOR, Color_Weeks);
}
else
{
ObjectMove(RotationIndex + " wOffVLine", 0, FutureDate, 0);
}
}
else if(Degrees >=270)
{
OffsetNumber = AngleRelationship(RotationIndex,Degrees-270);
FutureDate = DateAdd("w",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " wOffVLine") != 0)
{
ObjectCreate(RotationIndex + " wOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " wOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " wOffVLine", OBJPROP_COLOR, Color_Weeks);
}
else
{
ObjectMove(RotationIndex + " wOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees-180);
FutureDate = DateAdd("w",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " wOffVLine") != 0)
{
ObjectCreate(RotationIndex + " wOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " wOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " wOffVLine", OBJPROP_COLOR, Color_Weeks);
}
else
{
ObjectMove(RotationIndex + " wOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees-90);
FutureDate = DateAdd("w",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " wOffVLine") != 0)
{
ObjectCreate(RotationIndex + " wOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " wOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " wOffVLine", OBJPROP_COLOR, Color_Weeks);
}
else
{
ObjectMove(RotationIndex + " wOffVLine", 0, FutureDate, 0);
}
}
}
}
if(SquareDays==true)
{
FutureDate = DateAdd("d",RelationshipNumber,StartTime);
if(ObjectFind(RotationIndex + " dVLine") != 0)
{
ObjectCreate(RotationIndex + " dVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " dVLine", OBJPROP_STYLE, STYLE_SOLID);
ObjectSet(RotationIndex + " dVLine", OBJPROP_COLOR, Color_Days);
}
else
{
ObjectMove(RotationIndex + " dVLine", 0, FutureDate, 0);
}
//PLOT THE 90 DEGREE OFFSETS TO THE FIRST ANGLE
if(Plot90DegreeOffsets==true)
{
if(Degrees < 90)
{
OffsetNumber = AngleRelationship(RotationIndex,Degrees+90);
FutureDate = DateAdd("d",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " dOffVLine") != 0)
{
ObjectCreate(RotationIndex + " dOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " dOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " dOffVLine", OBJPROP_COLOR, Color_Days);
}
else
{
ObjectMove(RotationIndex + " dOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees+180);
FutureDate = DateAdd("d",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " dOffVLine") != 0)
{
ObjectCreate(RotationIndex + " dOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " dOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " dOffVLine", OBJPROP_COLOR, Color_Days);
}
else
{
ObjectMove(RotationIndex + " dOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees+270);
FutureDate = DateAdd("d",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " dOffVLine") != 0)
{
ObjectCreate(RotationIndex + " dOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " dOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " dOffVLine", OBJPROP_COLOR, Color_Days);
}
else
{
ObjectMove(RotationIndex + " dOffVLine", 0, FutureDate, 0);
}
}
else if(Degrees >=90 && Degrees < 180)
{
OffsetNumber = AngleRelationship(RotationIndex,Degrees-90);
FutureDate = DateAdd("d",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " dOffVLine") != 0)
{
ObjectCreate(RotationIndex + " dOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " dOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " dOffVLine", OBJPROP_COLOR, Color_Days);
}
else
{
ObjectMove(RotationIndex + " dOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees+90);
FutureDate = DateAdd("d",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " dOffVLine") != 0)
{
ObjectCreate(RotationIndex + " dOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " dOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " dOffVLine", OBJPROP_COLOR, Color_Days);
}
else
{
ObjectMove(RotationIndex + " dOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees+180);
FutureDate = DateAdd("d",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " dOffVLine") != 0)
{
ObjectCreate(RotationIndex + " dOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " dOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " dOffVLine", OBJPROP_COLOR, Color_Days);
}
else
{
ObjectMove(RotationIndex + " dOffVLine", 0, FutureDate, 0);
}
}
else if(Degrees >=180 && Degrees < 270)
{
OffsetNumber = AngleRelationship(RotationIndex,Degrees-180);
FutureDate = DateAdd("d",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " dOffVLine") != 0)
{
ObjectCreate(RotationIndex + " dOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " dOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " dOffVLine", OBJPROP_COLOR, Color_Days);
}
else
{
ObjectMove(RotationIndex + " dOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees-90);
FutureDate = DateAdd("d",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " dOffVLine") != 0)
{
ObjectCreate(RotationIndex + " dOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " dOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " dOffVLine", OBJPROP_COLOR, Color_Days);
}
else
{
ObjectMove(RotationIndex + " dOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees+90);
FutureDate = DateAdd("d",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " dOffVLine") != 0)
{
ObjectCreate(RotationIndex + " dOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " dOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " dOffVLine", OBJPROP_COLOR, Color_Days);
}
else
{
ObjectMove(RotationIndex + " dOffVLine", 0, FutureDate, 0);
}
}
else if(Degrees >=270)
{
OffsetNumber = AngleRelationship(RotationIndex,Degrees-270);
FutureDate = DateAdd("d",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " dOffVLine") != 0)
{
ObjectCreate(RotationIndex + " dOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " dOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " dOffVLine", OBJPROP_COLOR, Color_Days);
}
else
{
ObjectMove(RotationIndex + " dOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees-180);
FutureDate = DateAdd("d",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " dOffVLine") != 0)
{
ObjectCreate(RotationIndex + " dOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " dOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " dOffVLine", OBJPROP_COLOR, Color_Days);
}
else
{
ObjectMove(RotationIndex + " dOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees-90);
FutureDate = DateAdd("d",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " dOffVLine") != 0)
{
ObjectCreate(RotationIndex + " dOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " dOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " dOffVLine", OBJPROP_COLOR, Color_Days);
}
else
{
ObjectMove(RotationIndex + " dOffVLine", 0, FutureDate, 0);
}
}
}
}
if(SquareHours==true)
{
FutureDate = DateAdd("h",RelationshipNumber,StartTime);
if(ObjectFind(RotationIndex + " hVLine") != 0)
{
ObjectCreate(RotationIndex + " hVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " hVLine", OBJPROP_STYLE, STYLE_SOLID);
ObjectSet(RotationIndex + " hVLine", OBJPROP_COLOR, Color_Hours);
}
else
{
ObjectMove(RotationIndex + " hVLine", 0, FutureDate, 0);
}
//PLOT THE 90 DEGREE OFFSETS TO THE FIRST ANGLE
if(Plot90DegreeOffsets==true)
{
if(Degrees < 90)
{
OffsetNumber = AngleRelationship(RotationIndex,Degrees+90);
FutureDate = DateAdd("h",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " hOffVLine") != 0)
{
ObjectCreate(RotationIndex + " hOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " hOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " hOffVLine", OBJPROP_COLOR, Color_Hours);
}
else
{
ObjectMove(RotationIndex + " hOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees+180);
FutureDate = DateAdd("h",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " hOffVLine") != 0)
{
ObjectCreate(RotationIndex + " hOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " hOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " hOffVLine", OBJPROP_COLOR, Color_Hours);
}
else
{
ObjectMove(RotationIndex + " hOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees+270);
FutureDate = DateAdd("h",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " hOffVLine") != 0)
{
ObjectCreate(RotationIndex + " hOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " hOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " hOffVLine", OBJPROP_COLOR, Color_Hours);
}
else
{
ObjectMove(RotationIndex + " hOffVLine", 0, FutureDate, 0);
}
}
else if(Degrees >=90 && Degrees < 180)
{
OffsetNumber = AngleRelationship(RotationIndex,Degrees-90);
FutureDate = DateAdd("h",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " hOffVLine") != 0)
{
ObjectCreate(RotationIndex + " hOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " hOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " hOffVLine", OBJPROP_COLOR, Color_Hours);
}
else
{
ObjectMove(RotationIndex + " hOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees+90);
FutureDate = DateAdd("h",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " hOffVLine") != 0)
{
ObjectCreate(RotationIndex + " hOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " hOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " hOffVLine", OBJPROP_COLOR, Color_Hours);
}
else
{
ObjectMove(RotationIndex + " hOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees+180);
FutureDate = DateAdd("h",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " hOffVLine") != 0)
{
ObjectCreate(RotationIndex + " hOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " hOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " hOffVLine", OBJPROP_COLOR, Color_Hours);
}
else
{
ObjectMove(RotationIndex + " hOffVLine", 0, FutureDate, 0);
}
}
else if(Degrees >=180 && Degrees < 270)
{
OffsetNumber = AngleRelationship(RotationIndex,Degrees-180);
FutureDate = DateAdd("h",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " hOffVLine") != 0)
{
ObjectCreate(RotationIndex + " hOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " hOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " hOffVLine", OBJPROP_COLOR, Color_Hours);
}
else
{
ObjectMove(RotationIndex + " hOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees-90);
FutureDate = DateAdd("h",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " hOffVLine") != 0)
{
ObjectCreate(RotationIndex + " hOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " hOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " hOffVLine", OBJPROP_COLOR, Color_Hours);
}
else
{
ObjectMove(RotationIndex + " hOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees+90);
FutureDate = DateAdd("h",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " hOffVLine") != 0)
{
ObjectCreate(RotationIndex + " hOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " hOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " hOffVLine", OBJPROP_COLOR, Color_Hours);
}
else
{
ObjectMove(RotationIndex + " hOffVLine", 0, FutureDate, 0);
}
}
else if(Degrees >=270)
{
OffsetNumber = AngleRelationship(RotationIndex,Degrees-270);
FutureDate = DateAdd("h",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " hOffVLine") != 0)
{
ObjectCreate(RotationIndex + " hOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " hOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " hOffVLine", OBJPROP_COLOR, Color_Hours);
}
else
{
ObjectMove(RotationIndex + " hOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees-180);
FutureDate = DateAdd("h",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " hOffVLine") != 0)
{
ObjectCreate(RotationIndex + " hOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " hOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " hOffVLine", OBJPROP_COLOR, Color_Hours);
}
else
{
ObjectMove(RotationIndex + " hOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees-90);
FutureDate = DateAdd("h",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " hOffVLine") != 0)
{
ObjectCreate(RotationIndex + " hOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " hOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " hOffVLine", OBJPROP_COLOR, Color_Hours);
}
else
{
ObjectMove(RotationIndex + " hOffVLine", 0, FutureDate, 0);
}
}
}
}
if(SquareMinutes==true)
{
FutureDate = DateAdd("m",RelationshipNumber,StartTime);
if(ObjectFind(RotationIndex + " mVLine") != 0)
{
ObjectCreate(RotationIndex + " mVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " mVLine", OBJPROP_STYLE, STYLE_SOLID);
ObjectSet(RotationIndex + " mVLine", OBJPROP_COLOR, Color_Minutes);
}
else
{
ObjectMove(RotationIndex + " mVLine", 0, FutureDate, 0);
}
//PLOT THE 90 DEGREE OFFSETS TO THE FIRST ANGLE
if(Plot90DegreeOffsets==true)
{
if(Degrees < 90)
{
OffsetNumber = AngleRelationship(RotationIndex,Degrees+90);
FutureDate = DateAdd("m",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " mOffVLine") != 0)
{
ObjectCreate(RotationIndex + " mOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " mOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " mOffVLine", OBJPROP_COLOR, Color_Minutes);
}
else
{
ObjectMove(RotationIndex + " mOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees+180);
FutureDate = DateAdd("m",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " mOffVLine") != 0)
{
ObjectCreate(RotationIndex + " mOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " mOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " mOffVLine", OBJPROP_COLOR, Color_Minutes);
}
else
{
ObjectMove(RotationIndex + " mOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees+270);
FutureDate = DateAdd("m",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " mOffVLine") != 0)
{
ObjectCreate(RotationIndex + " mOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " mOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " mOffVLine", OBJPROP_COLOR, Color_Minutes);
}
else
{
ObjectMove(RotationIndex + " mOffVLine", 0, FutureDate, 0);
}
}
else if(Degrees >=90 && Degrees < 180)
{
OffsetNumber = AngleRelationship(RotationIndex,Degrees-90);
FutureDate = DateAdd("m",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " mOffVLine") != 0)
{
ObjectCreate(RotationIndex + " mOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " mOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " mOffVLine", OBJPROP_COLOR, Color_Minutes);
}
else
{
ObjectMove(RotationIndex + " mOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees+90);
FutureDate = DateAdd("m",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " mOffVLine") != 0)
{
ObjectCreate(RotationIndex + " mOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " mOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " mOffVLine", OBJPROP_COLOR, Color_Minutes);
}
else
{
ObjectMove(RotationIndex + " mOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees+180);
FutureDate = DateAdd("m",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " mOffVLine") != 0)
{
ObjectCreate(RotationIndex + " mOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " mOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " mOffVLine", OBJPROP_COLOR, Color_Minutes);
}
else
{
ObjectMove(RotationIndex + " mOffVLine", 0, FutureDate, 0);
}
}
else if(Degrees >=180 && Degrees < 270)
{
OffsetNumber = AngleRelationship(RotationIndex,Degrees-180);
FutureDate = DateAdd("m",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " mOffVLine") != 0)
{
ObjectCreate(RotationIndex + " mOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " mOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " mOffVLine", OBJPROP_COLOR, Color_Minutes);
}
else
{
ObjectMove(RotationIndex + " mOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees-90);
FutureDate = DateAdd("m",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " mOffVLine") != 0)
{
ObjectCreate(RotationIndex + " mOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " mOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " mOffVLine", OBJPROP_COLOR, Color_Minutes);
}
else
{
ObjectMove(RotationIndex + " mOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees+90);
FutureDate = DateAdd("m",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " mOffVLine") != 0)
{
ObjectCreate(RotationIndex + " mOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " mOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " mOffVLine", OBJPROP_COLOR, Color_Minutes);
}
else
{
ObjectMove(RotationIndex + " mOffVLine", 0, FutureDate, 0);
}
}
else if(Degrees >=270)
{
OffsetNumber = AngleRelationship(RotationIndex,Degrees-270);
FutureDate = DateAdd("m",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " mOffVLine") != 0)
{
ObjectCreate(RotationIndex + " mOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " mOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " mOffVLine", OBJPROP_COLOR, Color_Minutes);
}
else
{
ObjectMove(RotationIndex + " mOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees-180);
FutureDate = DateAdd("m",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " mOffVLine") != 0)
{
ObjectCreate(RotationIndex + " mOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " mOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " mOffVLine", OBJPROP_COLOR, Color_Minutes);
}
else
{
ObjectMove(RotationIndex + " mOffVLine", 0, FutureDate, 0);
}
OffsetNumber = AngleRelationship(RotationIndex,Degrees-90);
FutureDate = DateAdd("m",OffsetNumber,StartTime);
if(ObjectFind(RotationIndex + " mOffVLine") != 0)
{
ObjectCreate(RotationIndex + " mOffVLine", OBJ_VLINE, 0, FutureDate, 0);
ObjectSet(RotationIndex + " mOffVLine", OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSet(RotationIndex + " mOffVLine", OBJPROP_COLOR, Color_Minutes);
}
else
{
ObjectMove(RotationIndex + " mOffVLine", 0, FutureDate, 0);
}
}
}
}
}
return(0);
}
int ConvertToDegrees(double Input)
{
int Degrees=0;
double Temp=0;
if(StringFind(Symbol(),"JPY",0) == -1)
{
Input = Input * 10000;
}
else
{
Input = Input * 100;
}
Degrees = MathMod( ((MathSqrt(Input) * 180) -225),360);
return(Degrees);
}
double AngleRelationship(int Rotation, double Angle)
{
double Value=0;
Value = MathPow(((2 * Rotation) + ((2 * Angle)/360) + 1.25),2);
return(Value);
}
int DateAdd(string Interval, int Number, datetime Date)
{
//Interval: m - Minute, h - Hours, d - Days
int FutureTime=0;
int IntervalSeconds=0;
//Convert everything to seconds
if(Interval == "w")
{
IntervalSeconds = 604800 * Number;
}
else if(Interval == "d")
{
IntervalSeconds = 86400 * Number;
}
else if(Interval == "h")
{
IntervalSeconds = 3600 * Number;
}
else if(Interval == "m")
{
IntervalSeconds = 60 * Number;
}
if(IntervalSeconds > 0)
{
FutureTime = Date + IntervalSeconds;
//Print("FutureTime=",TimeToStr(FutureTime));
}
return(FutureTime);
}
Comments