Data Export to CSV and Multi Timeframe
Data Export to CSV and Multi Timeframe
03 Jan 2019, 08:25
Good night
"GetSymbol" is not supported in backtesting, i export real data to .CSV file and i do the backtest in Excel.
The export code to .csv is the following link (https://ctrader.com/algos/cbots/show/588), with change wich exported data is every minute by "protected override void OnBar()" that calls the structure "private void ExportData()" because cBot needs to run in Minute timeframe.
I need cBot export hourly but the strategy stays in the 1 minute timeframe (OnBar())
Can someone help me?
Im sorry my English.
Happy new year full of pips (:
Replies
DelFonseca
03 Jan 2019, 08:55
Hi Paul Hayes,
Thank you very much for your reply.
I already have here in my files, this code also doesnt do what i want.
I currently have exporting on OnBar(1 minute timeframe) wich is where the strategy runs, but i want to export hourly.
Thank you again.
@DelFonseca
ClickAlgo
03 Jan 2019, 10:12
one option is to create a timer that runs every 60 mins and this timer will have an event handler method that will get called, in this method you save your values, this way you can have a 1-min TF on the chart, but the data is saved every hour.
Just Google the C# Timer class for examples on how to implement.
For further help post of Stackoverflow.
@ClickAlgo
DelFonseca
03 Jan 2019, 20:21
Hi Paul,
That's a good ideia. I will creat a timer to export hourly.
Thank you again!
@DelFonseca
DelFonseca
03 Jan 2019, 23:30
If someone needs the solucion:
using System.Timers; (...) int lastHour; (...) protected override void OnStart() { var aTimer = new System.Timers.Timer(1000); //1000 = One second. (use less to add precision, use more to consume less processor time lastHour = DateTime.Now.Hour; aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent); } private void OnTimedEvent(object source, ElapsedEventArgs e) { if (lastHour < DateTime.Now.Hour || (lastHour == 23 && DateTime.Now.Hour == 0)) { lastHour = DateTime.Now.Hour; YourImportantMethod(); // Call The method with your important staff.. } }
@DelFonseca
ClickAlgo
03 Jan 2019, 08:39
Hi DelTrader,
You may also find these free tools useful for reading and writing CVS files with the cTrader platform.
How to Save To A CSV File
How to Read From a CSV File
Paul Hayes
Sales & Marketing
Email: contact@clickalgo.com
Phone: (44) 203 289 6573
Website: https://clickalgo.com
Twitter | Facebook | Google+ | YouTube | Pinterest | LinkedIn
@ClickAlgo