|
Add Reply New Topic |
Script works perfect but same code in EA produces errors. Why so and how to solve???? |
Mar 30, 2015, 12:03 AM
Post
#1
|
||
Group: Members Posts: 8 Joined: October 13, 2010 Member No.: 4,880 |
Mar 30, 2015, 12:03 AM
Post
#1
|
This is an ea to open orders based to time data supplied in a comma separated values in .csv file. It works brilliantly in a script but in an ea it is simply unable to open file supplied.
CODE #property copyright "Copyright 2015, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict extern int SL=70; extern int TP=20; int data[10][3]; int start() { string separator=","; int m_handle=-1, count, line_count = 1; string m_filename="data.txt"; double price=Ask; double balance; //the balance double equity; //the equity balance=AccountBalance(); equity=AccountEquity(); m_handle=FileOpen(m_filename,FILE_CSV|FILE_ANSI|FILE_READ,separator,CP_ACP); if(m_handle<0) { Print("I can't open the file."); } else { Print("File successfully open."); while (FileIsEnding(m_handle) == false) { data[count][0]=FileReadInteger(m_handle, 10); data[count][1]=FileReadInteger(m_handle, 10); data[count][2]=FileReadInteger(m_handle, 10); if (balance==equity && Day()==data[count][0] && Hour()==data[count][1] && Minute()==data[count][2]) OrderSend(Symbol(),OP_SELL,1.5*equity/100,Bid,20,Ask+SL*Point,Ask-TP*Point,"My order",16384,0,Green); if (FileIsLineEnding(m_handle) == true)line_count ++; count ++; } FileClose(m_handle); } PlaySound("wait.wav"); return(0); } The tester gives error:- "2015.03.16 04:41 TimeEA EURUSD,M1: I can't open the file." the time data is supplied in data.txt formatted as:- date,hour,minute This file is placed in ...\MQL4\Files folder and is accessible to all the scripts. How to correct that error? Can anyone help me?
Attached File(s)
|
|
Add Reply |
|
Financial services provided by InstaForex Companies Group © 2008-2024 |
InstaForexTM is a registered trademark of InstaForex Group
|