Help: I will be glad to see this in .mq4 codes with your kind assistance!

 
Name: Glory-Pips Breakouts TM
Author: Opengates
Link: www.forexgates.blogspot.com, Email: opengate8170@yahoo.com


Hello, I am new to mql4 codes programming, i have tried this several times
but couldn't get it right at all.
Please, can somebody help me generate mql4 codes for my trading system to
become an automated trading EA?
The idea behind the trading system is this:

- The system will open 3 pairs of buy-stop and sell-stop pending orders at

exactly 9:00 am GMT (London Time)

- Buy-stop order's open price will be 20pips above the highest price from the

hour of 00:00 am - 8:00 am GMT (London Time).

- Sell-stop order's open price will be 20pips below the lowest price from the

hour of 00:00 am - 8:00 am GMT (London Time).

- Stop loss is 23pips (-/+ spread) for all orders.

- Take profit for the first pair of order is 23pips (-/+ spread)

" " " " second " " " " 53pips ( -/+ spread )
" " " " third " " " " 103pips( -/+ spread )

- Trailing stop is 25pips for both second and third pair of orders only.

- All pending orders to expire at exactly 12:50pm GMT (London Time).

- Lot for the first order is 1.0 (Mini Acct.)

" " " second and third orders is 0.20 (Mini Acct.)
Note: Lots can be adjusted according to the account size, type and broker.

- Leverage is 100:1 (Can be adjusted)

- Can work for gbpusd, gbpjpy, gbpchf, eurgbp or eurjpy on hourly chart.

- This process to be carried out every Monday to Friday continuously.


Thanks- Opengates.
 
Opengates:
i have tried this several times but couldn't get it right at all.

Please post the code you have created and we'll take a look.


CB

 
cloudbreaker:

Please post the code you have created and we'll take a look.


CB

thanks, please how do i post it to you?

Opengates

 
Opengates:

thank you Cloudbreaker, here is it!

Opengates

//+------------------------------------------------------------------+
//| Glory Pips Breakouts TM.mq4.mq4
//| Copyright © 2009, Olufemi O. Adeyemo    "Opengates Success Int'l."
//| www.forexgates.blogspot.com;       opengate8170@yahoo.com
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, Olufemi O. Adeyemo, Opengates Success Int'l."
#property link      "www.forexgates.blogspot.com;       opengate8170@yahoo.com"

Hello, I am new to mql4 codes programming, i have tried this several times
but i couldn't get it right at all.
Please, can somebody help me generate mql4 codes for my trading system to 
become an automated trading EA?
The idea behind the trading system is this:
- The system will open 3 pairs of buy-stop and sell-stop pending orders at 
  excatly 9:00 am GMT (London Time)
- Buy-stop order's open price will be 20pips above the high price from the 
  hour of 00:00 am - 8:00 am GMT (London Time). 
- Sell-stop order's open price will be 20pips below the low price from the 
  hour of 00:00 am - 8:00 am GMT (London Time).
- Stop loss is 23pips (-/+ spread) for all orders.
- Take profit for the first pair of orders is 23pips (-/+ spread)
   "     "     "   "  second "   "    "    " 53pips (  "       )
   "     "     "   "  third  "   "    "    " 103pips(  "       )
- Trailing stop is 25pips for both second and third pair of orders only.
- All pending orders to expire at exactly 12:50pm GMT(London Time).
- Lots for the first order is 1.0(Mini Acct.)
   "   "   " second and third orders is 0.20 (Mini Acct)respectively
  Lots can be adjusted according to the account size, type and broker.
- Leverage is 100:1 (Can be adjusted)
- Can work for Gbpusd, gbpjpy, gbpchf, eurgbp or eurjpy.
- Hourly chart.
- This process to be carried out every Monday to Friday continously.

***PLEASE FEEL FREE TO DELETE THE WHOLE CODES IF IT MAKES NO SENSE AND 
PUT THE RIGHT CODES. THANKS!



//---- input parameters
extern int       OpenTime=00.00;
extern int       CloseTime=8.00;
extern int       TakeProfit=23; 53; 103;
extern int       StopLoss=23;
extern double    Lots=1.0; 0.20;
extern int       TrailingStop=25;
extern double    MagicNumber=20091121;
extern double    Expiration=12.50;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
int order_type;
  if(OrderSelect(12, SELECT_BY_POS)==true)
    {
     order_type=OrderType();
     // OP_BUYSTOP & OP_SELLSTOP;
    }
  else
    Print("OrderSelect() returned error - ",GetLastError())
int OrderSend(symbol,OP_BUYSTOP,lots,High+20*point,0,sl,tp,NULL,20091121,12.50,CLR_NONE) 
       {
        Print("OrderSend failed with error #",GetLastError());
        return(0);
        
         if(sell==0 && (high-Ask)>orderlimit*Point)
      {day=DayOfWeek();sell=3;
      op=high+20*point;  sl=low; tp=high+20*Point;
      err=OrderSend(Symbol(),OP_BUYSTOP,lots,High+20*point,0,sl,tp,NULL,20091121,12.50,CLR_NONE);
      
      }
      if(OrderSelect(12, SELECT_BY_POS)==true)
    order=OrderTicket();
  else
    Print("OrderSelect failed error code is",GetLastError());
      
      else
    Print("OrderSelect() returned error - ",GetLastError())
int OrderSend(symbol,OP_SELLSTOP,lots,Low-20*point,0,sl,tp,NULL,20091121,12.50,CLR_NONE) 
      
      if(buy==0 && (Bid-low)>orderlimit*Point)
      {day=DayOfWeek();buy=3;
      op=low-20*point;  sl=low;  tp=low-50*Point;
      err=OrderSend(Symbol(),OP_SELLSTOP,Lots,Low-20*point,0,sl,tp,NULL,20091121,12.50,CLR_NONE);
      
      }
   }
return(0);
}
       }
    }
     if(OrderSelect(12, SELECT_BY_TICKET)==true)
    {
     Print("order #12 open price is ", OrderOpenPrice());
     Print("order #12 close price is ", OrderClosePrice());
    }
  else
    Print("OrderSelect returned the error of ",GetLastError());

//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
 

First step:

You need to look at the documentation and understand how EAs work with regard to incoming ticks - specifically the usage of the init() and start() functions.


Second step:

Take one of the sample EAs and annotate each line of code with exactly what it is doing - by referring to the documentation.


By the way:

Can't see anywhere in your code where you've made any attempt to open trading at 0900.

That's just the first of many observations (averaging more than one per line of code), which, until you start to get your head around things a bit more, are not worth stating.


CB

 

Thanks CB,

For finding time to attend to me. I am trying my hands on another codes, It belongs to someone else and i am modifying it because it is similar in operations to my trading system. Can you please modify it for me to do a complete work as defined by my trading system?

Thanks once again. I will be expecting, God bless.

Email: opengate8170@yahoo.com

Opengates

extern int starttime = 00; 
extern int stoptime  = 08; 
extern int maxpoint  = 0; 

extern int TP=53;

extern int mn=1;

extern double Lots=0.1;

extern int orderlimit=12.50;

int start()
  {
   OpenPattern();
   return(0);
  }

int day,buy,sell,stop;  
int OpenPattern()
{double op,sl,tp;int err;


   //Åñëè íîâûé äåíü òî óäàëÿåì îðäåðà.
   if(day!=DayOfWeek()){_DeleteOrder(1);_DeleteOrder(0);}
   
   double high= GetHighLow_Time(starttime,stoptime,0);
   double low = GetHighLow_Time(starttime,stoptime,1);
   
   if(OrdersTotal()<1){buy=0;sell=0;stop=0;}
   
   if(MathAbs(high-low)<maxpoint*Point*mn && StrToInteger(TimeToStr(Time[1],TIME_MINUTES))>=stoptime && stop==0)
   {stop=1;
      if(sell==0 && (high-Ask)>orderlimit*Point*mn)
      {day=DayOfWeek();sell=1;
      op=high+20*point;  sl=high;tp=high+TP*Point*mn;
      err=OrderSend(Symbol(),OP_BUYSTOP,Lots,NormalizeDouble(op,Digits),3,sl,tp,"FORTRADER.RU",0,0,Red);
      if(err<0){Print("FT_TIME_BIGDOG()-  Îøèáêà óñòàíîâêè îòëîæåííûõ îðäåðîâ OP_SELLLIMIT.  op "+op+" sl "+sl+" tp "+tp+" "+GetLastError());return(-1);}
      }
      
      if(buy==0 && (Bid-low)>orderlimit*Point*mn)
      {day=DayOfWeek();buy=1;
      op=low-20*point;  sl=low;  tp=low-TP*Point*mn;
      err=OrderSend(Symbol(),OP_SELLSTOP,Lots,NormalizeDouble(op,Digits),3,sl,tp,"FORTRADER.RU",0,0,Red);
      if(err<0){Print("FT_TIME_BIGDOG()-  Îøèáêà óñòàíîâêè îòëîæåííûõ îðäåðîâ OP_BUYLIMIT.  op "+op+" sl "+sl+" tp "+tp+" "+GetLastError());return(-1);}
      }
   }
return(0);
}

//óäàëÿåò îòëîæåííûå ñòîï îðäåðà
int _DeleteOrder(int type)
{
   for( int i=1; i<=OrdersTotal(); i++)          
   {
    if(OrderSelect(i-1,SELECT_BY_POS)==true) 
    {                                       
     if(OrderType()==OP_SELLSTOP && OrderSymbol()==Symbol() && type==0)
     {
      OrderDelete(OrderTicket()); 
     }//if
  
    if(OrderType()==OP_BUYSTOP && OrderSymbol()==Symbol() && type==1)
     {
      OrderDelete(OrderTicket()); 
     }//if
    }//if
   }
   return(0);
}  

double GetHighLow_Time(int starttime,int stoptime, int type)
{double ret;int i;

if(type==0)
{
   if(StrToInteger(TimeToStr(Time[1],TIME_MINUTES))>=stoptime)
   {
      for( i=0;i<200;i++)
      {
         if(StrToInteger(TimeToStr(iTime(Symbol(),Period(),i),TIME_MINUTES))<=stoptime)
         {
            if(High[i]>ret)
            {ret=High[i];}
            if(StrToInteger(TimeToStr(iTime(Symbol(),Period(),i),TIME_MINUTES))<=starttime)
            {return(ret);}
         }
      }    
   }
}

if(type==1)
{
   if(StrToInteger(TimeToStr(Time[1],TIME_MINUTES))>=stoptime)
   {
      for( i=0;i<200;i++)
      {
         if(StrToInteger(TimeToStr(iTime(Symbol(),Period(),i),TIME_MINUTES))<=stoptime)
         {
            if(Low[i]<ret || ret==0){ret=Low[i];}
            if(StrToInteger(TimeToStr(iTime(Symbol(),Period(),i),TIME_MINUTES))<=starttime){return(ret);}
         }
      }    
   }
}

return(ret);
}
 

Cloud Breaker,

There is one more thing i will like to know about the EAs, do they work if the computer is not turned on at all?

Thanks,

Opengates.

 
Opengates:

There is one more thing i will like to know about the EAs, do they work if the computer is not turned on at all?

 
Opengates:

Cloud Breaker,

There is one more thing i will like to know about the EAs, do they work if the computer is not turned on at all?

Thanks,

Opengates.

The EA runs on your own computer, so turning it on will help enormously.

When the EA places orders successfully, those orders are stored in your broker/bank computer system until you or your EA closes/deletes them.

So it really depends upon your trading strategy whether or not your computer needs to remain turned on for long periods.

For example:

- If your strategy is to analyse candles all day and/or manage its own stop loss (to stop your broker hunting you) then the computer needs to be on and the EA running

- If your strategy just makes a decision once a day based on daily movement and you're happy to trust your broker to action your stops, then you can turn your computer off, as long as you ensure that on restart, your EA has access to any data it needs to recover its context.


I'm going to make a point of not writing your code for you. This is a programming forum, not an EA market.

You've got a strategy, which is 1 strategy more than a lot of folks on here who want EAs written.

So. Read the docs, starting with the basics. Annotate the sample EAs so you know how they work. Then start writing your OWN code.

Once you do that, you will find that I, and others, will suddenly be a lot more forthcoming with our respect and help.


CB