xjd853311189 发表于 2018-4-17 16:24:22

GetArrayItemValue

#property copyright "Copyright ?2005-2016, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"

#import "DLLSample.dll"
int    GetIntValue(int);
double GetDoubleValue(double);
string GetStringValue(string);
double GetArrayItemValue(double &arr[],int,int);
bool   SetArrayItemValue(double &arr[],int,int,double);
double GetRatesItemValue(MqlRates &rates[],int,int,int);
#import

#define TIME_INDEX   0
#define OPEN_INDEX   1
#define LOW_INDEX    2
#define HIGH_INDEX   3
#define CLOSE_INDEX4
#define VOLUME_INDEX 5
//+------------------------------------------------------------------+
//| expert initialization function                                 |
//+------------------------------------------------------------------+
int init()
{
   double ret,some_value=10.5;
   string sret;
   int    cnt;
//--- simple dll-functions call
   cnt=GetIntValue(int(some_value));
   Print("Returned value is ",cnt);

   ret=GetDoubleValue(some_value);
   Print("Returned value is ",ret);

   sret=GetStringValue("some string");
   Print("Returned value is ",sret);
//---
   return(0);
}
//+------------------------------------------------------------------+
//| array functions call                                             |
//+------------------------------------------------------------------+
int start()
{
   double   price;
   double   arr={1.5,2.6,3.7,4.8,5.9 };
   MqlRates rates[];
//--- get first item from passed array
   price=GetArrayItemValue(arr,5,0);
   Print("Returned from arr ",price);
//--- change second item in the passed array
   if(SetArrayItemValue(arr,5,1,1234.5)==true)
      Print("Changed to ",arr);
//--- get current close
   ArrayCopyRates(rates);
   price=GetRatesItemValue(rates,Bars,0,CLOSE_INDEX);
   Print("Returned from Close ",price);
//---
   return(0);
}
//+------------------------------------------------------------------+


扬---帆千里 发表于 2020-8-11 20:03:01

帮你顶下哈!!

ospzmjdb 发表于 2020-11-20 12:19:19

{:1_179:}

cinib 发表于 2021-7-19 11:48:13

谢谢

redfly 发表于 2021-7-22 15:28:17

顶下

rixlyuqm 发表于 2021-7-26 14:11:14

{:1_181:}

konase 发表于 2021-8-7 11:27:53

顶下

平步青云去看海 发表于 2023-6-19 21:37:26

{:1_189:}

晴无眠 发表于 2024-8-7 11:15:15

{:1_194:}
页: [1]
查看完整版本: GetArrayItemValue