Problems with storing data in Excel

 

Before i start, i want to mention that i am by no means a coder, barely a script kiddie. I have managed to store realtime price in excel with timestamp. Is there a way to only store when price is moving? Because excel keeps storing every seconds, meaning there will be lots of empty spaces with timestamp. While im at it, is there also a way to code so that when every minute passes, it jumps to the next column and stores from there? Im using xlsapp to code. Here is the 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";
extern string StartSpread="F3";
extern string StartTime="A3";




bool xlsgateok=false;
string StrBid;
string StrAsk;
string StrSpread;
string StrTime;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
  StrBid=StartBid;
  StrAsk=StartAsk;
  StrSpread=StartSpread;
  StrTime=StartTime;

  
   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;
int lastSpread=0;
datetime time=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);
   ExcelSetValue(StrSpread,(Ask-Bid)/Point);
   StrSpread=ExcelRowAdd(StrSpread,1);
   string s= TimeToStr(TimeCurrent());
   ExcelSetString(StrTime,s);
   StrTime=ExcelRowAdd(StrTime,1);
 
   
   
   
  }
  
//+------------------------------------------------------------------+
Automated Trading and Strategy Testing
Automated Trading and Strategy Testing
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
 
can i see your this file
xlsgate.mqh