Here is what worked for my needs.
//+------------------------------------------------------------------+ //| expressionTester5.mq5 | //+------------------------------------------------------------------+ #property copyright "" #property link "" #property version "1.00" #include <Arrays\ArrayObj.mqh> #include <Arrays\ArrayDouble.mqh> #include <Arrays\List.mqh> input ENUM_TIMEFRAMES TF1=PERIOD_MN1; input ENUM_TIMEFRAMES TF2=PERIOD_W1; input ENUM_TIMEFRAMES TF3=PERIOD_D1; input ENUM_TIMEFRAMES TF4=PERIOD_H4; input ENUM_TIMEFRAMES TF5=PERIOD_H1; input ENUM_TIMEFRAMES TF6=PERIOD_M15; input ENUM_TIMEFRAMES TF7=PERIOD_M5; input ENUM_TIMEFRAMES TF8=PERIOD_M1; //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { InstanciateStatusObjects(); //Print("statuses[1].TFNumber: ",statuses[1].TFNumber); return; } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ // Instanciate instances of the oStatuses object and load into the //+------------------------------------------------------------------+ void InstanciateStatusObjects() { ENUM_TIMEFRAMES TFInputs[8]; TFInputs[0]=TF1; TFInputs[1]=TF2; TFInputs[2]=TF3; TFInputs[3]=TF4; TFInputs[4]=TF5; TFInputs[5]=TF6; TFInputs[6]=TF7; TFInputs[7]=TF8; for(int i=0; i<8; i++) { CStatuses *oneStat; oneStat=new CStatuses; statuses[i]=oneStat; // prevent memory leak delete oneStat; statuses[i].TFNumber=i; // in this test, this is being assigned statuses[i].timeframe=TFInputs[i]; // in this test, this is being assigned //// just empty values below for now. statuses[i].label=""; statuses[i].buyOrSell=0; statuses[i].hasPulledBack=false; statuses[i].histCount=0; statuses[i].crossCount=0; statuses[i].thickOrThin=0; statuses[i].thickOrThinCurrent=0; statuses[i].ema6Handle=0; statuses[i].TMACDHandle=0; statuses[i].macdPullbackHandle=0; // in existing code, seems to be redundant usage of the TMACDHandle statuses[i].TFmsg=""; statuses[i].TFCrossMsg=""; statuses[i].TFstat=""; statuses[i].TFPeriodLabel=""; } } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ // // CLASS DEFINITIONS FOR v2 //+------------------------------------------------------------------+ class CStatuses { public: int TFNumber; // 0-7 corresponding to indicator input parameters ENUM_TIMEFRAMES timeframe; string label; int buyOrSell; bool hasPulledBack; int histCount; int crossCount; int thickOrThin; // consider changing this to "thickOrThinPrior" int thickOrThinCurrent; // handles required for use int ema6Handle; int TMACDHandle; // can this be the handle stored in a different instance of the class (the one that is the pullback timeframe?) // and just use the TMACDHandle stored in the correct class instance? check the code to see. int macdPullbackHandle; // this does seem to just be a redundant usage of the same handle as TMACDHandle // messaging displayed on screen string TFmsg; string TFCrossMsg; string TFstat; string TFPeriodLabel; public: // Constructor CStatuses() {}; void CStatuses(CStatuses &statObj) { } // Destructor ~CStatuses() {}; }; CStatuses statuses[8];
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
UPDATE: Clearly I was overthinking this. I just created a straight array of CStatuses, figured out how to avoid memory leaks, and I'm good. Still have a lot of reading up to do on CList usage and understanding proper use of pointers, but I've got what I need apparently working. Didn't realize global use of custom classes required usage after the class definition in the global scope. That little bit of ignorance cost me greatly. Grrrrrr.
Posting my final result as another comment at the end, in case it is useful to someone.
If anyone could advise me if I'm still doing something poorly in my solution, that would be great. Thanks!
===================================================
Hello and thank you for looking.
I assure you I spend ungodly hours testing, experimenting and researching before resorting to posting here. My ignorance has me at my wit's end.
I have a global CArrayObj (globalStatusArray) with each elements containing instances of my own custom CObject class with public properties.
In the global scope in the debugger I can see all the objects of the globalStatusArray and all the properties are correctly assigned. However, I cannot access them.
Of course I would love to directly access them with globalStatusArray[1].m_data.myProperty, but even coding Get(xxx) methods in my class return the wrong values, and instantiating a new class instance with .At(1) returns an instance of my class with all the properties, but their values are gibberish or unititialized or something.
I've tried to detail the code very carefully to make answering this question as easy as possible.
Thank you!