Can someone add more codes for me??

 

Hi all,attached is an EA that will open X trades immediately when switch on, and after it TP or SL, it will keep on open new trades

Can anyone add some code for me, that i need "High price and Low Price", which if price above "High Price" or below "Low Price", it wont open trades.

In other words, I need it open trades only within that price range. Out of that high and low, no trade. Is that easy to add such code?

Am using it in Instaforex bi-Weekly contest. Pls kindly reply.

This is just the Buy EA, i will modify the Sell EA myself according to this Buy, thaanks again


Code:


//--------------------------------------------------------------------
// simpleopenbuy.mq4
//
//--------------------------------------------------------------------
extern double lots = 0.1;
extern double TakeProfit = 20;
extern double Stoploss = 17;
extern double MaxOpenOrders = 3;


//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
// Special function start()

{ // Opening BUY
OrderSend(Symbol(),OP_BUY,lots,Ask,3,Bid-Stoploss*Point,Bid+TakeProfit*Point);
return; // Exit start()
}
//--------------------------------------------------------------------
Files:
 
Ghosthand:

Hi all,attached is an EA that will open X trades immediately when switch on, and after it TP or SL, it will keep on open new trades

Can anyone add some code for me, that i need "High price and Low Price", which if price above "High Price" or below "Low Price", it wont open trades.

In other words, I need it open trades only within that price range. Out of that high and low, no trade. Is that easy to add such code?

Am using it in Instaforex bi-Weekly contest. Pls kindly reply.

This is just the Buy EA, i will modify the Sell EA myself according to this Buy, thaanks again


Code:


//--------------------------------------------------------------------
// simpleopenbuy.mq4
//
//--------------------------------------------------------------------
extern double lots = 0.1;
extern double TakeProfit = 20;
extern double Stoploss = 17;
extern double MaxOpenOrders = 3;


//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
// Special function start()

{ // Opening BUY
OrderSend(Symbol(),OP_BUY,lots,Ask,3,Bid-Stoploss*Point,Bid+TakeProfit*Point);
return; // Exit start()
}
//--------------------------------------------------------------------
 
//--------------------------------------------------------------------
// simpleopenbuy.mq4 
// 
//--------------------------------------------------------------------
extern double lots = 0.1;
extern double TakeProfit = 20;
extern double Stoploss = 17;
extern double MaxOpenOrders = 3;

double High_Price, Low_Price;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start() 
// Special function start()

{
   High_Price = NormailizeDouble(iHigh(Symbol(),1440,1),Digits); //-- Set High Price
   Low_Price  = NormailizeDouble(iLow (Symbol(),1440,1),Digits); //-- Set Low Price
   if (Bid < High_Price && Bid > Low_Price)
   { // Opening BUY
      OrderSend(Symbol(),OP_BUY,lots,Ask,3,Bid-Stoploss*Point,Bid+TakeProfit*Point);
   }
return; // Exit start()
}
//--------------------------------------------------------------------

There you go, just modify the condition for setting the High_Price + Low_Price variables as you prefer. It is currently set to previous day Hi/Low.

FYI this ea will open a new order every tick if between the levels.

/ McKeen

 
McKeen:

There you go, just modify the condition for setting the High_Price + Low_Price variables as you prefer. It is currently set to previous day Hi/Low.

FYI this ea will open a new order every tick if between the levels.

/ McKeen


Many Thanks to McKeen . But it still not function between the price i enter, can u pls take a look?I am a zero in coding.... my final is like below

extern double lots = 1;
extern double TakeProfit = 13;
extern double Stoploss = 50;
extern double MaxOpenOrders = 10;

double High_Price = 1.5000;
double Low_Price = 1.4800;


//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
// Special function start()

{
High_Price = NormalizeDouble(iHigh(Symbol(),1440,1),Digits); //-- Set High Price
Low_Price = NormalizeDouble(iLow (Symbol(),1440,1),Digits); //-- Set Low Price


if (Bid < High_Price && Bid > Low_Price)


{ // Opening BUY
OrderSend(Symbol(),OP_SELL,lots,Bid,3,Ask+Stoploss*Point,Ask-TakeProfit*Point);
}
return; // Exit start()
}
//--------------------------------------------------------------------
 

I misunderstood you, I thought you wanted the ea to calculate the levels by itself without manual input all the time.

Below is new code, you can now change it from EA-properties, no need to change in code.

extern double lots = 1;
extern double TakeProfit = 13;
extern double Stoploss = 50;
extern double MaxOpenOrders = 10;
extern double High_Price = 1.5;
extern double Low_Price = 1.48;


int start() 
// Special function start()
{
   if (Bid < High_Price && Bid > Low_Price)
   {
      OrderSend(Symbol(),OP_SELL,lots,Bid,3,Ask+Stoploss*Point,Ask-TakeProfit*Point);
   }
return; // Exit start()
}
//--------------------------------------------------------------------
 
McKeen:

I misunderstood you, I thought you wanted the ea to calculate the levels by itself without manual input all the time.

Below is new code, you can now change it from EA-properties, no need to change in code.


Many thanks to u my fren. Is Done! Actually this script being use to assist manual trade :) Instaforex contest's having weird rules in bi-weekly Contest, maximum 10pips per trade. To lower the effort in monitoring this, gotta use this script to continue open trades after every 10pips....

Good Luck my man

 

Sorry, May I ask for someone to addon another line of code for me, on above script?

I need another variable : maximum X Trades per day. It means once this EA open X trades already on one day, it will definitely stop function. It that possible?

Thanks a lot for those who look into this...

 
Ghosthand:

Sorry, May I ask for someone to addon another line of code for me, on above script?

I need another variable : maximum X Trades per day. It means once this EA open X trades already on one day, it will definitely stop function. It that possible?

Thanks a lot for those who look into this...

i suggest to use MagicNumbers

not tested, i hope it does the job

if u think it's going to run more than a month than changh Day() with DayOfWeek() or DayOfYear()

extern double lots = 1;
extern double TakeProfit = 13;
extern double Stoploss = 50;
extern double MaxOpenOrders = 10;
extern double High_Price = 1.5;
extern double Low_Price = 1.48;
extern double MaxOpenOrdersPerDay = 10;
int  OpenOrders = 0, cnt = 0;

//----
int start() 
// Special function start()
{

   for(cnt = 0; cnt < OrdersTotal(); cnt++)   
     {
       OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
              //----
       if(OrderSymbol() == Symbol() && OrderMagicNumber() == Day())
                       OpenOrders++;
     }       

if (OpenOrders >= MaxOpenOrdersPerDay)
       return(0);

   if (Bid < High_Price && Bid > Low_Price)
   {
      OrderSend(Symbol(),OP_SELL,lots,Bid,3,Ask+Stoploss*Point,Ask-TakeProfit*Point,NULL,Day());
   }
return; // Exit start()
}
//--------------------------------------------------------------------
Reason: