A coding guru will laugh at this, but....

 

I'm trying to modify TickLoggerForFXT.mq4 by Paul Hampton-Smith, but this doesn't ever go into my main loop. I've got EA's enabled and Allow Live Trading set on MT4.

The comment Past File Seek shows up on the chart (and stays there...) and the file has Date,Time,Open,High,Low,Close, (but no data) and

the Starting Main Loop comment never shows on the chart.

So.... why is this not going into the main loop?

Thank you for the help

Dollarshort

extern double Range = 0.10;

int handle;

int nTickCount;

datetime CurrTime, LastTime;

double LastBid, HighBid, LowBid, OpenBid, CloseBid;

double CloseBarHigh, CloseBarLow;

bool go = true;

int init()

{

Comment("Waiting for tick 062007_01");

handle = FileOpen(Symbol() +"RangeBar.csv", FILE_CSV|FILE_READ|FILE_WRITE, ',' );

FileSeek(handle,0,SEEK_END);

Comment("Past File Seek.");

FileWrite(handle,"Date,Time,Open,High,Low,Close");

}

int deinit()

{

FileClose(handle);

}

int start()

{

Comment("Starting Main Loop.");

CurrTime=TimeCurrent();

LastTime=TimeCurrent();

LastBid = Bid;

OpenBid = Bid;

CloseBid = Bid;

LowBid = Bid;

HighBid = Bid;

CloseBarHigh = LowBid + Range;

CloseBarLow= HighBid - Range;

Comment("Going into While loop.");

while(go)

{

Comment("In While Loop.");

if (CurrTime != TimeCurrent())

{

Comment("In If Statement.");

CurrTime = TimeCurrent();

nTickCount++;

if(Bid < LowBid ) LowBid = Bid;

if(Bid > HighBid) HighBid = Bid;

CloseBarHigh = LowBid + Range;

CloseBarLow= HighBid - Range;

Comment("\nLogging tick #",nTickCount);

FileWrite(handle,TimeToStr(CurTime(),TIME_DATE),TimeToStr(CurTime(),TIME_SECONDS),DoubleToStr(OpenBid,2),DoubleToStr(HighBid,2),

DoubleToStr(LowBid,2),DoubleToStr(CloseBid,2));

}

Comment("Out of If Statement.");

FileFlush(handle);

}

Comment("Out of While Statement.");

return(0);

}

 

Mladen,

Thanky you for the help. Looking at the style of the code now, I guess that I should have run it through MT4's EA wizard. Also I notice that the comments are missing, so I'll look and see if EAs can have comments....

If you ran this I'm sure you noticed that the logic is still flawed, but at least now I can see what is wrong (almost everything) and go from there...

Thanks again!

DollarShort

 

Try this

The file in the attachment works

Reason: