佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

搜索
查看: 1007|回复: 7

ema alert

[复制链接]
发表于 16-1-2009 10:27 AM | 显示全部楼层 |阅读模式
请问有谁懂什么indicator 会alert 当price break ema。所说的并不时两个ema cross,而是price cross ema.谢谢
回复

使用道具 举报


ADVERTISEMENT

发表于 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 | 显示全部楼层

回复 2# 江百虎 的帖子

请问有没有简单点的?谢谢
回复

使用道具 举报

发表于 16-1-2009 10:44 AM | 显示全部楼层

江大大

江大大。。
这个应该是EA的code吧!
我是看不太懂里面的冬冬。。。

请问大大,
有没有一个EA..
当4ema cross 20ema   时,
4ema 提升过20ema 就buy , 反之则 Sell
Buy  的 trade..等到 4ema 靠近20em ( 相差30pips就close order)
Sell 的 trade 也是靠近 20ema 30pip的距离就 close
这个用DAily chat 看。。。
能的话。。cross时 (就是buy or sell ) 就发出alert...平仓时也是alert..

请EA大大帮帮小弟
回复

使用道具 举报

发表于 16-1-2009 10:48 AM | 显示全部楼层

嘻嘻!

原帖由 clf 于 16-1-2009 10:44 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 ( 相 ...


这个很简单拉。。。

我还想写呢。。。

写完了再放上来好了。。。

回复

使用道具 举报

Follow Us
发表于 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# 江百虎 的帖子

谢谢,待会试试
回复

使用道具 举报


ADVERTISEMENT

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT


本周最热论坛帖子本周最热论坛帖子

ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2026 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 9-3-2026 09:20 PM , Processed in 0.105081 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表