MQL4 - automated forex trading   /  

Forum

Login | Register | Language: ru cn en
10 000 traders are already selling signals and programs on the Market

Foolproof arbitrage EA

Back to topics list  | 1 2 To post a new topic, please log in or register
avatar
3
Ted1983 2007.03.12 20:06
 
Hi All,

I am very new to MQL4 but have been wondering about the possibility of a trianngular arbitrage EA for a while.

Here is the code ,courtesy of Codersguru, for a fractional product oscillator.
I notice this uses MODE_CLOSE for each pair, could this be applied to live tick data?
As I am assuming close data will not be reliable for triangular arbitrage,could anyone confirm this?

#property link      "http://www.xpworx.com"
#property copyright "Coders' Guru" 
 
 
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Yellow
#property indicator_level1 0
 
 
 
double Main[] , EurUsd[] ,UsdJpy[] ,EurJpy[] ;
 
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(4); 
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,Main);
   
   SetIndexBuffer(1,EurUsd);
   SetIndexBuffer(2,UsdJpy);
   SetIndexBuffer(3,EurJpy);
 
   ArrayInitialize(EurUsd,EMPTY_VALUE);
   ArrayInitialize(UsdJpy,EMPTY_VALUE);
   ArrayInitialize(EurJpy,EMPTY_VALUE);
   ArrayInitialize(Main,EMPTY_VALUE);
 
   return(0);
  }
 
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
 
//+------------------------------------------------------------------+
int start()
  {
 
   ArrayCopySeries(EurUsd,MODE_CLOSE,"EURUSD",Period());
   ArrayCopySeries(UsdJpy,MODE_CLOSE,"USDJPY",Period());
   ArrayCopySeries(EurJpy,MODE_CLOSE,"EURJPY",Period());
 
   int counted_bars=IndicatorCounted();
   int i = 0;
 
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   int limit=Bars-counted_bars;
   
   for(i=0; i<limit; i++)
   {
       Main[i] = EurUsd[i]* UsdJpy[i]* (1/EurJpy[i]);
   }
 
   return(0);
  }
//+------------------------------------------------------------------+

It would be great if somebody could make this open the hedge (i.e buy EURUSD, buy USDJPY, sell EURJPY simultaneously) when 1.0003 <FPI<0.9997,
and swap close or open when the opposite extreme is reached.
Granted the profits will be small and the above parameters may not be wide enough, but I would love to forward test this system anyway,
as it may be forexs' only "FREE LUNCH"
 
VIDEO LESSON - Trading the News: Consumer Price Index (CPI)
Released at 8:30 am eastern standard on approximately the 15th of each month, the Consumer Price Index (CPI) is a measure of the changes in prices paid by urban consumers for a fixed basket of goods and services. The PPI is designed to measure the entire marketed output of US producers which includes goods and services purchased by other producers.
avatar
322
TheEconomist 2007.03.13 20:17 #
 
There is still much to learn... Michal hid "the gold in some places, for the friends to look for it"... A crucial mistake that you do is using MODE_CLOSE. .. you lose what happens during the chosen period. Plus that only one ring is not enough.
avatar
3
Ted1983 2007.03.15 00:21 #
 

Hello'

"A crucial mistake that you do is using MODE_CLOSE"

I had already realized this if you refer to the top of the original post. My question was how to correct the problem, please be aware that I know()0 about programming, see!
Also I have tried the same indicator with various trios, but cant capitalize till the aforementioned issue is resolved.

avatar
322
TheEconomist 2007.03.15 09:40 #
 
Do not make an indicator. Instead, make a script that loops continuously and print when FPI gets out of regular range...
 
avatar
19
JosTheelen 2007.03.16 18:07 #
 
I advice against this system. I tested something like this some time ago and noticed the following:
When there are strong jumps in one of the currencies (like just after newsreports), then 2 of those pairs move very fast. That often means there is a chance on a hedge. However when you would automatically send orders, you will see that mostly only one of the orders is accepted for the price you wish, and the other is not accpeted. And the one that was accepted will be the losing one.

 
avatar
322
TheEconomist 2007.03.18 14:34 #
 
I don't have anything better on this. It's true that they are accepted with slippage, however i'm confronting the problem when one of them is not accepted at all, even if i catch execution in a while loop:

for (i=0;i<NoOfContracts;i++)
{
//WriteLn("Sending order "+OrderType2Str(Ops[i])+" "+DoubleToStr(Lots[i], 2)+" "+Contracts[i]);
Gle=ERR_TRADE_CONTEXT_BUSY;
while (Gle==ERR_TRADE_CONTEXT_BUSY||Gle==ERR_REQUOTE)
{
if (Gle==ERR_REQUOTE)
{
RefreshRates();
if (Ops[i]==OP_BUY)
Prices[i]=MarketInfo(Contracts[i],MODE_ASK);
else
Prices[i]=MarketInfo(Contracts[i],MODE_BID);
}
OrderSend(Contracts[i],Ops[i],Lots[i],Prices[i],AdmittedSlippage,0,0,comm,AccountMagic, 0,CLR_NONE);
Gle=GetLastError();
if (Gle==ERR_NO_CONNECTION)
{
if (i!=0)
Gle=ERR_TRADE_CONTEXT_BUSY;
else
break;
}
}
if (Gle==ERR_NO_CONNECTION)
break;
if (Gle!=0)
error=True;
}

I have a similar problem closing them too...
Anyway, the broker plays even a more important role than the strategy itself.
 
avatar
368
codersguru 2010.10.14 22:37 #
 

You can update the FPI indicator from here:

FPI Indicator

Last update: 11 Oct 2010

avatar
368
codersguru 2011.09.30 22:11 #
 
avatar
2
DesertSkater 2011.11.30 03:13 #
 

I have looked at the Triangular Arbitrage Indicator. That is interesing. But can you give me a pointer as to how one would be able to use this indicator to trade? You have three pairs involved. One of the pair is probably lying (lagging / slightly off) but you don't know which one is right and wrong.

 
avatar
4
avatar
2005
zzuegg 2012.01.14 17:44 #
 
DesertSkater:

I have looked at the Triangular Arbitrage Indicator. That is interesing. But can you give me a pointer as to how one would be able to use this indicator to trade? You have three pairs involved. One of the pair is probably lying (lagging / slightly off) but you don't know which one is right and wrong.

Yes, thats true. You trade all 3 pairs simultaneously. If you do the programming right, trade only when FPI > SumOfSpread+Commision the Triangular Arbitrage system works perfectly on demo accounts. However i never got the same results when trying it on a live account due to higher slippage, requotes, higher spread and higher commisions.

In theory a unbeatable system, which does not work well as an average trader

 
Back to topics list   | 1 2  

To add comments, please log in or register