Getting closing price in an array

To add comments, please log in or register
Skester96
23
Skester96  

Hello,


I want to have the closing prices in an array which I can call using name_array[x] whereas x is the price on that timeframe (1m, 1h, etc). What can I use for this? I only found information on CopySpread, copy tick and realtime updates. (Copy spread keepts telling me an error that this function declaration is only allowed on global, namespace or class declarations only, whereas everywhere I put this in my code (Global, onInit and on Tick) it givs me the same error. 



void OnTick()

  {

  

  

  int  CopySpread( 

   string           USD_JPY,      // symbol name 

   ENUM_TIMEFRAMES  0,        // period 

   int              0,        // start position 

   int              20,            // data count to copy 

   int              spread_array[]    // target array for spread values 

   );

  

   //Get price data

   double current_bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);

   double current_ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK); 

   }




Sergey Golubev
Moderator
115546
Sergey Golubev  

Forum on trading, automated trading systems and testing trading strategies

When you post code please use the CODE button (Alt-S)!

Use the CODE button


William Roeder
20741
William Roeder  
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2. void OnTick(){  
    
      int  CopySpread( 
       string           USD_JPY,      // symbol name 
    Don't post code that won't even compile. You copied the signature of CopySpread, you need to write a call. Compare that to the example in the documentation.
              Timeseries and Indicators Access / CopySpread - Reference on algorithmic/automated trading language for MetaTrader 5
katesmith1304
6
katesmith1304  
Hi, i had the same issue. i surfed many forms and nothing happened . then i used the code button and it got fixed. many thanks !!
katesmith1304
6
katesmith1304  
katesmith1304:
Hi, i had the same issue. i surfed many forms and nothing happened . then i used the code button and it got fixed. many thanks !! 9AppsVidMate
No reply??
Keith Watford
Moderator
21916
Keith Watford  
katesmith1304:
No reply??

Why are you expecting a reply?

lippmaje
1150
lippmaje  
Skester96:

I want to have the closing prices in an array which I can call using name_array[x] ...

You can either get the closing price of a single bar with iClose, or you can copy a range of prices with CopyRates.
To add comments, please log in or register