Posted By: MatPed
file_append, file_appendfront - 01/30/19 09:34
Goodmorning community,
I am struggling using zorro's file_append and file_appendfront functions.
I have prepared a script to test the 2 functions:
The idea behind the script is to print the same windows output in a file in normal and reverse order.
I have tried all the 6 version listed uncommenting one of the numbered row at the time (remember to delete the file before each run).
My finding is that file_append works, but does not write the EOL so instead of a file of strings a long sequence of char is written.
file_appendfront does not work at all.
I have involved the support and they confirmed that file_appendfront() with length=0 does not work as expected.
Does anybody got some experience using this functions?
Any idea?
Ciao
I am struggling using zorro's file_append and file_appendfront functions.
I have prepared a script to test the 2 functions:
Code:
void storeTrade(); /* Stores all the trades closed this bar Use after the algo/Asset loop. Not in the loop */ void printTrade(int counter); int createReRArray(var* ReRarray, int Counter); #define _storedRER "Data\storedRER.txt" #define _storedTradeSize 50000 //1.000 trades (1.000 char [50]) #define _sTradeSize 50 char sRow[_storedTradeSize]; void storeTrade(){ char sTrade[_sTradeSize]; string ls, bo = "{", bc = "}"; for(closed_trades){ // Check only phantom trades closed this Bar if ((int) TradeBarClose == Bar) { if (TradeIsPhantom && TradeIsClosed){ if(TradeIsShort) ls = "S"; else ls = "L"; sprintf(sTrade, "n{%s:%s:%s%i}:%.2f", TradeAsset, TradeAlgo, ls, TradeID, TradeProfit ); // file_appendfront(_storedRER, sTrade, strlen(sTrade)+1 ); //<<--------- 1 // file_appendfront(_storedRER, sTrade, strlen(sTrade) ); //<<--------- 2 // file_appendfront(_storedRER, sTrade, 0); //<<--------- 3 // file_append(_storedRER, sTrade, 0); //<<--------- 4 // file_append(_storedRER, sTrade, strlen(sTrade) ); //<<--------- 5 // file_append(_storedRER, sTrade, strlen(sTrade) ); //<<--------- 6 printf("%s", sTrade); // printf("Bar:%i - %s", Bar, sTrade); } // } else break_trades; } } void run() { // set(LOGFILE); MaxLong = 5; MaxShort = 5; StartDate = 20180101; EndDate = 20180102; BarPeriod =1; Hedge = 5; algo("TREND"); LifeTime = (int) random(10); if (random(6) > 3) enterLong(); else enterShort(); enterLong(); enterShort(); storeTrade(); }
The idea behind the script is to print the same windows output in a file in normal and reverse order.
I have tried all the 6 version listed uncommenting one of the numbered row at the time (remember to delete the file before each run).
My finding is that file_append works, but does not write the EOL so instead of a file of strings a long sequence of char is written.
file_appendfront does not work at all.
I have involved the support and they confirmed that file_appendfront() with length=0 does not work as expected.
Does anybody got some experience using this functions?
Any idea?
Ciao