|
查看: 1008|回复: 7
|
ema alert
[复制链接]
|
|
|
|
请问有谁懂什么indicator 会alert 当price break ema。所说的并不时两个ema cross,而是price cross ema.谢谢 |
|
|
|
|
|
|
|
|
|
|
发表于 16-1-2009 10:32 AM
|
显示全部楼层
// Buy_Order.mq4
#property copyright "Copyright ?2009, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
extern int EMA_Frame = 30;
extern int EMA_Take_Action = 40;
extern int EMA_Buy_Sell = 50;
extern double StopLoss = 25;
extern double SetNewStopLoss = 0.0025;
extern double OrderLot = 1.0;
string BidPrevious = "Unknown";
string BidLatest = "Unknown";
int init() // expert initialization function
{
Print("init";
return(0);
}
int deinit() // expert deinitialization function
{
Print("deinit";
return(0);
}
int OrdersCount()
{
int totalOrders = OrdersTotal();
int count =0;
for(int cnt = 0 ; cnt < totalOrders ; cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol())
count++;
}
return (count);
}
int start() // expert start function
{
int totalOrders;
Print("------------- start -------------";
totalOrders = OrdersCount();
Print("orders ", totalOrders);
double EMA_Take_Action_Value = iMA(NULL,EMA_Frame,EMA_Take_Action,0,1,0,0);
double EMA_Buy_Sell_Value = iMA(NULL,EMA_Frame,EMA_Buy_Sell,0,1,0,0);
Print("EMA frame ", EMA_Frame);
Print("EMA take action ", EMA_Take_Action);
Print("EMA buy sell ", EMA_Buy_Sell);
Print("Stoploss ", StopLoss);
Print("Set new stop loss ", SetNewStopLoss);
Print("Lots ", OrderLot);
Print("EMA take action value ", EMA_Take_Action_Value);
Print("EMA buy sell value ", EMA_Buy_Sell_Value);
Print("Bid value ", Bid);
if(Bid - EMA_Buy_Sell_Value >= 0 && Bid - EMA_Buy_Sell_Value <= 0.0005)
{
PlaySound("003.wav";
}else{
if(Bid - EMA_Buy_Sell_Value >= -0.0005 && Bid - EMA_Buy_Sell_Value <= -0.0001)
{
PlaySound("004.wav";
}else{
if(Bid - EMA_Take_Action_Value >= 0 && Bid - EMA_Take_Action_Value <= 0.0005)
{
PlaySound("news.wav";
}else{
if(Bid - EMA_Take_Action_Value >= -0.0005 && Bid - EMA_Take_Action_Value <= -0.0001)
{
PlaySound("stops.wav";
}
}
}
}
double BidActionDiffrence = Bid - EMA_Take_Action_Value;
Print("************ Bid take action diffrence ************ ", BidActionDiffrence);
if(BidPrevious == "Unknown"
{
Print("Bid Previous 1-1 ", BidPrevious);
Print("Bid Latest 1-1 ", BidLatest);
if(BidActionDiffrence >= 0){
BidLatest = "Upper";
}else{
BidLatest = "Lower";
}
BidPrevious = "Known";
Print("Bid Previous 1-2 ", BidPrevious);
}else{
Print("Bid Latest 2-1 ", BidLatest);
Print("Bid Previous 2-1 ", BidPrevious);
BidPrevious = BidLatest;
Print("Bid Previous 2-2 ", BidPrevious);
if(BidActionDiffrence >= 0){
BidLatest = "Upper";
}else{
BidLatest = "Lower";
}
Print("Bid Latest 2-2 ", BidLatest);
}
if(EMA_Take_Action_Value - EMA_Buy_Sell_Value > 0) // decide buy or sell
{
int ticketBuy;
if(Bid - EMA_Take_Action_Value >= 0.0001 && Bid - EMA_Take_Action_Value <= 0.0005 && totalOrders < 1)
{
if(BidPrevious == "Lower"
{
ticketBuy=OrderSend(Symbol(),OP_BUY,OrderLot,Ask,3,Ask-StopLoss*Point,0,"My order #2",16384,0,Green);
PlaySound("ok.wav";
if(ticketBuy<0)
{
Print("OrderSend failed with error # ",GetLastError());
return(0);
}
}
}
}
if(totalOrders > 0) // set new stop loss
{
double PriceDiffrence = Bid - OrderOpenPrice();
Print("Order Ticket ", OrderTicket());
Print("Order Open Price ", OrderOpenPrice());
Print("Order stop loss ", OrderStopLoss());
Print("============ Bid Order Price Diffrence ============ ", PriceDiffrence);
if(Bid - OrderOpenPrice()>= SetNewStopLoss)
{
double StopLossNewValue = EMA_Take_Action_Value - 0.0005;
Print("EMA stoploss ", StopLossNewValue);
if(StopLossNewValue - OrderStopLoss() >= 0.0005)
{
OrderModify(OrderTicket(),OrderOpenPrice(),StopLossNewValue,OrderTakeProfit(),0,Blue);
}
}
return(0);
}
return(0);
} |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 16-1-2009 10:44 AM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|
发表于 16-1-2009 10:44 AM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|
发表于 16-1-2009 10:48 AM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|
发表于 16-1-2009 11:06 AM
|
显示全部楼层
原帖由 Paulps85 于 16-1-2009 10:44 AM 发表 
江大大。。
这个应该是EA的code吧!
我是看不太懂里面的冬冬。。。
请问大大,
有没有一个EA..
当4ema cross 20ema 时,
4ema 提升过20ema 就buy , 反之则 Sell
Buy 的 trade..等到 4ema 靠近20em ( 相 ...
这个很简单拉。。。
我还想写呢。。。
写完了再放上来好了。。。
 |
|
|
|
|
|
|
|
|
|
|
发表于 16-1-2009 11:08 AM
|
显示全部楼层
原帖由 clf 于 16-1-2009 10:44 AM 发表 
请问有没有简单点的?谢谢
这个最简单的了。。。
只会发出声音而已。。。

// 1st line buffer
#property copyright "Copyright ?2009, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
int init() // expert initialization function
{
Print("check init" ;
return(0);
}
int deinit() // expert deinitialization function
{
Print("check deinit" ;
return(0);
}
int start() // expert start function
{
Print("check start" ;
double EMA50_value = iMA(NULL,1,50,0,1,0,0);
double EMA250_value = iMA(NULL,1,250,0,1,0,0);
Print("check 50 ema value ", EMA50_value);
Print("check 250 ema value ", EMA250_value);
Print("check Bid value ", Bid);
Print("check 50 minus value ", Bid - EMA50_value);
Print("check 250 minus value ", Bid - EMA250_value);
if(Bid - EMA250_value >= -0.0005 && Bid - EMA250_value <= 0.0005)
{
if(Bid - EMA250_value >= 0 && Bid - EMA250_value <= 0.0005)
{
PlaySound(" ieng_ter.wav" ;
}else{
if(Bid - EMA250_value >= -0.0005 && Bid - EMA250_value <= -0.0001)
{
PlaySound("thousand_moon.wav" ;
}
}
}else{
if(Bid - EMA50_value >= 0 && Bid - EMA50_value <= 0.0005)
{
PlaySound("alert.wav" ;
}else{
if(Bid - EMA50_value >= -0.0005 && Bid - EMA50_value <= -0.0001)
{
PlaySound("stops.wav" ;
}
}
}
return(0);
}
|
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 16-1-2009 11:43 AM
|
显示全部楼层
回复 7# 江百虎 的帖子
谢谢,待会试试 |
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|