mq4 Code help for trend lines starting at a specific time and date

 

Hi all,

Pretty raw with coding and have hit a wall. I don't mind admitting that I've backwards engineered some code on an indicator I found online to make it work for me. It's a manual pivot where I enter the H, L & C and it plots the pivots on a chart. However it's using a horizontal line and I've found from research that you can't specify a date and time on a horizontal line but just a price.

As I mainly trade indicies and not FX I need to pivot lines to start at a specific time. So for example I'd need them to start at 07:00 GMT+1 for FTSE and DAX.

I know the code is obj_TREND but that's as far as I've got. Below is a snippet of the code I've got for drawing one of the horizontal lines. Just not sure how to amend for the OBJ_TREND.


ObjectCreate(IndiName+"_P label", OBJ_TEXT, 0, LabelShiftTime, Pivot);
ObjectSetText(IndiName+"_P label", "Pivot", 8, "Arial", Black);
      
ObjectCreate(IndiName+"_P line", OBJ_HLINE, 0, LineShiftTime, Pivot);
ObjectSet(IndiName+"_P line", OBJPROP_STYLE, STYLE_DASH);
ObjectSet(IndiName+"_P line", OBJPROP_COLOR, Black);
 
Chris Taylor: Just not sure how to amend for the OBJ_TREND.

Change the type. Add the second time/price coordinate.

 
In future please post in the correct section
I will move your topic to the MQL4 and Metatrader 4 section.
 
William Roeder:

Change the type. Add the second time/price coordinate.

Still not sure what you mean.

I've got this but not sure what you mean about the time/price coordinate

ObjectCreate(IndiName+"_P line", OBJ_TREND, 2, LineShiftTime, YC);
 

Exactly what he said add the second set of parameters currently you only have the staring point.

Read the documentation.

ObjectCreate(IndiName+"_P line", OBJ_TREND, 2, LineShiftTime, YC, TimeCurrent(), YC);
Reason: