I need an ea that open an order at a certain price if the candle close above/bellow it.

To add comments, please log in or register
Lucas Santana
34
Lucas Santana  

Hi, I am searching for an EA that can only open an order when the candle closesabove or below a specific price. Could somebody help me?


Thanks.

Kenneth Parling
6886
Kenneth Parling  
Lucas Santana:

Hi, I am searching for an EA that can only open an order when the candle closesabove or below a specific price. Could somebody help me?


Thanks.

i recommend to use Freelance and have it developed

Lucas Santana
34
Lucas Santana  

I found an indicator that can send me an email below or above a certain price, here is the code.

//+------------------------------------------------------------------+
extern int     TimeFrame = 0;
extern double  PriceTest = 0.0;
extern int     CloseCandleShift=1;// 1:the last candle, 2:two candles ago, etc. pp.

extern bool    AlertAbove  = true,
               AlertBelow  = true,
               EmailAlertAbove=false,
               EmailAlertBelow=false,
               SendPushNotificationAbove=false,
               SendPushNotificationBelow=false,
               PlaySoundAbove=false,
               PlaySoundBelow=false;
extern string  SoundFileAbove="alert.wav",
               SoundFileBelow="alert2.wav";

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
 if (TimeFrame==0) TimeFrame=Period();
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//----
      string msg;
      static int AlertPrevTime = 0;
      if (Time[0] <= AlertPrevTime) { 
      return;
      }
      double testclose = iClose(NULL,TimeFrame,1);
      
      if(testclose>PriceTest && PriceTest!=0)
       {
        msg=Symbol() + " Price Has Closed Above "+ DoubleToStr(PriceTest,MarketInfo(Symbol(),MODE_DIGITS)) + " On "+ TimeFrame+" Minute Bar";
        if(AlertAbove)Alert(msg);
        if(EmailAlertAbove)SendMail(Symbol() + " Price Close Alert!",msg);
        if(PlaySoundAbove) PlaySound(SoundFileAbove);
        if(SendPushNotificationAbove) SendNotification(msg);
        AlertPrevTime  = Time[0];
       }
         
      if(testclose<PriceTest && PriceTest!=0)
       {
        msg=Symbol() + " Price Has Close Below "+ DoubleToStr(PriceTest,MarketInfo(Symbol(),MODE_DIGITS)) + " On "+ TimeFrame+ " Minute Bar";
        if(AlertBelow)Alert(msg);
        if(EmailAlertBelow)SendMail(Symbol() + " Price Close Alert!",msg);
        if(PlaySoundBelow) PlaySound(SoundFileBelow);
        if(SendPushNotificationBelow) SendNotification(msg);       
        AlertPrevTime  = Time[0];
       }
//----
   return(0);
  }
//+------------------------------------------------------------------+


Now I would like to do an EA that can close all open orders and close all the EA's on the same currency pair. Here its my idea


//+------------------------------------------------------------------+
extern int     TimeFrame = 0;
extern double  PriceTest = 0.0; 
extern double  PriceStop = 0.0; //price to close all orders and EA's
extern int     CloseCandleShift=1;// 1:the last candle, 2:two candles ago, etc. pp.

extern bool    AlertAbove  = true,
               AlertBelow  = true,
               EmailAlertAbove=false,
               EmailAlertBelow=false,
               SendPushNotificationAbove=false,
               SendPushNotificationBelow=false,
               PlaySoundAbove=false,
               PlaySoundBelow=false;
extern string  SoundFileAbove="alert.wav",
               SoundFileBelow="alert2.wav";

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
 if (TimeFrame==0) TimeFrame=Period();
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//----
      string msg;
      static int AlertPrevTime = 0;
      if (Time[0] <= AlertPrevTime) { 
      return;
      }
      double testclose = iClose(NULL,TimeFrame,1);
      
      if(testclose>PriceTest && PriceTest!=0 && testclose<PriceStop)
       {
        msg=Symbol() + " Price Has Closed Above "+ DoubleToStr(PriceTest,MarketInfo(Symbol(),MODE_DIGITS)) + " On "+ TimeFrame+" Minute Bar";
        if(AlertAbove)Alert(msg);
        if(EmailAlertAbove)SendMail(Symbol() + " Price Close Alert!",msg);
        if(PlaySoundAbove) PlaySound(SoundFileAbove);
        if(SendPushNotificationAbove) SendNotification(msg);
        AlertPrevTime  = Time[0];
       } else //I dont know how to close all open orders and remove all EA's for this currency pair, maybe ExpertRemove(); ?
         
      if(testclose<PriceTest && PriceTest!=0 && testclose>PriceStop)
       {
        msg=Symbol() + " Price Has Close Below "+ DoubleToStr(PriceTest,MarketInfo(Symbol(),MODE_DIGITS)) + " On "+ TimeFrame+ " Minute Bar";
        if(AlertBelow)Alert(msg);
        if(EmailAlertBelow)SendMail(Symbol() + " Price Close Alert!",msg);
        if(PlaySoundBelow) PlaySound(SoundFileBelow);
        if(SendPushNotificationBelow) SendNotification(msg);       
        AlertPrevTime  = Time[0];
       } else //I dont know how to close all open orders and remove all EA's for this currency pair, maybe ExpertRemove(); ?
//----
   return(0);
  }
//+------------------------------------------------------------------+


Thanks

To add comments, please log in or register