daileycon:
How do you do this? I get "invalid index value".
You need to use a dynamic array, and then resize its size:
//+------------------------------------------------------------------+ //| Test.mq5 | //| Copyright © 2016, Vladimir Karputov | //| http://wmua.ru/slesar/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2016, Vladimir Karputov" #property link "http://wmua.ru/slesar/" #property version "1.000" #property script_show_inputs //--- inputs input int SpreadsToCollect=10; //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { double spreads[]; Print("ArraySize before: ",ArraySize(spreads)); if(ArrayResize(spreads,SpreadsToCollect)==-1) Print("Error ArrayResize, #",GetLastError()); else Print("ArraySize after: ",ArraySize(spreads)); } //+------------------------------------------------------------------+
Output:
2016.10.04 13:05:10.073 Test (EURUSD,M5) ArraySize before: 0 2016.10.04 13:05:10.073 Test (EURUSD,M5) ArraySize after: 10
Files:
Test.mq5
3 kb
Karputov Vladimir:
You need to use a dynamic array, and then resize its size:
Output:
Weird, I thought I tried to resize it. I didn't have #property script_show_inputs
Thanks for the quick help!!!
daileycon:
Weird, I thought I tried to resize it. I didn't have #property script_show_inputs
Thanks for the quick help!!!
There are dynamic arrays (my example above) and static. An example of a static array:
double spreads[10]; // a static array Print("ArraySize before: ",ArraySize(spreads));
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
How do you do this? I get "invalid index value".