what i like to achieve is that instead of every tick the bid and ask price will be saved to a csv file, i like to have the bid and ask price saved in a csv file for every second.
i tried the sleepcommand for and add 1000 milliseconds but that does not work. could anybody help me fix the code? ( code is below )
thanks in advance
what i like to achieve is that instead of every tick the bid and ask price will be saved to a csv file, i like to have the bid and ask price saved in a csv file for every second.
i tried the sleepcommand for and add 1000 milliseconds but that does not work. could anybody help me fix the code? ( code is below )
thanks in advance
there is not every second a new tick.......
i know, but i dont care. all i want is 1 bid and ask price every second and that is it.
sorry raptorUK i didnt read your part.
i just tried it and seems to work.
however when i add it on the GBPUSD for example i get some mismatches.
so lets say price is 1.63450 i get then like 1.6345 and 0 is missing. but i can easily fix this in excel myself.
again thanks for the help! and for fast reply!
sorry raptorUK i didnt read your part.
i just tried it and seems to work.
however when i add it on the GBPUSD for example i get some mismatches.
so lets say price is 1.63450 i get then like 1.6345 and 0 is missing. but i can easily fix this in excel myself.
again thanks for the help! and for fast reply!
If you never exit start() Bid and Ask are never updated . . . unless you RefreshRates()
sorry raptorUK i didnt read your part.
i just tried it and seems to work.
however when i add it on the GBPUSD for example i get some mismatches.
so lets say price is 1.63450 i get then like 1.6345 and 0 is missing. but i can easily fix this in excel myself.
again thanks for the help! and for fast reply!
What is it wrong? (this is MT5). How can I test in backtest?
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int handle;
bool testing=true;
MqlTick tick;
int OnInit()
{
//Open file/////////////////////////////////////////////////////////////////////////////////////////////////////////
handle=FileOpen("test.csv",FILE_CSV|FILE_READ|FILE_WRITE,';');
if(handle<1)
{
Comment("File test.csv not found, the last error is ", GetLastError());
return(false);
}
else
{
Comment("Ok");
FileWrite(handle, "Time","Bid","Ask");
Comment("1");
}
return(handle);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit(bool handle)
{
//Close file////////////////////////////////////////////////////////////////////////////////////////////////////
FileClose(handle);
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
int i=0;
//Write to file//////////////////////////////////////////////////////////////////////////////////////////////
while(testing){
FileWrite(handle,TimeToString( TimeCurrent(), TIME_DATE | TIME_SECONDS ), tick.bid,tick.ask);
Sleep(1000);
}
return(0);
}
//+------------------------------------------------------------------+
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
what i like to achieve is that instead of every tick the bid and ask price will be saved to a csv file, i like to have the bid and ask price saved in a csv file for every second.
i tried the sleepcommand for and add 1000 milliseconds but that does not work. could anybody help me fix the code? ( code is below )
thanks in advance