Please help!! get value from iVolume
Please, read documentation. https://www.mql5.com/en/docs/series/ivolume
iVolume is not an indicator and do not provide an handle.
I strongely suggesst to use CopyVolume or CopyRates. Be also aware that volume is "long" type and not "integer".
Documentation on MQL5: Timeseries and Indicators Access / iVolume
- www.mql5.com
Returns the tick volume of the bar (indicated by the 'shift' parameter) on the corresponding chart. Parameters symbol [in] The symbol name of...
I made you an example
//+------------------------------------------------------------------+ //| CopyingVolume.mq5 | //| Copyright 2023, MetaQuotes Ltd. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2023, MetaQuotes Ltd." #property link "https://www.mql5.com" #property version "1.00" long array_iVolume[]; input int bars = 1000; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- ArraySetAsSeries(array_iVolume,true); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- Comment(""); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- if(CopyTickVolume(Symbol(), Period(), 0, bars, array_iVolume) == -1){ Print("Somthing went wrong copying the volume"); } Print("The volume of the most recent bar: ", array_iVolume[0]); Comment("The volume of the most recent bar: ", array_iVolume[0]); Print("Using iVolume: ", iVolume(Symbol(), Period(), 0)); } //+------------------------------------------------------------------+
Hi,
Please help me to correct this code below :
I try to get value from iVolume but got warning when compile code :
"possible loss of data due to type conversion from 'long' to 'int' volume-test.mq5 29 18
and got error code 4807 when run expert.