Download MetaTrader 5
To add comments, please log in or register
How to test a program before buying?
Automated-Trading
Admin
88368
Automated-Trading 2015.04.24 15:41 

Arbitrage:

The indicator draws two lines that represent the difference between two currencies derived from three pairs/currencies.

Difference between two currencies.

Author: pipPod

gerardplatero
16
gerardplatero 2015.04.29 10:18  

HI pipPod,


Is it possible to have an EA that alerts when the color changes from blue to green and viceversa ?!


Thank you so much.

Ernst Van Der Merwe
4397
Ernst Van Der Merwe 2015.04.29 13:43  
gerardplatero:

HI pipPod,


Is it possible to have an EA that alerts when the color changes from blue to green and viceversa ?!


Thank you so much.

input bool AlertsOn=true;     //Alert when cross

      BaseBuffer[i] = baseIndex;
      QoteBuffer[i] = qoteIndex;
//---
      if(FillBuffers)
        {
         colorFill = (baseIndex>qoteIndex)?color1:color2;
         ObjectCreate((string)(uint)time[i],time[i],BaseBuffer[i],QoteBuffer[i]);
        }  
      if(AlertsOn && prev_calculated>0)
        {
         static datetime timePrev;
         if(BaseBuffer[i]>QoteBuffer[i] &&
            BaseBuffer[i+1]<QoteBuffer[i+1] &&
            timePrev!=time[0])
           {
            Alert("Buy "+_Symbol);
            timePrev = time[0];
           }
         if(BaseBuffer[i]<QoteBuffer[i] &&
            BaseBuffer[i+1]>QoteBuffer[i+1] &&
            timePrev!=time[0])
           {
            Alert("Sell "+_Symbol);
            timePrev = time[0];
           }
        }
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }

or

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   double baseCurr = iCustom(NULL,0,"Arbitrage",0,0);
   double basePrev = iCustom(NULL,0,"Arbitrage",0,1);
   double quoteCurr = iCustom(NULL,0,"Arbitrage",1,0);
   double quotePrev = iCustom(NULL,0,"Arbitrage",1,1);

   static datetime timePrev;
   if(baseCurr>quoteCurr &&
      basePrev<quotePrev &&
      timePrev!=Time[0])
     {
      Alert("Buy ",_Symbol);
      timePrev=Time[0];
     }
   if(baseCurr<quoteCurr &&
      basePrev>quotePrev &&
      timePrev!=Time[0])
     {
      Alert("Sell ",_Symbol);
      timePrev=Time[0];
     }
  }
//+------------------------------------------------------------------+
Enoch
9
Enoch 2015.04.30 15:25  

I think there is a mistake at OnInit() where you check the USDJPY pair

 

if(_Symbol==USDJPY)  
     {
      color1 = clrLimeGreen;
      color2 = clrYellow;
      quoteJPY = true;
      symbol1 = _Symbol;
      quoteJPY1 = true;
      symbol2 = "EURUSD";
      symbol3 = "EURJPY"; // was USDJPY
      quoteJPY3 = true;
     }

 then inverting the index3 value :

 

      case INDICATOR_DEMARK:
            index1 = iDeMarker(symbol1,TimeFrame,DeMarkerPeriod,shift)-.5;
            index2 = iDeMarker(symbol2,TimeFrame,DeMarkerPeriod,shift)-.5;
            index3 = iDeMarker(symbol3,TimeFrame,DeMarkerPeriod,shift)-.5;
        }
//--- Add this code
      if (_Symbol==USDJPY)
        index3=1/index3;
        
      if(quoteUSD)
        {
         baseIndex = (index1+index2)/2;
         index1 *= -1;
         qoteIndex = (index1+index3)/2;          
        }

 

 Maybe correct?

 

Anyway I find your indicator very useful. 

Ernst Van Der Merwe
4397
Ernst Van Der Merwe 2015.05.02 10:38  
Enoch:

I think there is a mistake at OnInit() where you check the USDJPY pair

 

 then inverting the index3 value :

 

 

 Maybe correct?

 

Anyway I find your indicator very useful. 

Hi Enoch,

Thanks for pointing that out! I appreciate it. Only the symbol needs to change though, not the inverting. I've resubmitted with the correction.

candletrader
4
candletrader 2015.06.29 11:58  

hi,

I need an indicator to compare(the difference between them at this case) close of candle's value of two instruments in Future markets( e.g. Crude oil and Brent oil). The most important things is the missing candles in one or both charts which led me to wrong calculation. If one chart have minimum one missing candle the process go wrong way and all graph shown the wrong number from the missing candles to the first available candle in history. I believe that the solution is comparing candle's time at first and then go to next step for calculating  the difference for each pair of candles and if there is no matched candle at the same time use the earlier one for calculation. In some case this repeat for tow or more continuous missing candles .

note : Missing candles are occurred regularly in future markets charts because of server's errors or contract start time and so on.Also some low liquidity markets have many missing candles per day and it is very popular.

If any body could help me I'll be appreciated  in advance.

Best Regards,

I'm not native in English and I'm sorry for that.

carero
10
carero 2015.11.08 20:30  
Hello thank you for make this indicator pipPod, pipPod how to use this indicator properly? since i try to install it in my U/J E/J and E/U chart buy it's different from your picture, so i thought i messed up something, but dont know what i do wrong, pls pippod help me to answer this question, thank you



Ernst Van Der Merwe
4397
Ernst Van Der Merwe 2015.11.09 11:36  
carero:
Hello thank you for make this indicator pipPod, pipPod how to use this indicator properly? since i try to install it in my U/J E/J and E/U chart buy it's different from your picture, so i thought i messed up something, but dont know what i do wrong, pls pippod help me to answer this question, thank you



Your symbols have suffixes e.g. USDJPY.ecn .The attached indicator should work.
Files:
Arbitrage.mq4 20 kb
/
To add comments, please log in or register