I used ArraySetAsSeries( array[], false) in indicator. In indicator I need to use iMa(...,i), it turns out indexing in another way. Can I also change the indexing order for iMa() as ArraySetAsSeries?
So far I did it like this: rates_total-i (count at the other end), but I'm not sure if this is the right solution?
Guys. Can you please give me the code to bind an indicator to an account number, and in addition to binding to an account, you could add a license key?
I used ArraySetAsSeries( array[], false) in indicator. In indicator I need to use iMa(...,i), it turns out indexing in another way. Can I also reverse the indexing order for iMa() as ArraySetAsSeries?
So far I did this: rates_total-i (count from the other end ), just not sure if this is the right solution?
Let me answer myself (maybe somebody will need it too). You can create (remake) data buffer by example include MovingAverages.mqh (SimpleMAOnBuffer) and don't even bother with ArraySetAsSeries, because it already has ArrayGetAsSeries in the example.
//+------------------------------------------------------------------+//| Data on array |//+------------------------------------------------------------------+int DataBuffer(constint rates_total,constint prev_calculated,constint begin,
constdouble& data[],double& buffer[])
{
int i,limit;
//--- check for data//--- save as_series flagsbool as_series_data=ArrayGetAsSeries(data);
bool as_series_buffer=ArrayGetAsSeries(buffer);
if(as_series_data)
ArraySetAsSeries(data,false);
if(as_series_buffer)
ArraySetAsSeries(buffer,false);
//--- first calculation or number of bars was changedif(prev_calculated==0) // first calculation
{
limit=begin+1;
//--- set empty value for first barsfor(i=0; i<limit-1; i++)
buffer[i]=0.0;
//--- calculate first visible valuedouble firstValue=0;
for(i=begin; i<limit; i++)
firstValue=data[i];
buffer[limit-1]=firstValue;
}
else
limit=prev_calculated-1;
//--- main loopfor(i=limit; i<rates_total-1; i++)
buffer[i]=data[i];
//--- restore as_series flagsif(as_series_data)
ArraySetAsSeries(data,true);
if(as_series_buffer)
ArraySetAsSeries(buffer,true);
//---return(rates_total);
}
//+------------------------------------------------------------------+
there will be no variable names after compilation,
I see, Igor, I guess it won't work gracefully. I thought I would shorten the path to the data for clarity, but I'll get sheets of case and macro substitutions. I'll probably settle for a long record. I'll think about it though, it's an interesting solution. Thanks!
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
What is the best way to access a property of a class to another property of the same class?
That is, instead of "this", I would like to use something like "parent".
I used ArraySetAsSeries( array[], false) in indicator. In indicator I need to use iMa(...,i), it turns out indexing in another way. Can I also change the indexing order for iMa() as ArraySetAsSeries?
So far I did it like this: rates_total-i (count at the other end), but I'm not sure if this is the right solution?What is the best way to access a property of a class to another property of the same class?
That is, instead of "this", I would like to use something like "parent".
Learn the math)
Guys. Can you please give me the code to bind an indicator to an account number, and in addition to binding to an account, you could add a license key?
A question, how do I refer to a structure element by substituting its name as a string?
Whoever can tell me, well done!I used ArraySetAsSeries( array[], false) in indicator. In indicator I need to use iMa(...,i), it turns out indexing in another way. Can I also reverse the indexing order for iMa() as ArraySetAsSeries?
So far I did this: rates_total-i (count from the other end ), just not sure if this is the right solution?Let me answer myself (maybe somebody will need it too). You can create (remake) data buffer by example include MovingAverages.mqh (SimpleMAOnBuffer) and don't even bother with ArraySetAsSeries, because it already has ArrayGetAsSeries in the example.
A question, how do I refer to a structure element by substituting its name as a string?
Who will prompt, it will be well done!No variable names after compilation,
I need to invent something with macrosubstitutions.
i don't likestring type, i always expect a lot of unexpected things with it:
UPD:
although it would be more logical to put a method of working with fields in the structure, i.e. so:
there will be no variable names after compilation,
I see, Igor, I guess it won't work gracefully. I thought I would shorten the path to the data for clarity, but I'll get sheets of case and macro substitutions. I'll probably settle for a long record. I'll think about it though, it's an interesting solution. Thanks!
A question, how do I refer to a structure element by substituting its name as a string?
Whoever can tell me, well done!