You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
What I need is a simple array with ask bid for 2 terminals.
Exchange_Data.mqh
PriceGiver.mq4
PriceTaker.mq4
Run PriceGiver.ex4 and PriceTaker.ex4.
Result
Thank you. It works. My questions is, will it work in full duplex mode? Meaning each platform is both giver and taker of ticks?
Thank you. It works. My questions is, will it work in full duplex mode? Meaning each platform is both giver and taker of ticks?
Read the source!
Is this EA code correct? (seems to be working)
//+------------------------------------------------------------------+
//| Forex Arb.mq4 |
//| Copyright 2017, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
#include <Exchange_Data.mqh>
#define AMOUNT 100
EXCHANGE_DATA<MqlTick> ExchangeTicks(AMOUNT, true);
const bool Init = EventSetMillisecondTimer(10);
#define TOSTRING(A) (#A + " = " + (string)(A) + " ")
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- create timer
//EventSetTimer(60);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//--- destroy timer
EventKillTimer();
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
}
//+------------------------------------------------------------------+
//| Timer function |
//+------------------------------------------------------------------+
void OnTimer()
{
//Transmitter
static MqlTick Ticks_Trn[1];
if (SymbolInfoTick(_Symbol, Ticks_Trn[0]))
ExchangeTicks.DataSave(Ticks_Trn);
//Receiver
static MqlTick PrevTick_Rcv = {0};
MqlTick Ticks_Rcv[];
if ((ExchangeTicks.DataLoad(Ticks_Rcv) > 0) &&
((Ticks_Rcv[0].bid != PrevTick_Rcv.bid) || (Ticks_Rcv[0].ask != PrevTick_Rcv.ask)))
{
Print(TOSTRING(Ticks_Rcv[0].time) + TOSTRING(Ticks_Rcv[0].bid) + TOSTRING(Ticks_Rcv[0].ask));
PrevTick_Rcv = Ticks_Rcv[0];
}
}
//+------------------------------------------------------------------+
Is it possible to save tick data info (bid,ask) together with symbol?
So I can loop thru list of symbols and save,load all data in one expert instead of attaching separate expert to separate chart symbols?
Not working in full duplex mode. It prints quotes from both terminals however I do not know which is which.
I tried to define my own struct:
struct MyTick
{
public:
datetime time; // Time of the last prices update
double bid; // Current Bid price
double ask; // Current Ask price
double last; // Price of the last deal (Last)
ulong volume; // Volume for the current Last price
string symbol;
string company;
};
and use:
static MyTick Ticks[1];
Ticks[0].time = TimeLocal();
Ticks[0].bid = Bid;
ExchangeTicks.DataSave(Ticks, true);
However when saving the array throws an error: 'Ticks' - parameter conversion not allowed PriceGiver.mq4 58 27
It is expecting struct of type MqlTick.
Can this be changed?