[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 301

 
Zhunko:
There is no trade at the weekend.
Thanks ... I'll keep that in mind)))
 
to Reshetov^ Like this: int start() { Comment("Open positions: ", OrdersTotal()); string smb=Symbol(); int tf=Period(); gsID=smb+IsDemo()+IsTesting()+IsOptimization()+"."+Magic; inf=""; INF(TTS(TimeCurrent()), true); main(Magic, smb, tf); Comment(inf); and where and how will the number be displayed?
 
Why is my "comment" and "edit" function broken ? There are no top options - the top is completely blank - you can't add pictures, for example. What has this got to do with it?
 
yosuf:
to Reshetov^ Like this: int start() { Comment("Open positions: ", OrdersTotal()); string smb=Symbol(); int tf=Period(); gsID=smb+IsDemo()+IsTesting()+IsOptimization()+"."+Magic; inf=""; INF(TTS(TimeCurrent()), true); main(Magic, smb, tf); Comment(inf); and where and how is the number displayed?
There is a magic combination: Ctrl+Alt+M and a useful key "Enter", so as not to spoil the vision of interlocutors. Since eyesight is more precious, I can't answer anything specific on your code-washing.
 
Can you tell me how to work with ArrayMaximum in the EA? In the indicator it works, I marked arrays and buffers, but in the EA it is not clear.
 
Alexandr24:
Can you tell me how to work with ArrayMaximum in the EA? In the indicator it works, I marked arrays and buffers, but in the EA it is not clear.


You need to prepare the array first. Try the script given in the MetaEditor's help:

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start(){
  double num_array[15]={4,1,6,3,9,4,1,6,3,9,4,1,6,3,9};
  int    maxValueIdx=ArrayMaximum(num_array);
  Alert("Max value = ", num_array[maxValueIdx]);
  
  return(0);
}
//+------------------------------------------------------------------+
 
drknn:


You need to prepare the array first. Try the script given in the meta-editor's help:

In my indicator it looks like this:

sm[i]=...........;

double IndexMaxValue=ArrayMaximum(sm,n,shift);

I don't know how to attach it to your script, how to do it in the Expert Advisor?

I can output sm[i] via iCustom, but how can I put the iCustom variable into ArrayMaximum?

 
Alexandr24:

but how can iCustom variable be put into ArrayMaximum it's not an array?

I didn't cite the documentation for nothing. There is such a thing as description of parameters to be passed to function inputs. If it is written there that the parameter must be an array name, shoving another function (iCustom() in its place will do us no good. It means that before calling ArrayMaximum() we should declare array, then fill this array with values and only after that call ArrayMaximum().
 
drknn:
I didn't cite the documentation for nothing. There is such a thing as description of parameters which should be given as input to a function. If it says there that the parameter must be an array name, shoving another function (iCustom() in particular) will lead to nothing good. It means that before calling ArrayMaximum() we should declare an array and then fill this array with values and only after that you can call ArrayMaximum()
.
I tried to put the code of the indicator in an EA, but nothing works, the thing is that an indicator needs to indicate buffers and I haven't seen it in EAs, that's why an indicator works and the same code doesn't work in an EA. I have an array filled with cycle sm[i] and indicator sees it but EA with the same code does not. Maybe, the arrays in EAs should be declared differently than in indicators?
 
Alexandr24:
I tried to put the code of the indicator itself into the EA, but nothing works, IMHO the point is that the indicator needs to indicate buffers and I haven't seen it anywhere in EAs, that's why the indicator works, but the same code doesn't work in EAs. I have an array filled with cycle sm[i] and indicator sees it but EA with the same code does not. Maybe, the arrays in EAs should be declared differently than in indicators?

Work it out - no questions asked: https://www.mql5.com/ru/articles/mt4
Reason: