| New signals service! | |
|
|||||||
| Register in Forex TSD! | |
|
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information |
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Isn't start() supposed to run on every tick?
I've learned that what is placed after the start(), will run on every tick. But my code doesnt agree with me.
I'm trying to export to a file on every tick, with this code: Code:
int start()
{
string tab = "";
int f = FileOpen(Symbol()+Period()+".csv", FILE_CSV | FILE_WRITE,',');
FileWrite(f,"Date","Open","High","Low","Close","Volume");
Print(tab, TimeToStr(iTime(NULL,0,m), TIME_DATE) ,iOpen(NULL,0,m), iHigh(NULL,0,m),
iLow(NULL,0,m) ,iClose(NULL,0,m) ,iVolume(NULL,0,m));
string sDate = TimeToStr(iTime(NULL,0,m),TIME_DATE);
sDate = StringSetChar(sDate,4,'/');
sDate = StringSetChar(sDate,7,'/');
FileWrite(f,sDate, TimeToStr(iTime(NULL,0,m),TIME_MINUTES),iOpen(NULL,0,m), iHigh(NULL,0,m),
iLow(NULL,0,m), iClose(NULL,0,m), iVolume(NULL,0,m));
FileClose(f);
(/johan |
|
||||
|
Try putting and ending bracket " } " to finish off the function.
__________________
"Don't work harder, work smarter." -- my Java professor Coder for Hire: http://www.firecell-fx.com |
|
||||
|
I noticed you have another thread with more coding questions. Try posting your entire indicator or EA so programmers can see the whole picture.
__________________
"Don't work harder, work smarter." -- my Java professor Coder for Hire: http://www.firecell-fx.com |
|
|||
|
m is set to 0, i want the current "action".
My complete code is: Code:
//+------------------------------------------------------------------+
//| test.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""
//---- indicator settings
#property indicator_separate_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
return(0);
}
//+------------------------------------------------------------------+
int start()
{
int m=0;
//---- done
string tab = "";
int f = FileOpen(Symbol()+Period()+".csv", FILE_CSV | FILE_WRITE,',');
FileWrite(f,"Date","Open","High","Low","Close","Volume");
Print(tab, TimeToStr(iTime(NULL,0,m), TIME_DATE) ,iOpen(NULL,0,m), iHigh(NULL,0,m),
iLow(NULL,0,m) ,iClose(NULL,0,m) ,iVolume(NULL,0,m));
string sDate = TimeToStr(iTime(NULL,0,m),TIME_DATE);
sDate = StringSetChar(sDate,4,'/');
sDate = StringSetChar(sDate,7,'/');
FileWrite(f,sDate, TimeToStr(iTime(NULL,0,m),TIME_MINUTES),iOpen(NULL,0,m), iHigh(NULL,0,m),
iLow(NULL,0,m), iClose(NULL,0,m), iVolume(NULL,0,m));
FileClose(f);
return(0);
}
//+------------------------------------------------------------------+
Ideas? |
|
|||
|
You're right, my bad. I got it working as an indicator now, but the thing is that I want to use on my ea for extended backtesting. The exact same code doesn't give any output at all, maybe it's not possible?
When you backtest an ea, doesn't it trigger on every tick being made? I know it's just 1min data and the ticks is "made up", but shoulden't it work the same? Or maybe you can solve it with like if volume[0]>volume[1] or something, to create the trigger for the output? If I set the output exactly as my triggerconditions for the trade, I still get no output??? |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| What's the best way to check if the tick is the first tick of the new bar? | blooms | Metatrader 4 | 2 | 10-31-2006 06:10 AM |
| Problem using Variables Tick-by-Tick | unltdsoul | Metatrader 4 | 2 | 07-04-2006 03:36 AM |
| About start() | The_N | Indicators - Metatrader 4 | 1 | 05-21-2006 03:20 PM |