My question lacks certainly knowledge, but unfortunately I didn't find
any documentation about it.
I have the following code which works as wanted except at the end,
as it writes all the values in the file and not only the values just
before the switch of the signal. This code is joint to a strategy
which generates alternatively long- and shortsignals.
filepath = "C:\\ScanExport.txt";
fdelete( filepath );
fh = fopen( filepath, "a", True );
qs = "";
if ( fh )
dt = DateTime();
fputs( Name() + "," , fh );
fputs( "DT,sig,entry,stop,prof,loss\n", fh );
for ( i = 0; i < BarCount; i++ )
fputs( DateTimeToStr( dt[ i ] ) + ",", fh );
qs = StrFormat( "%g,%g,%g,%g,%g\n", Ref(lastsignal[ i ],-1), Ref(entry[ i ],-1), Ref(realstopprice[ i ],-1) , PrecRound(Ref( bestprofit[ i ],-1), roundl ),PrecRound( Ref(worstloss[ i ],-1), roundl));
addtxtcond = LastSignal[ i ] != Ref(LastSignal[ i ],-1);
IIf(addtxtcond,fputs( qs, fh ),null);
fclose( fh );
So the addtxtcond doesn't seem to work, as the file is filled with
all the data and not only those before the change of the signal occurs.
Thank you for your attention
If you are scanning multiple symbols in multithread, its best to put each symbol in its own file or maybe put the Name() in along with each line. ( When i tested, if many threads are writing to same file, you may get unexpected result so if each single write has all the info then it will not be an issue. )
Thank you for your notice.
My idea was, as I apply this to intradaycharts which cover about a month of data,
to run it again after a month to get a continued kind of trackrecord by appending
the results to the previous ones.
But in this case indeed it makes no sens to start by deleting the file each time.
So I modified the code to have the choice.
For those who are interested it looks now basically like this