tintin92: I publish my code hoping constructive criticism.
In a constructor, first all members are constructed and then the code in the braces is executed. For basic data types it means little, but for member classes it can be a double hit (default construction and then parameter setting. void CArea::CArea(datetime startTime, datetime endTime, double resistance, double support) { m_startTime=startTime; m_endTime=endTime; m_resistance=resistance; m_support=support; }
Use Initialization lists. void CArea::CArea(datetime startTime, datetime endTime, double resistance, double support) : m_startTime(startTime), m_endTime(endTime), m_resistance(resistance), // Same as assignment for basic members. m_support(support) // Same as construction for class members. {} // {} all members initialized nothing else to do.
#include <../Areas/clArea.mqh> #include <../Areas/clAreas.mqh>
Do forward slashes actually compile? This looks like you created a non-standard folder in the data folder. Probably not a good idea.If you created a folder below the standard includes (in MQL4\Includes\Areas) you would use
#include <Areas\\clArea.mqh> #include <Areas\\clAreas.mqh>
Not recomended, I'd put non-application specific includes there, like WinUser32.mqh.If you created a folder below the experts folder (in \MQL4\Experts\Areas) you would use: #include "Areas\\clArea.mqh", #include "Areas\\clAreas.mqh"
Application specific includes with or below the application.
It depends on user preferences. From my point of view the MQL4/Includes folder is very appropriate for all includes. I use other root directories very rarely, since they are supposed to contain executable code rather than snippets.
For example if I use following combination:
#include "../TestInclude.mqh" #include <Ovo/MT4OfflineChart.class.mqh>
it is just to ensure that the TestInclude.mqh is never processed by Doxygen, which otherwise traverses the Includes in my settings.
The forward slashes do work, I never noticed any problem.
Hello,
Thanks for the answers, now I have a new question.
No change in the code.
A simple add of a Print:
/ / + ----------------------------------------------- ------------------- + void Careas :: addArea (CAREA * area) { Print ("ArraySize (Areas):" + ArraySize (Areas)); ArrayResize (Areas, ArraySize (Areas) 1.10); Areas [ArraySize (Areas) -1] = area; } / / + ----------------------------------------------- ------------------- +
During a change of TimeFrame from W1 to D1 for example, I see that objects are added to the table not deleted.
CAREA * Areas [];
2014.03.11 17:56:03.588 idAreas GOLD,Weekly: initialized 2014.03.11 17:56:03.588 idAreas GOLD,Weekly: ArraySize(Areas) :8 2014.03.11 17:56:03.588 idAreas GOLD,Weekly: ArraySize(Areas) :7 2014.03.11 17:56:03.588 idAreas GOLD,Weekly: ArraySize(Areas) :6 2014.03.11 17:56:03.588 idAreas GOLD,Weekly: init() 2014.03.11 17:56:03.588 idAreas GOLD,Daily: uninit reason 3 2014.03.11 17:56:00.647 idAreas GOLD,Daily: initialized 2014.03.11 17:56:00.647 idAreas GOLD,Daily: ArraySize(Areas) :5 2014.03.11 17:56:00.647 idAreas GOLD,Daily: ArraySize(Areas) :4 2014.03.11 17:56:00.647 idAreas GOLD,Daily: ArraySize(Areas) :3 2014.03.11 17:56:00.647 idAreas GOLD,Daily: init() 2014.03.11 17:56:00.647 idAreas GOLD,Weekly: uninit reason 3 2014.03.11 17:55:49.849 idAreas GOLD,Weekly: initialized 2014.03.11 17:55:49.849 idAreas GOLD,Weekly: ArraySize(Areas) :2 2014.03.11 17:55:49.849 idAreas GOLD,Weekly: ArraySize(Areas) :1 2014.03.11 17:55:49.849 idAreas GOLD,Weekly: ArraySize(Areas) :0 2014.03.11 17:55:49.849 idAreas GOLD,Weekly: init() 2014.03.11 17:55:49.843 Custom indicator Areas\idAreas GOLD,Weekly: loaded successfully
It is not my wish, I want the objects to be deleted and then recreated.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello,
For my own needs, as an exercise, I tried to develop an indicator showing support and resistance determined by zones, where you can enter areas and values.
I publish my code hoping constructive criticism.
Regards,