Use the iClose() in EA, Why the result is OpenPrice?

 

I want to print out the Close price and MA price (1 mintue) though the back testing.

Here is the code of the EA:

//##################################################################
#property copyright "Copyright 2014, MetaQuotes Software Corp."
#property link      "/"
#property version   "1.00"
#property strict


static datetime now;
double BufMAA=0;

int start()
{
if(now != Time[0])
   {
    now = Time[0];
    BufMAA=iMA(NULL,PERIOD_M1,4,0,MODE_SMA,PRICE_CLOSE,0);
    Print(Time[0],",",iClose(NULL,PERIOD_M1,0),",",BufMAA);
    }
return(0);
   
}
//##################################################################

The setting of Back Testing:

Symbol:USDJPY

Model: Every tick

UseDate: From 2013.01.01 To:20.13.01.31

Period:M1

Spread:10


I don't know why I used the iClose() in the EA, but the result in the log file is Open Price.

Hope can get your help.

Thanks a  lot. I have attached my EA for anyone to have a try.

Files:
 

1) if you post code please use the SRC button beside the camera!

2) you enter this loop:

if(now != Time[0])
   {
    now = Time[0];
...

only at the open of the new bar - so you get only the opens.

 
gooly:

1) if you post code please use the SRC button beside the camera!

2) you enter this loop:

only at the open of the new bar - so you get only the opens.


Thanks a lot for your answering.

Can you help me, if I want to get the close price, how to change the code?

Please・・・・

 
BufMAA=iMA(NULL,PERIOD_M1,4,0,MODE_SMA,PRICE_CLOSE,1);
    Print(Time[1],",",iClose(NULL,PERIOD_M1,1),",",BufMAA);
To print the previous bars close, change the index from 0 to 1
 
GumRai:
To print the previous bars close, change the index from 0 to 1

Thanks a lot! Really!!

Reason: