MQL4 iClose()
Returns the close price of one bar of a symbol and timeframe, counted back from the current bar.
Risk warning: CFDs and spread bets are complex instruments and come with a high risk of losing money rapidly due to leverage. You can lose money on these products, and each provider publishes its own loss figure under FCA rules. You should consider whether you understand how they work and whether you can afford to take the high risk of losing your money. Automated and API trading can amplify losses through bugs, connectivity failures and runaway orders.
This is an MQL4 function, not an HTTP endpoint. It has no method, no path and no address to send a request to: it runs inside the MetaTrader 4 terminal, in a program written in MQL4.
Signature
The form of the call on the vendor's page, with the vendor's comments taken out.
double iClose( string symbol, int timeframe, int shift )
Arguments
| Name | Type | Description |
|---|---|---|
| symbolrequired | string | The symbol's name. NULL means the chart's own symbol. |
| timeframerequired | int | The timeframe, as a value of ENUM_TIMEFRAMES. 0 means the chart's own timeframe. |
| shiftrequired | int | How many bars back from the current one. |
Return value
- Type
- double
- What comes back
- The close price, or 0 where the local history is empty. The page points to GetLastError() for the reason.
Sample
Written by this site from the signature and arguments recorded on this page. It has not been run against a terminal, a server or an account, and the values in it are placeholders. It holds no credential and needs none: the program runs inside a terminal that is already logged in to an account. Nothing is entered on this site.
void OnStart()
{
Print("Close of the previous bar: ",iClose(NULL,0,1));
}