Draw line from High to High - page 2

 
William Roeder #:

In that case you simplify remove the date portion from TimeCurrent()

          date/time (2017)
          Find bar of the same time one day ago - MQL4 programming forum (2017)
Thanks!
 

Hi,

i've been testing the code and its working fine with me, only there is an odd behavior couldn't find the solution or what is the reason.

as the screenshot below show, on the first bar on the new day the line will flip to the back, this is only on the first bar on every new day!!?

below additional screen added


 

i just noticed, its always the same numbers 

Today Time: 1604898000

Today High Value: 1965.5


 
Younis Alsulaimi:

Hi everyone, i'm new to programming and to this nice forum :D

with this code i'm trying to draw a line from the previous day high to the current day high,

i got the values for each but couldn't specify the time correctly 


You are learning and you coded this, impressive, using 
time[0]

... is dependent on the TF ... since you are dealing on the daily highs only ... you could create a datetime variable, assigning a variable to it

datetime t2; // Time 2 >>> todays' high
t2 = iTime(_Symbol, PERIOD_D1, 0);

//--- Then use "t2" and "YesterdayDate" when creating your line

Note:

If the chart is moving up, the high t2 would be changing 

 
Thank-god Avwerosuoghene Odukudu #:
You are learning and you coded this, impressive, using 

... is dependent on the TF ... since you are dealing on the daily highs only ... you could create a datetime variable, assigning a variable to it

Note:

If the chart is moving up, the high t2 would be changing 

Honestly, I couldn't figure out how to do this way,

currently I've added an if statment to the line create:

if(TodayHighCandleTime!=1604898000)
{
ObjectDelete(.......
ObjectCreate(.......
}

I know its not practical,but it solved the issue :D

 

I believe the only issue that if the high came at this candle I’m ignoring, then it will not consider it, I didn't come across this on tester, but obviously that’s what will happen in this case I guess.

 
Younis Alsulaimi #:

Honestly, I couldn't figure out how to do this way,

currently I've added an if statment to the line create:

I know its not practical,but it solved the issue :D

it would do it, but, am sure you want it to touch both highs( from start to end) then ray left or right, achieving that would not be difficult

      datetime YesterdayDate = iTime(_Symbol, PERIOD_D1, 1);            // Yesterday Date
      datetime t0 = iTime(_Symbol, PERIOD_D1, 0);                       // Today Date
      double   c1, /*Highest Value (Yesterday)*/   c0;                  // Today Highest value
      string Lname = "HighTrendLine";                                   // Name of the Line, having to type "HighTrendLine is too stranous"
      
      c1 = iHigh(_Symbol, PERIOD_D1, 1);
      c0 = iHigh(_Symbol, PERIOD_D1, 0);
      
      //--- Draw line
      // Create a New Line, if only the chart is not having the Line
      if (ObjectFind(0, Lname) < 0)
         ObjectCreate(0, Lname, OBJ_TREND, 0, YesterdayDate, c1, t0, c0 );
      
      // Update the properties of the line if already on the chart
      ObjectSetInteger(0, Lname, OBJPROP_COLOR, clrWhite); 
      ObjectSetInteger(0, Lname, OBJPROP_STYLE, STYLE_DASHDOT);
      ObjectSetInteger(0, Lname, OBJPROP_WIDTH, 1);
      
      // OBJPROP_Ray ==> Is for vertical Lines, it has no effect on Horizontal line
      ObjectSetInteger(0, Lname, OBJPROP_RAY_RIGHT, true);
      
      //--- The only property that may change is if todays' highs changes, so we 
      //--- need to update the high if it changes
      ObjectSetDouble(0, Lname, OBJPROP_PRICE, 0, c1);
      ObjectSetDouble(0, Lname, OBJPROP_PRICE, 1, c0);      // If you change the Chart symbol, the value of the previous days' high needs to be updated as well
      
      // Show Figures on chart
      Comment( "Yesterday High Time:\t", YesterdayDate,
               "\nYesterday High Value:\t", c1,
               "\nToday Time:\t", t0,
               "\nToday High Value:\t", c0);