I am trying to create a script that will draw horizontal lines on the high and low of the last candle of the W1, D1 and the Swing High and Swing Low of M15.
I seem to be having issues calling my timeframes, if that is even possible.
Am I close?
Any help from the programmers out there would be appreciated.
Thanks in advance.
I would post the file, but not sure how to do that as it requires a web address.
I seem to be having issues calling my timeframes, if that is even possible.
Inserted Code
//+------------------------------------------------------------------+ //| HighLow_W1_D1_M15 | //| Copyright 2023, NoizeUnit | //+------------------------------------------------------------------+ #property strict //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void OnStart() { // Switch to the W1 timeframe PeriodSet(Period("W1")); // Calculate the high and low prices of the current week's candle double weeklyHigh = iHigh(NULL, PERIOD_CURRENT, 0); double weeklyLow = iLow(NULL, PERIOD_CURRENT, 0); // Draw horizontal lines on the high and low points for the weekly candle ObjectCreate("WeeklyHighLine", OBJ_HLINE, 0, Time[0], weeklyHigh); ObjectSet("WeeklyHighLine", OBJPROP_COLOR, Blue); ObjectSet("WeeklyHighLine", OBJPROP_WIDTH, 1); ObjectCreate("WeeklyLowLine", OBJ_HLINE, 0, Time[0], weeklyLow); ObjectSet("WeeklyLowLine", OBJPROP_COLOR, Blue); ObjectSet("WeeklyLowLine", OBJPROP_WIDTH, 1); // Switch to the D1 timeframe PeriodSet(Period("D1")); // Calculate the high and low prices of the current day's candle double dailyHigh = iHigh(NULL, PERIOD_CURRENT, 0); double dailyLow = iLow(NULL, PERIOD_CURRENT, 0); // Draw horizontal lines on the high and low points for the daily candle ObjectCreate("DailyHighLine", OBJ_HLINE, 0, Time[0], dailyHigh); ObjectSet("DailyHighLine", OBJPROP_COLOR, Blue); ObjectSet("DailyHighLine", OBJPROP_WIDTH, 1); ObjectCreate("DailyLowLine", OBJ_HLINE, 0, Time[0], dailyLow); ObjectSet("DailyLowLine", OBJPROP_COLOR, Blue); ObjectSet("DailyLowLine", OBJPROP_WIDTH, 1); // Switch to the M15 timeframe PeriodSet(Period("M15")); // Calculate the high and low prices of the swing high and swing low on M15 timeframe double swingHigh = High[0]; double swingLow = Low[0]; for(int i = 1; i <= Bars; i++) { if(High[i] > swingHigh) swingHigh = High[i]; if(Low[i] < swingLow) swingLow = Low[i]; } // Draw horizontal lines on the swing high and swing low points for the M15 timeframe ObjectCreate("M15SwingHighLine", OBJ_HLINE, 0, Time[0], swingHigh); ObjectSet("M15SwingHighLine", OBJPROP_COLOR, DarkTurquoise); ObjectSet("M15SwingHighLine", OBJPROP_WIDTH, 1); ObjectCreate("M15SwingLowLine", OBJ_HLINE, 0, Time[0], swingLow); ObjectSet("M15SwingLowLine", OBJPROP_COLOR, DarkTurquoise); ObjectSet("M15SwingLowLine", OBJPROP_WIDTH, 1); } //+------------------------------------------------------------------+
Am I close?
Any help from the programmers out there would be appreciated.
Thanks in advance.
I would post the file, but not sure how to do that as it requires a web address.