SQ9 (Time)_001
Download scriptThis script is designed to generate a series of visual projections on a trading chart based on specific historical price points and time intervals. It treats market data as a geometric cycle, allowing users to project potential "echoes" or recurring patterns into the future.
Core Concept
The logic operates on the principle that price movements can be associated with specific angles and cycles. By providing an initial "anchor" (a specific date and a specific price), the script calculates where future price actions might occur based on mathematical rotations. Instead of just looking at trends, this tool treats time and price as cyclical dimensions.
How the Logic Works
1. The Anchor Point The process begins with a user-defined starting point: a specific date and price. The script places a visual marker (an arrow) on the chart at this exact location. This serves as the origin for all subsequent calculations.
2. Price-to-Angle Conversion The script takes the starting price and converts it into a degree value (between 0 and 360). It handles different currency types automatically to ensure accuracy. This conversion allows the script to treat the market's price level as a position on a circle, which is necessary for calculating "rotations."
3. Mathematical Projections Based on the starting angle, the script calculates future dates using a specific power-based formula. The user can choose how many of these projections they want to see on their chart (e.g., the next 5 occurrences).
4. Time Interval Scaling One of the most versatile features of this logic is its ability to project these cycles across different timeframes. The script can automatically calculate and draw vertical lines for:
- Weeks: Large-scale cyclical moves.
- Days: Intermediate cycles.
- Hours: Intraday patterns.
- Minutes: Short-term, high-frequency fluctuations.
The user can toggle these specific timeframes on or off in the settings to declutter the chart.
5. Geometric Offsets (90-Degree Shifts) To provide a more comprehensive view of potential market "turning points," the script includes an optional feature to plot 90-degree offsets. If enabled, the logic identifies the primary projection and then automatically calculates and draws additional dashed lines at 90, 180, and 270-degree intervals from that starting angle. This helps visualize a full "orbit" of potential price activity around the original starting point.
Visual Output
- Solid Lines: Represent the primary mathematical projections for the chosen timeframes (Days, Weeks, etc.).
- Dashed Lines: Represent the 90-degree offset projections, providing a secondary layer of geometric data.
- Color Coding: Each timeframe is assigned a unique color (e.g., Pink for Weeks, Red for Days) to help the user distinguish between long-term and short-term cyclical projections at a glance.
//+------------------------------------------------------------------+
//| 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 14: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=Pink;
extern color Color_Days=Red;
extern color Color_Hours=Yellow;
extern color Color_Minutes=Blue;
int init()
{
return(0);
}
int deinit()
{
int RotationIndex=0;
ObjectDelete("StartTimePrice");
for(RotationIndex=1;RotationIndex<=NumberOfProjections;RotationIndex++)
{
ObjectDelete(RotationIndex + " wVLine");
ObjectDelete(RotationIndex + " dVLine");
ObjectDelete(RotationIndex + " hVLine");
ObjectDelete(RotationIndex + " mVLine");
ObjectDelete(RotationIndex + " wOffVLine");
ObjectDelete(RotationIndex + " dOffVLine");
ObjectDelete(RotationIndex + " hOffVLine");
ObjectDelete(RotationIndex + " mOffVLine");
}
return(0);
}
int start()
{
int Degrees=0;
int RelationshipNumber=0;
int OffsetNumber=0;
int RotationIndex=0;
int FutureDate=0;
if(ObjectFind("StartTimePrice") != 0)
{
ObjectCreate("StartTimePrice", OBJ_ARROW, 0, StartTime, StartPrice);
ObjectSet("StartTimePrice", OBJPROP_ARROWCODE, 3);
ObjectSet("StartTimePrice", OBJPROP_COLOR, White);
}
else
{
ObjectMove("StartTimePrice", 0, StartTime, StartPrice);
}
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