MQl5 Debugger Drawings

 

Hello all,

I am writing an EA in MQL5. I have Support and resistance lines auto detecting. When a support gets taken out, it will not detect at all the next time the code runs(it will receive a new bar). It should then delete the support line that was there before, but instead, it leaves it. Why? Does the debugger not have the capability of deleting drawings. I am calling objectsDeleteAll so i do not understand why it is not able to delete this line. 

 
Your topic has been moved to the section: Expert Advisors and Automated Trading
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 
doofenShmirtz: I am writing an EA in MQL5. I have Support and resistance lines auto detecting. When a support gets taken out, it will not detect at all the next time the code runs(it will receive a new bar). It should then delete the support line that was there before, but instead, it leaves it. Why? Does the debugger not have the capability of deleting drawings. I am calling objectsDeleteAll so i do not understand why it is not able to delete this line. 

Debugging should not be preventing anything.

You have not explained your debugging steps in detailed nor have you provide a code sample that has the issue.

So, all we can do is speculate at most. Most likely there is a bug in your code.

EDIT: However, the debugger can "pause" the thread, and given that processing the "graphical objects" may be subject to a delay because the thread is on hold.

This is just me speculating, as I have never debugged "graphical objects" before.

 
doofenShmirtz:

Hello all,

I am writing an EA in MQL5. I have Support and resistance lines auto detecting. When a support gets taken out, it will not detect at all the next time the code runs(it will receive a new bar). It should then delete the support line that was there before, but instead, it leaves it. Why? Does the debugger not have the capability of deleting drawings. I am calling objectsDeleteAll so i do not understand why it is not able to delete this line. 

Another speculation is, you are not calling ChartRedraw() after you deleted your object.

Some code would really help to help you.
 
Fernando Carreiro #:

Debugging should not be preventing anything.

You have not explained your debugging steps in detailed nor have you provide a code sample that has the issue.

So, all we can do is speculate at most. Most likely there is a bug in your code.

EDIT: However, the debugger can "pause" the thread, and given that processing the "graphical objects" may be subject to a delay because the thread is on hold.

This is just me speculating, as I have never debugged "graphical objects" before.

Dominik Egert #:
Another speculation is, you are not calling ChartRedraw() after you deleted your object.

Some code would really help to help you.

Thank you for both replying. Another thing worth noting is that the objects DO delete when running the EA live, but not in the debugger. 

void OnTick()
  {
   double bid = SymbolInfoDouble(_Symbol,SYMBOL_BID);
   bid = NormalizeDouble(bid,_Digits);
   double ask = SymbolInfoDouble(_Symbol,SYMBOL_ASK);
   ask = NormalizeDouble(ask,_Digits);


// Check if the last bar time has changed since the last tick.
   if(isNewBar())
     {

      //clear chart of all graphical objects.
      Print("deleting ",ObjectsDeleteAll(ChartID()), " objects");
      //breakpoint here 
      ChartRedraw(ChartID()); // Redraws the chart


        // more irrelevant code down here
        //etc,etc,etc
}

}

hopefully this will better explain my situation. Apologies for the incorrect section as well as the lack of a code sample. 

 
doofenShmirtz #:

Thank you for both replying. Another thing worth noting is that the objects DO delete when running the EA live, but not in the debugger. 

hopefully this will better explain my situation. Apologies for the incorrect section as well as the lack of a code sample. 

I finally figured this out. ObjectsDeleteAll() just literally does not work. I had to loop them to delete the manually as such. 
void DeleteObjectsWithPrefix( string& prefixes[]) {
    for (int i = 0; i < ArraySize(prefixes); i++) {
        if (!ObjectsDeleteAll(0, prefixes[i], 0, -1)) {
            Print("Can't delete all objects with prefix: ", prefixes[i]);
        }
    }
}
Reason: