Download MetaTrader 5
To add comments, please log in or register
Deposit to your account via PayPal
xin2014
42
xin2014 2015.01.14 03:52 

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      "https://www.mql5.com"
#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:
Carl Schreiber
5934
Carl Schreiber 2015.01.14 09:02  

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.

xin2014
42
xin2014 2015.01.15 00:55  
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・・・・

Keith Watford
Moderator
7887
Keith Watford 2015.01.15 04:18  
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
xin2014
42
xin2014 2015.01.19 07:44  
GumRai:
To print the previous bars close, change the index from 0 to 1

Thanks a lot! Really!!

/
To add comments, please log in or register