Deleting autotrade Object.

 

Hello, good day programmers, I have tried to eliminate the arrows and trendlines from the autotrades but they are only removed from the current chart but not from the other charts opened by the strategy tester.

and in the same way when I call the function in the OnDeinit() part they are not eliminated at the end of the backtest.

and in options I also have it disabled but I would also like to eliminate it via code.

These continue to appear no matter how I try to eliminate them in the backtest.


It should be noted that I use a multi-symbol advisor that opens operations in different symbols and time frames.


Thanks for read.



Current Backtest Chart: 


Second Backtest Chart: 



// Delete Objects for All Charts
void DeleteObjects()
{
    long currChart;
    long prevChart = ChartFirst();
    int deleted = ObjectsDeleteAll(prevChart);
    int chartCount = 1;
    // Loop through charts
    while (true)
    {
        // Get next chart
        currChart = ChartNext(prevChart);
        // If currChart < 0 ==> we iterated through all charts, exit loop
        if (currChart < 0)
            break;
        deleted += ObjectsDeleteAll(currChart);
        DeleteObjectbyName(currChart);
        chartCount++;
        prevChart = currChart;
    }
    PrintFormat("Deleted %d objects on %d charts", deleted, chartCount);
}

// Delete Objects
void DeleteObjectbyName(long s)
{
    long ChartID = s;
    int totalObjects = ObjectsTotal(ChartID, -1, -1);
    for (int j = totalObjects - 1; j >= 0; j--)
    {
        string objectName = ObjectName(ChartID, j, -1, -1);
        if (StringFind(objectName, "Arrow") >= 0 || StringFind(objectName, "Trendline") >= 0)
        {
            if (ObjectDelete(ChartID, objectName))
                Print("Deleted: ", objectName);
            else
                Print("Failed to delete: ", objectName);
        }
    }
}
 
Manuel Espinosa:

Hello, good day programmers, I have tried to eliminate the arrows and trendlines from the autotrades but they are only removed from the current chart but not from the other charts opened by the strategy tester.

and in the same way when I call the function in the OnDeinit() part they are not eliminated at the end of the backtest.

and in options I also have it disabled but I would also like to eliminate it via code.

These continue to appear no matter how I try to eliminate them in the backtest.


It should be noted that I use a multi-symbol advisor that opens operations in different symbols and time frames.


Thanks for read.



Current Backtest Chart: 


Second Backtest Chart: 



did you try the simple way by disableing show trade history through chart properties?
 
pavelion #:
did you try the simple way by disableing show trade history through chart properties?

Yes, they are deactivated and are also displayed when running the expert advisor in backtest.

 
Manuel Espinosa #:

Yes, they are deactivated and are also displayed when running the expert advisor in backtest.

what about applying a clean template(no indicator and no objects)? 

BTW, did you try to re-enable and re-disable the Trade History?
 
pavelion #:
e(no indicator and no objects)?

Yes, the tester.tpl that I use in backtesting is empty, without objects and without indicators. The problem occurs when the expert advisor opens operations, that is when the "autotrade" arrows and lines are created in the symbols being operated.

Yes, I already tried activating and deactivating it.

 
I was thinking of making a script that deletes all the objects with a key press
 
Conor Mcnamara #:
I was thinking of making a script that deletes all the objects with a key press

yes, a script using ObjectsDeleteAll(0); removes all objects from the current chart each time it is executed but not from different charts opened by the tester in which "autotrade" objects exist

but as you will see in the code I go through all the charts, but even so in backtesting they are not eliminated.

Reason: