"ObjectGetValueByTime" return different value after the weekend by different testing way(Especially the trendline)?

 

For example, in my EA, i need to get the value from a trendline , but if there is a weekend, i will get different value by getting different testing period.(seems calculating weekend in one case)

1.If i selet 2022.8.1 - 2022.9.1

2.If i selet 2022.8.8 - 2022.9.1

The value return by ObjectGetValueByTime is different , but the trendline and the time are the same(In text, trendline number are different,  because different period named different ,but the trendline in chart are the same).

In first case, the value seems caculate weekend, so the value is smaller than case2.  But there is no bar in weedend. So how can I adjust this difference? Generally, I don't need to calculate the weekend when testing my EA for a year or more.

 
Jia Run Yuan:

For example, in my EA, i need to get the value from a trendline , but if there is a weekend, i will get different value by getting different testing period.(seems calculating weekend in one case)

1.If i selet 2022.8.1 - 2022.9.1

2.If i selet 2022.8.8 - 2022.9.1

The value return by ObjectGetValueByTime is different , but the trendline and the time are the same(In text, trendline number are different,  because different period named different ,but the trendline in chart are the same).

In first case, the value seems caculate weekend, so the value is smaller than case2.  But there is no bar in weedend. So how can I adjust this difference? Generally, I don't need to calculate the weekend when testing my EA for a year or more.

Help me please! A master here?

 
How we should know without the code, but when you use a different test time schedule its possible that the calc is different
 
amando #:
How we should know without the code, but when you use a different test time schedule its possible that the calc is different

Thanks for your reply.  The source code is very long. Simple words , i get the trendline value when a new bar generates, using  ObjectGetValueByTime. But when i test it longger than a week, the first bar of monday return a smaller value in the chart which didn't on the trendline. Like the picture below.   When i ask trendline value on the the saturday(next_day),it returns the correct value,but there are no bar in saturday.  So how to Skip the weekend when calculating Trendline value?

                {
                    ResetLastError();
                    ChartRedraw(0);

                    ObjectSetInteger(0,selllimit_openpoint_line,OBJPROP_WIDTH,in_trade_width);
                    ObjectSetInteger(0,selllimit_openpoint_line,OBJPROP_COLOR,DownLine_only_sell_limit);
                    PrintFormat("Now Trade the %s in Sell limit mod,sell limit open point: %f", selllimit_openpoint_line,selllimit_openpoint);
                    
                    double testprice = ObjectGetValueByTime(0,selllimit_openpoint_line,iTime(Symbol(),Period(),0),0);
                    double lasttestprice = ObjectGetValueByTime(0,selllimit_openpoint_line,iTime(Symbol(),Period(),1),0);
                    datetime next_day = iTime(Symbol(),Period(),0) + PeriodSeconds();

                    double nexttestprice = ObjectGetValueByTime(0,selllimit_openpoint_line,next_day,0);

                    datetime testtime = ObjectGetTimeByValue(0,selllimit_openpoint_line,testprice,0);

                    int objectfind = ObjectFind(0,selllimit_openpoint_line);
                    PrintFormat("Now the ObjectGetValueByTime:%f.find num: %d,last vbt %f,next vbt %f~~~~~",testprice,objectfind,lasttestprice,nexttestprice);
                    PrintFormat("Now the ObjectGetTimeByValue:%s.   %s",TimeToString(testtime,TIME_DATE),TimeToString(testtime,TIME_SECONDS));
                    PrintFormat("GetLastError:::%d",GetLastError());
                }


 

I tried many ways to fix it. It looks like a bug.  Finally i fix it by 2 step:

1.Redraw the trendline on Monday

2.Caculating current value in my way.

double Current_ObjectGetValueByTime(long chart_id,string name)
{
    double lastvalue = ObjectGetValueByTime(0,name,iTime(Symbol(),Period(),1),0);
    double lastlastvalue = ObjectGetValueByTime(0,name,iTime(Symbol(),Period(),2),0);
    double value = lastvalue + lastvalue - lastlastvalue;

    return value;
}

Hope to help someone with the same problem. In the other hands, welcome to propose a better solutions :)