• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 4:35am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 4:35am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

MT4 to Excel through Excel RTD (Finally!) 577 replies

Export to Excel in Real Time 27 replies

Export to Excel in Real Time - library for MetaTrader 4 21 replies

Exporting data from Metatrader into Excel in real time 32 replies

Simple way of exporting MT4 data from Data Window into Excel? 2 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
  • 1
Attachments: [Excel] How to store time with real-time data?
Exit Attachments

[Excel] How to store time with real-time data?

  • Post #1
  • Quote
  • First Post: Edited at 11:17am Sep 18, 2015 7:11am | Edited at 11:17am
  •  drammen
  • | Joined Feb 2015 | Status: Dee50's Disciple | 177 Posts
I apologies in advance if this has already been answered, do point me in the right direction if that were to be the case. I have managed to store BID and ASK prices by using xlsgate. I'm having a hard time to add timestamp whenever there is a change in price. How would one go about coding that into mql->excel?

I am by no means a coder, hardly a "scriptkiddie" if you will. So i apologies in advance if this code looks rubbish.
This is how it looks like:
Attached Image

Inserted Code
//+------------------------------------------------------------------+
//|                                                        Test1.mq4 |
//|                        Copyright 2015, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#include <xlsgate.mqh>
extern string StartBid= "C3";
extern string StartAsk= "D3";
 
bool xlsgateok=false;
string StrBid;
string StrAsk;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
  StrBid=StartBid;
  StrAsk=StartAsk;
  
   if (ExcelInit("mt4") && ExcelStart(""))
   {
   Print("XLSgate init done");
   xlsgateok=true;
   Print("Office version = "+ExcelVersion());
   ExcelSheetAdd("MT4");
   }
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
  
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
double lastBid=0;
double lastAsk=0;
void OnTick()
  {
//---
   if(xlsgateok && lastBid!=Bid)
   ExcelSetValue(StrBid,Bid);
   lastBid=Bid;
   StrBid=ExcelRowAdd(StrBid,1);
  
   if(xlsgateok && lastAsk!=Ask)
   ExcelSetValue(StrAsk,Ask);
   lastAsk=Ask;
   StrAsk=ExcelRowAdd(StrAsk,1);
  
  }
  
//+------------------------------------------------------------------+

Update 1: Found a solution. Nasty coding, but it works
Energy, frequency and vibration.
  • Platform Tech
  • /
  • [Excel] How to store time with real-time data?
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2022