if(PriceInfo[12].close>PriceInfo[8].close){ if(PriceInfo[13].close>PriceInfo[9].close){ ObjectCreate(_Symbol,"Buyline",OBJ_HLINE,0,0,PriceInfo[1].low); ObjectSetInteger(0,"Buyline",OBJPROP_COLOR,clrGreen); ObjectSetInteger(0,"Buyline",OBJPROP_WIDTH,3);
Use a trend line instead of a horizontal line.
Create an individual name for each additional line. It is normal to use the time of the candle in the name.
ie.
string obName = "BuyLine:"+TimeToString(iTime(_Symbol,PERIOD_CURRENT,1))

- www.mql5.com
ObjectCreate(_Symbol,obNames,OBJ_TREND,0,0,PriceInfo[1].high,0,PriceInfo[1].high); ObjectSetInteger(0,obNames,OBJPROP_RAY_RIGHT, true); ObjectSetInteger(0,obNames,OBJPROP_COLOR,clrRed); ObjectSetInteger(0,obNames,OBJPROP_WIDTH,3); ObjectMove(_Symbol,obNames,0,0,PriceInfo[1].high);
Thank you, I now can have it post multiple lines however how is the best way to do trend line because my current code doesnt work
"Doesn't work" is meaningless. Give details if you want help.
Is this MQL5 or MQL4?
You don't appear to be setting any time anchors for the trend line.
Do you really want any ray enabled, I thought that you wanted a short line that does not go on into infinity.
I am struggling to find a way to make the horizontal line only start from the bottom of the candle and go out 4 bars instead of infinite
Its in mql5,
With the following code there are no lines printed however, simply changing obj_trend to obj hline gives me multiple lines.
My issue is I dont know how to create a horizontal line that extends 4-10 bars into the future.
I currently have this
ObjectCreate(_Symbol,obNames,OBJ_TREND,0,1,PriceInfo[1].high,0,PriceInfo[1].high); ObjectSetInteger(0,obNames,OBJPROP_ANCHOR,ANCHOR_TOP); ObjectSetInteger(0,obNames,OBJPROP_RAY_RIGHT, false); ObjectSetInteger(0,obNames,OBJPROP_COLOR,clrRed); ObjectSetInteger(0,obNames,OBJPROP_WIDTH,3); ObjectMove(_Symbol,obNames,0,0,PriceInfo[1].high);
You have to assume that every bar will exist — they don't. What if there are no ticks during a specific candle period? There can be minutes between ticks during the Asian session, think M1 chart. Larger charts, think weekend, market holiday (country and broker specific.) requires knowledge of when your broker stops and starts (not necessary the same as the market.)
Whatever you are thinking, stop.
Your create call is bogus.
ObjectCreate(_Symbol,obNames,OBJ_TREND,0,1,PriceInfo[1].high,0,PriceInfo[1].high); //In MQL5 the 1st parameter is the Chart ID ObjectSetInteger(0,obNames,OBJPROP_ANCHOR,ANCHOR_TOP); //Why are you setting ANCHOR_TOP for a trendline??? ObjectSetInteger(0,obNames,OBJPROP_RAY_RIGHT, false); ObjectSetInteger(0,obNames,OBJPROP_COLOR,clrRed); ObjectSetInteger(0,obNames,OBJPROP_WIDTH,3); ObjectMove(_Symbol,obNames,0,0,PriceInfo[1].high); //In MQL5 the 1st parameter is the Chart ID
You don't appear to be setting any time anchors for the trend line.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am struggling to find a way to make the horizontal line only start from the bottom of the candle and go out 4 bars instead of infinite
I also don't know how to place horizontal lines at each of these conditions instead of it repainting, I would like it to hold its location and just spawn a new one