//-------------------------------------- //--- 010 Editor v1.3.1 Binary Template // // File: 010EditorTemplate_CWS.bt // Author: C1 // Purpose: MgForex/ForexNews Charts workspace (*.CWS) and single charts (*.CHA) // Date: 2004-Apr-19 //-------------------------------------- /* http://www.SweetScape.com/ - 010 Editor - an excellent binary editor with parsing. http://www.ForexNews.com/ - Charts - a reliable Forex on-line information. CHA files contain information regarding a single chart. CWS files contain information regarding a whole workspace. This file (BT) is 010Editor language, but it will be understood by most C programmers as well (the `struct` is much more flexible here, actually it is almost a procedure). I highly recommend the 010Editor, it is a great tool and worth the money (you can try for free and support them if you like the tool). No, i don`t hold stocks of SweetScape :) The work is not complete ! The main purpose for me was to load forex history, therefor i did not pay any special attention to the information regarding the tools and indicators. You`ll see many variables with the name of `unknown` or `unk` or alike, this implies that i have no idea what this variable for. Known bugs: If the chart does not contain any trend-line it will be loaded successfully, but when many tools and indicators are used there are some cases that the template fails. I think it happends when a trend-line exceeds the visible timescale (mostly, about 500 observations), but i did not solve it (yet?) Unknown bugs: You tell me. Should anyone continue this work, please publish it in the relevant sites. C1 */ LittleEndian(); typedef enum // BOOLEAN { BOOL_FALSE=0, BOOL_TRUE=1 } BOOLEAN; //-------------------------------------- typedef struct // SPC_STR { unsigned short m_bStrExist; if (m_bStrExist == 0xFFFF) { unsigned short m_unk; unsigned short m_length; if (m_length > 0) { if (m_length > 255) { Printf("! String very long (#%Lu)\n", FTell() ); Warning("! String very long"); SetCursorPos( FTell() ); return -1; } char m_str[m_length]; } } } SPC_STR; //-------------------------------------- typedef struct // PASCAL_STR_BYTE { unsigned byte m_length; if (m_length > 0) { char m_str[m_length]; } } PASCAL_STR_BYTE; //-------------------------------------- typedef struct // COLOR_RGB { SetBackColor( cPurple ); unsigned byte m_red; unsigned byte m_green; unsigned byte m_blue; SetBackColor( cLtPurple ); unsigned byte m_pad; // always 0 if (m_pad != 0) { Printf("! Color (#%Lu)\n", FTell() ); Warning("! This is not a color"); SetCursorPos( FTell() ); return -1; } } COLOR_RGB; //-------------------------------------- typedef enum // FILE_TYPE { FILE_TYPE_UNKNOWN=0, FILE_TYPE_CWS=1, FILE_TYPE_CHA=2 } FILE_TYPE; //-------------------------------------- typedef enum // CURRENCY { CURRENCY_EUR_USD= 0, CURRENCY_USD_JPY= 1, CURRENCY_GBP_USD= 2, CURRENCY_USD_CHF= 3, CURRENCY_GBP_JPY= 4, CURRENCY_GBP_CHF= 5, CURRENCY_EUR_JPY= 6, CURRENCY_EUR_GBP= 7, CURRENCY_EUR_CHF= 8, CURRENCY_AUD_USD= 9, CURRENCY_AUD_JPY=10, CURRENCY_USD_CAD=11 } CURRENCY; //-------------------------------------- typedef enum // INTERVAL { INTERVAL_TIC= 0, INTERVAL_M1= 1, INTERVAL_M5= 2, INTERVAL_M10= 3, INTERVAL_M15= 4, INTERVAL_M30= 5, INTERVAL_H1= 6, INTERVAL_H2= 7, INTERVAL_H4= 8, INTERVAL_DAY= 9, INTERVAL_WEEK=10 } INTERVAL; //-------------------------------------- typedef enum // GRAPH { GRAPH_BAR=0, GRAPH_CANDLE=1, GRAPH_LINE=2 } GRAPH; //-------------------------------------- typedef enum // TOOL_TYPE { TOOL_TYPE_LINE= 0, TOOL_TYPE_FIBONACCI_RET1=1, TOOL_TYPE_FIBONACCI_RET2=2, TOOL_TYPE_FIBONACCI_RET3=3, TOOL_TYPE_TEXT_POINTER=4, TOOL_TYPE_TEXT_LABEL=5, TOOL_TYPE_TEXT_ONLY=6 } TOOL_TYPE; //-------------------------------------- typedef struct // CWS_HEADER { SetBackColor( cLtGray ); char m_string[30]; //// including 2 null-chars SetBackColor( cGray ); unsigned int m_version; Printf ("Version: %d\n", m_version); SetBackColor( cLtGray ); unsigned byte m_unkn[40]; SetBackColor( cGray ); unsigned int m_countCharts; } CWS_HEADER; //-------------------------------------- typedef struct // CHART_WINPOS { SetBackColor( cGray ); int m_left; SetBackColor( cLtGray ); int m_top; SetBackColor( cGray ); int m_right; SetBackColor( cLtGray ); int m_bottom; } CHART_WINPOS; //-------------------------------------- typedef struct // TOOL_RGN { SetBackColor( cDkAqua ); double price1; SetBackColor( cAqua ); double price2; SetBackColor( cDkAqua ); int m_unk2; SetBackColor( cAqua ); OLETIME m_time1; SetBackColor( cDkAqua ); int m_unk3; SetBackColor( cAqua ); OLETIME m_time2; } TOOL_RGN; //-------------------------------------- typedef struct // TOOLS { SetBackColor( cAqua ); short m_countTools; if (m_countTools > 0) { SetBackColor( cLtAqua ); SPC_STR m_string; local int iTools; for (iTools= 0; iTools < m_countTools; ++iTools) { TOOL_RGN m_rgn; SetBackColor( cDkAqua ); BOOLEAN m_bStop; SetBackColor( cAqua ); TOOL_TYPE m_toolType; SetBackColor( cDkAqua ); if ( (m_toolType == TOOL_TYPE_TEXT_POINTER) || (m_toolType == TOOL_TYPE_TEXT_LABEL) || (m_toolType == TOOL_TYPE_TEXT_ONLY) ) { int m_unk; PASCAL_STR_BYTE m_str; } SetBackColor( cAqua ); if (iTools < m_countTools - 1) { short m_roba; } } } } TOOLS; //-------------------------------------- typedef struct // TOOLSCOLOR { local int iToolsCol; for (iToolsCol=0; iToolsCol < 20; ++iToolsCol) COLOR_RGB m_colors; } TOOLSCOLOR; //-------------------------------------- typedef struct // MAIN_HEADER { SetBackColor( cLtGreen ); CURRENCY m_currency; SetBackColor( cGreen ); INTERVAL m_interval; SetBackColor( cLtGreen ); GRAPH m_graph; SetBackColor( cGreen ); BOOLEAN m_bGrid; SetBackColor( cLtGreen ); int m_unk1; SetBackColor( cGreen ); int m_unk2; SetBackColor( cLtGreen ); double m_max; SetBackColor( cGreen ); double m_min; SetBackColor( cLtGreen ); int m_zoom; // 0=All } MAIN_HEADER; //-------------------------------------- typedef struct // PRICE_RECORD { SetBackColor( cLtYellow ); double m_open; SetBackColor( cYellow ); double m_close; SetBackColor( cLtYellow ); double m_low; SetBackColor( cYellow ); double m_high; SetBackColor( cDkYellow ); unsigned int m_n; SetBackColor( cLtYellow ); OLETIME m_time; SetBackColor( cDkYellow ); } PRICE_RECORD; //-------------------------------------- typedef struct // RECORDS { SetBackColor( cGreen ); short m_countObs; SetBackColor( cLtGreen ); SPC_STR m_string; local int iRecord; for (iRecord= 0; iRecord < m_countObs; ++iRecord) { PRICE_RECORD record; if (iRecord < m_countObs - 1) unsigned short m_roba; } } RECORDS; //-------------------------------------- typedef struct // UNK_INDEX { BOOLEAN m_bDraw; // ? int m_period; // ? short m_unk; if (m_unk != 0) { Printf("UnkIndex (#%Lu)\n", FTell() ); } } UNK_INDEX; //-------------------------------------- typedef struct // UNK_INDEX2 { BOOLEAN m_bDraw; // ? int m_period; // ? short m_countUnk2; if (m_countUnk2 != 0) { Printf("UnkIndex2 (#%Lu)\n", FTell() ); local int iUnk2; for (iUnk2=0; iUnk2 < m_countUnk2; ++iUnk2) { struct { unsigned short m_unk[25]; } m_infoUnk2; } } } UNK_INDEX2; //-------------------------------------- typedef struct // INDEXSTRENDS { SetBackColor(cAqua); unsigned short m_unk1; unsigned short m_countTrends; if (m_countTrends != 0) { Printf("Trends (#%Lu)\n", FTell() ); SetCursorPos( FTell() ); SPC_STR m_string; local int iTrends; for (iTrends= 0; iTrends < m_countTrends; ++iTrends) { struct TrendEx { unsigned byte m_unk[40]; unsigned int m_unk1; unsigned int m_ex; // ? if (m_ex > 0) { Printf("trend-ex (#%Lu)\n", FTell() ); SetCursorPos( FTell() ); struct { unsigned byte m_unk[73]; } m_trendsex; } } m_trend; if (m_trend.m_ex > 0) ++iTrends; if (iTrends < m_countTrends-1) unsigned short m_roba; } } } INDEXSTRENDS; //-------------------------------------- typedef struct // INDICES3 { struct Stoch { SetBackColor( cPurple ); BOOLEAN m_bDrawStoch; SetBackColor( cDkPurple ); int m_stochD; SetBackColor( cPurple ); int m_stochParams; // D + 500*slow (D 1-400; slow 1-60) } m_stochastics; SetBackColor( cBlue ); UNK_INDEX m_unk1; struct Rsi { SetBackColor( cPurple ); BOOLEAN m_bDrawRSI; SetBackColor( cDkPurple ); int m_periodRSI; } m_rsi; SetBackColor( cLtBlue ); UNK_INDEX2 m_unk2; struct Momentum { SetBackColor( cPurple ); BOOLEAN m_bDrawMomentum; SetBackColor( cDkPurple ); int m_periodMomentum; } m_momentum; SetBackColor( cLtBlue ); UNK_INDEX m_unk3; struct Roc { SetBackColor( cPurple ); BOOLEAN m_bDrawROC; SetBackColor( cDkPurple ); int m_periodROC; } m_roc; SetBackColor( cBlue ); UNK_INDEX m_unk4; struct Bollinger { SetBackColor( cPurple ); BOOLEAN m_bDrawBollinger; SetBackColor( cDkPurple ); signed int m_bollingerParams; //// Period*DT; DT=1:Deviation=1, DT=-1:Deviation=2 } m_bollinger; struct Macd { SetBackColor( cBlue ); BOOLEAN m_bDrawMACD; SetBackColor( cLtBlue ); int m_periodLongMACD; SetBackColor( cBlue ); int m_unk; SetBackColor( cLtBlue ); short m_macdParams; //// ShP*100+SP; ShP=Short-Period, SP=Signal-Period SetBackColor( cBlue ); } m_macd; INDEXSTRENDS m_trends; struct Dmi { SetBackColor( cPurple ); int m_smoothDMI; SetBackColor( cDkPurple ); int m_periodsDMI; SetBackColor( cPurple ); BOOLEAN m_bDrawDMI; } m_dmi; struct Unk5 { SetBackColor( cBlue ); int m_unk1; short m_unk2; } m_unk5; } INDICES3; //-------------------------------------- typedef struct // INDICES4 { INDICES3 m_indices3; struct ParSar { SetBackColor( cPurple ); BOOLEAN m_bDrawParSar; SetBackColor( cDkPurple ); float m_stepParSar; SetBackColor( cPurple ); float m_maxParSar; } m_parsar; } INDICES4; //-------------------------------------- typedef struct // MOVAVGLINE { SetBackColor( cLtRed ); COLOR_RGB m_color; SetBackColor( cRed ); unsigned short m_period; SetBackColor( cLtRed ); unsigned short m_unk; SetBackColor( cRed ); unsigned int m_param; // Shift*10+Type; Type:0=Simple;1=Weighted;2=Exponential;3=Displaced;4=Envelope } MOVAVGLINE; //-------------------------------------- typedef struct // MOVING_AVG { SetBackColor( cLtRed ); unsigned byte m_countMovAvg; SetBackColor( cRed ); unsigned byte m_unk; if (m_countMovAvg > 0) { Printf("There are %d MovAvg lines\n", m_countMovAvg); SetBackColor( cLtRed ); SPC_STR m_string; local int iMovAvg; for (iMovAvg= 0; iMovAvg < m_countMovAvg; ++iMovAvg) { MOVAVGLINE m_line; if (iMovAvg < m_countMovAvg -1) unsigned short m_roba; } } } MOVING_AVG; //-------------------------------------- typedef struct // CHARTINFO3 { MAIN_HEADER m_hdrMain; TOOLSCOLOR m_colorTools; TOOLS m_tools; RECORDS m_records; MOVING_AVG m_movAvg; INDICES3 m_indices; } CHARTINFO3; //-------------------------------------- typedef struct // CHARTINFO4 { MAIN_HEADER m_hdrMain; TOOLSCOLOR m_colorTools; TOOLS m_tools; RECORDS m_records; MOVING_AVG m_movAvg; INDICES4 m_indices; } CHARTINFO4; //-------------------------------------- SetBackColor( cLtGray ); Warning(""); // reset previous warnings Printf("Starting...\n"); local FILE_TYPE filetype= FILE_TYPE_UNKNOWN; { local string filename= GetFileName(); local int len= Strlen(filename); if (len < 4) { Warning("! Filename"); return -1; } local string ext= filename[len-4] ; ext += filename[len-3] ; ext += filename[len-2] ; ext += filename[len-1] ; Printf("file '%s'\nfile extension: '%s'\n", filename, ext); if (Stricmp(ext,".CWS")==0) { filetype= FILE_TYPE_CWS; Printf("CWS file\n"); } if (Stricmp(ext,".CHA")==0) { filetype= FILE_TYPE_CHA; Printf("CHA file\n"); } } //-------------------------------------- if (filetype == FILE_TYPE_UNKNOWN) { Warning("! File type"); return -1; } //-------------------------------------- if (filetype == FILE_TYPE_CHA) { CHARTINFO4 m_chart; } //-------------------------------------- if (filetype == FILE_TYPE_CWS) { CWS_HEADER hdrCws; local int iCharts; for (iCharts=0; iCharts < hdrCws.m_countCharts; ++iCharts) { Printf("Chart %d (#%Lu)\n", iCharts, FTell() ); CHART_WINPOS m_winpos; if (hdrCws.m_version == 3 ) { CHARTINFO3 m_chart3; } if (hdrCws.m_version == 4 ) { CHARTINFO4 m_chart4; } } } //-------------------------------------- if (FTell() != FileSize() ) { Printf("! file size (#%Lu)\n", FTell() ); Warning("! file size"); SetCursorPos( FTell() ); return -1; } //-------------------------------------- Printf("Done successfully\n"); Warning("OK :)"); return 0; //// End of file