|
|
自己做了个多货币对均线交叉报警指标,但不工作,希望有高人指点修改
//+------------------------------------------------------------------+
//| MA cross.mq4 - I found it at fxfisherman.com |
//| Copyright 2012, www.forex-programming.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, www.forex-programming.com"
#property link "www.forex-programming.com"
#property indicator_chart_window
extern string s1="-- MA settings --";
extern int Fast_MA = 5 ;
extern int Slow_MA = 10 ;
extern string s2="-- Alert settings --";
extern bool ScreenAlert =true,
PushAlert =false;
double USDJPYFast1, USDJPYSlow1,USDCADFast1, USDCADSlow1,EURUSDFast1, EURUSDSlow1,GBPUSDFast1, GBPUSDSlow1;
double USDJPYFast2, USDJPYSlow2,USDCADFast2, USDCADSlow2,EURUSDFast2, EURUSDSlow2,GBPUSDFast2, GBPUSDSlow2;
datetime New_Time=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int limit=Bars-counted_bars;
if (limit<0) limit=0;
// define MAs values
for (int i=limit; i>=0; i--)
{
USDJPYFast1=iMA("USDJPY#", PERIOD_M1, Fast_MA, 0, MODE_SMA, PRICE_CLOSE, 1);
USDJPYSlow1=iMA("USDJPY#", PERIOD_M1, Slow_MA, 0, MODE_SMA, PRICE_CLOSE, 1);
USDCADFast1=iMA("USDCAD#", PERIOD_M1, Fast_MA, 0, MODE_SMA, PRICE_CLOSE, 1);
USDCADSlow1=iMA("USDCAD#", PERIOD_M1, Slow_MA, 0, MODE_SMA, PRICE_CLOSE, 1);
EURUSDFast1=iMA("EURUSD#", PERIOD_M1, Fast_MA, 0, MODE_SMA, PRICE_CLOSE, 1);
EURUSDSlow1=iMA("EURUSD#", PERIOD_M1, Slow_MA, 0, MODE_SMA, PRICE_CLOSE, 1);
GBPUSDFast1=iMA("GBPUSD#", PERIOD_M1, Fast_MA, 0, MODE_SMA, PRICE_CLOSE, 1);
GBPUSDSlow1=iMA("GBPUSD#", PERIOD_M1, Slow_MA, 0, MODE_SMA, PRICE_CLOSE, 1);
USDJPYFast2=iMA("USDJPY#", PERIOD_M1, Fast_MA, 0, MODE_SMA, PRICE_CLOSE, 2);
USDJPYSlow2=iMA("USDJPY#", PERIOD_M1, Slow_MA, 0, MODE_SMA, PRICE_CLOSE, 2);
USDCADFast2=iMA("USDCAD#", PERIOD_M1, Fast_MA, 0, MODE_SMA, PRICE_CLOSE, 2);
USDCADSlow2=iMA("USDCAD#", PERIOD_M1, Slow_MA, 0, MODE_SMA, PRICE_CLOSE, 2);
EURUSDFast2=iMA("EURUSD#", PERIOD_M1, Fast_MA, 0, MODE_SMA, PRICE_CLOSE, 2);
EURUSDSlow2=iMA("EURUSD#", PERIOD_M1, Slow_MA, 0, MODE_SMA, PRICE_CLOSE, 2);
GBPUSDFast2=iMA("GBPUSD#", PERIOD_M1, Fast_MA, 0, MODE_SMA, PRICE_CLOSE, 2);
GBPUSDSlow2=iMA("GBPUSD#", PERIOD_M1, Slow_MA, 0, MODE_SMA, PRICE_CLOSE, 2);
}
// Alert
{
// buy alert
if ((New_Candle() && USDJPYFast1 > USDJPYSlow1 && USDJPYFast2 <= USDJPYSlow2))
{
if (ScreenAlert) Alert("BUY - "+"USDJPY");
if (PushAlert) SendNotification("BUY -"+"USDJPY");
}
// sell alert
if ((New_Candle() && USDJPYFast1 < USDJPYSlow1 && USDJPYFast2 >= USDJPYSlow2))
{
if (ScreenAlert) Alert("SELL - "+"USDJPY");
if (PushAlert) SendNotification("SELL - "+"USDJPY");
}
// buy alert
if ((New_Candle() && USDCADFast1 > USDCADSlow1 && USDCADFast2 <= USDCADSlow2))
{
if (ScreenAlert) Alert("BUY - "+"USDCAD");
if (PushAlert) SendNotification("BUY -"+"USDCAD");
}
// sell alert
if ((New_Candle() && USDCADFast1 < USDCADSlow1 && USDCADFast2 >= USDCADSlow2))
{
if (ScreenAlert) Alert("SELL - "+"USDCAD");
if (PushAlert) SendNotification("SELL - "+"USDCAD");
}
// buy alert
if ((New_Candle() && EURUSDFast1 > EURUSDSlow1 && EURUSDFast2 <= EURUSDSlow2))
{
if (ScreenAlert) Alert("BUY - "+"EURUSD");
if (PushAlert) SendNotification("BUY -"+"EURUSD");
}
// sell alert
if ((New_Candle() && EURUSDFast1 < EURUSDSlow1 && EURUSDFast2 >= EURUSDSlow2))
{
if (ScreenAlert) Alert("SELL - "+"EURUSD");
if (PushAlert) SendNotification("SELL - "+"EURUSD");
}
// buy alert
if ((New_Candle() && GBPUSDFast1 > GBPUSDSlow1 && GBPUSDFast2 <= GBPUSDSlow2))
{
if (ScreenAlert) Alert("BUY - "+"GBPUSD");
if (PushAlert) SendNotification("BUY -"+"GBPUSD");
}
// sell alert
if ((New_Candle() && USDJPYFast1 < GBPUSDSlow1 && GBPUSDFast2 >= GBPUSDSlow2))
{
if (ScreenAlert) Alert("SELL - "+"GBPUSD");
if (PushAlert) SendNotification("SELL - "+"GBPUSD");
}
}
return(0);
}
//+------------------------------------------------------------------+
//| Define new candle |
//+------------------------------------------------------------------+
bool New_Candle()
{
if (New_Time!=Time[0])
{
New_Time=Time[0];
return(true);
}
else
{
return(false);
}
}
//+------------------------------------------------------------------+
复制代码 |
|