ea for a pending order to open at a set time

 

HI everyone!!!

I need some help in writing an ea as I have no knowledge in it at all.

I trade using pivot points as entry and exit levels. I set the trades by using pending orders (sell stop and buy stop). The problem is that I enter the trades at 07:00 gmt and since I have to work I can't always set the trade at that time so I would like an ea that opens the pending orders starting from 07:00gmt and expiring at 18:00gmt with customizable take profit and stop loss levels.

Could someone please help me?? Thankyou!!!!!!

 
you got a message
 
up
 
maxima88x:
up

It's been 33 minutes since you posted your first message! Please wait patiently for a day or two before bumping...

 
so you want let others do the job and code the ea for you for free?
 
Here's some simple code that's untested. Tell me if there's bugs and I might try to fix it. I suggest reading the MQL4 docs and/or maybe a basic programming online tutorial. Honestly, in this day and age, simple programming should be a universal skill (and in many fields it is!).

On to the code. There's no error checking. No hidden stop loss/take profit. Both you should be able to implement within a few days of learning. Writing those should be a good exercise to learn how to program. Like I said before, this was done without any testing so there's more than likely something wrong with it. If anyone catches anything, I'd be happy to help fix it.

By the way, BuyStopPrice and SellStopPrice are calculated based on Bid prices, so that's why the spread correction is there in the OrderSend. Default Lots is 0.1, or (maybe) calculated so that a stop out would cause you to lose EquityRiskPercentage% of your then current equity.

int start()
{
   
   datetime time = iTime(NULL,PERIOD_H1,0);
   if (TimeHour(time)==18+GMTOffset) //all pendings should be filled or expired by now...
   {                       //let's clear the holding flags
      OpenSell = -1;
      OpenBuy = -1;
   }
   if (OpenSell == -1 && TimeHour(time)==7+GMTOffset)
   {
      if (BuyStopPoints!=0 && BuyStopPrice!=0)
      { 
         Alert("You have specified both a pending price and a pending distance.");
         Alert("Please check the instructions again and reinitialize the EA.");
         OpenSell = 5; //will prevent this block from executing again until the next day
         return(0);
      }
      if (BuyStopPoints==0 && BuyStopPrice==0)
      { 
         Alert("You have specified neither a pending price nor a pending distance.");
         Alert("Please check the instructions again and reinitialize the EA.");
         OpenSell = 5; //will prevent this block from executing again until the next day
         return(0);
      }
      //no open pendings and it's time!
      //calculate buy stop and sell stop
      if (BuyStopPoints!=0)
      {
         BuyStopPrice = Bid+BuyStopPoints*Point;
      }
      if (SellStopPoints!=0)
      {
         SellStopPrice = Ask+SellStopPoints*Point;
      }
      
      //calculate lots
      double spread = Ask-Bid;
      if (AutoLot && EquityRiskPercentage < 1 && EquityRiskPercentage > 0)
      {
         Lots = (AccountEquity()*EquityRiskPercentage)/StopLossPoints;
      }
      OpenBuy = OrderSend(Symbol(),OP_BUYSTOP,Lots,BuyStopPrice+spread,3,BuyStopPrice-StopLossPoints*Point+spread
                                    ,BuyStopPrice+TakeProfitPoints*Point+spread,"woohoo",8675309,
                                    time+3600*11,Green);
      OpenSell = OrderSend(Symbol(),OP_SELLSTOP,Lots,SellStopPrice,3,SellStopPrice+StopLossPoints*Point-spread,
                                    SellStopPrice-TakeProfitPoints*Point-spread,"woohooooo",8675309,
                                    time+3600*11,Green);                       
   }
   return(0);
}

(I wouldn't use this code without modifications or, even better, an expert's overhaul.)

EDIT: Fixed a quick dumb mistake. I think Maximablahblah_1 is the updated file..?

Files:
 
maxima88x:

HI everyone!!!

I need some help in writing an ea as I have no knowledge in it at all.

I trade using pivot points as entry and exit levels. I set the trades by using pending orders (sell stop and buy stop). The problem is that I enter the trades at 07:00 gmt and since I have to work I can't always set the trade at that time so I would like an ea that opens the pending orders starting from 07:00gmt and expiring at 18:00gmt with customizable take profit and stop loss levels.

Could someone please help me?? Thankyou!!!!!!

have a look here:

http://sites.google.com/site/dmweadev/home/pending-time-ea

Pending Time EA


pending Time v1.2
property copyright "Copyright DMW EA Development"

With the EA you will be a able to set a time and date that 2 or more pending orders will be placed, buy
and sell.
It is very useful when trading news events because you can program your date / time that you want your
pending orders placed.

If the market moves up / down one of the pending orders will be triggered and a trade will be placed.

Settings
--------

The following can be configured in the EA:
1. next date and time to place pending orders.

2. profit, stop-loss and step.If using a 4 digit broker 10 will equall 10 pips, if using a 5 digit broker

, add a 0 (zero), so 10 pips will equall 100, etc.

step is the number of pips above and below the current price that the pending orders will be placed.

3. lot size and expiry time.
expiry time in in seconds, the default is 900 seconds which equalls 15 minutes, check or try with your
broker if less than 15 minutes can be used, if pending trades are not placed the expiry time might be
too low.

4. your own comment displayed on the chart.

5. number of pending orders to place.Use this in mutip[les of 2, IE 2 or 4 or 6, etc ...
example: if the setting is 2 it will place 1 buy and 1 sell pending order, if the setting is 4 it will

place 2 buy and 2 sell pending orders, etc ...

6. If during the minute that the EA is active and the market goes crazy up and down and the pending orders

are triggered and then closed the EA will automatically open new pending orders according to the number

of pending orders set - see point 5.
 
thanks everyone your help has been appreciated!!! : )
 
maxima88x:
thanks everyone your help has been appreciated!!! : )

but why no people come and let this topic continue?
Reason: