Of course they do, they are objects once created. Turn them off before opening a trade.
Thanks for your comment @whroeder1.
How do I do that? If I put the code
ChartSetInteger (0, CHART_SHOW_TRADE_LEVELS, false );
in the OnInit() function before any trades are opened, it still has no effect.
How can I turn / delete objects before they are created. Could you please be more precisely on how you would do that?
I managed to get rid of the green dotted line by setting CHART_COLOR_VOLUME equal to the background color of the chart.
I also realized that the TEXT LABEL and the SELL_ARROW are one object? Still struggeling to delete it. Any ideas?
#include <trade/trade.mqh> CTrade m_trade; // The Trade Class Object MqlTick last_tick; // Get bid and ask price for current tick bool trade = true; int OnInit() { ChartSetInteger(0, CHART_COLOR_VOLUME, clrBlack); ChartRedraw(); return(INIT_SUCCEEDED); } void OnTick() { if(trade) { m_trade.Sell(0.1, _Symbol, last_tick.ask, 0, 0, NULL); trade = false; } }
However, regardless what I do, the green line, as well as the arrow and the text stay.
You have to delete the objects or they stay on screen.
https://docs.mql4.com/objects/objectdelete
- Jack
![ObjectDelete - Object Functions - MQL4 Reference ObjectDelete - Object Functions - MQL4 Reference](https://c.mql5.com/36/15/objectdelete-object-functions-mql4.png)
- docs.mql4.com
You have to delete the objects or they stay on screen.
https://docs.mql4.com/objects/objectdelete
- Jack
Hi,
I am working with MQL5, so maybe there is a better way / functions I can use?
Hi,
I am working with MQL5, so maybe there is a better way / functions I can use?
For MQL5: https://www.mql5.com/en/docs/objects/objectdelete - Jack
![Documentation on MQL5: Object Functions / ObjectDelete Documentation on MQL5: Object Functions / ObjectDelete](/i/community/logo_mql5_small.png)
- www.mql5.com
If you want to clear ALL the objects from your chart you can also use:
https://www.mql5.com/en/docs/objects/objectdeleteall
- Jack
![Documentation on MQL5: Object Functions / ObjectsDeleteAll Documentation on MQL5: Object Functions / ObjectsDeleteAll](/i/community/logo_mql5_small.png)
- www.mql5.com
Thank you! I will have a look into that tomorrow.
I just quickly checked the ObjectDelete function and it uses the Name of the object to delete. When I create the order above, I don't know the Name of the arrow object created automatically.
So I guess, I have to iterate over all existing objects and pick up the OBJ_ARROW_SELL (maybe _DOWN) and delete that one?
Are my thoughts plausible?
Thank you! I will have a look into that tomorrow.
I just quickly checked the ObjectDelete function and it uses the Name of the object to delete. When I create the order above, I don't know the Name of the arrow object created automatically.
So I guess, I have to iterate over all existing objects and pick up the OBJ_ARROW_SELL (maybe _DOWN) and delete that one?
Are my thoughts plausible?
No need to iterate all the existing objects.
If you want to just delete all the down arrows on screen for example, you can specify the object type.
Example from documentation:
int ObjectsDeleteAll( long chart_id, // chart ID const string prefix, // prefix in object name int sub_window=-1, // window index int object_type=-1 // object type );
I've found the following page helpful for object types.
https://www.mql5.com/en/docs/constants/objectconstants/enum_object
- Jack
![Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Types / OBJ_ARROW_DOWN Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Types / OBJ_ARROW_DOWN](/i/community/logo_mql5_small.png)
- www.mql5.com
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
the following Code simply opens a sell order:
This produces the following chart in the strategy tester:
I am trying to get rid of the following Things:
1. green dotted sell line
2. the red arrow
3. the text #2 sell 0.10
I found the following two Forum posts:
https://www.mql5.com/en/forum/139145
https://www.mql5.com/en/forum/132892
From These posts, I found two possible Solutions:
1. Doing it via MQL5 code:
2. In the Strategy Tester Chart go to -> tools --> option --> uncheck "Show Trade Levels"
However, regardless what I do, the green line, as well as the arrow and the text stay.
I just read the post from syrvn 0 reporting a possible bug:
https://www.mql5.com/en/forum/216648#comment_5839187
That is why I also decided to ask whether anyone can confirm whether this is a bug or not or if I am doing something wrong.
Answers a greatly appreaciated.