Thread: How to code?
View Single Post
  #49 (permalink)  
Old 04-09-2006, 11:03 AM
eric79 eric79 is offline
Senior Member
 
Join Date: Dec 2005
Posts: 217
eric79 is on a distinguished road
Need help with very simple EA

Hi
I am trying to code a very simple EA to test a strategy.
All it should do is open an order at a given time.
Take Profit, Stop Loss and position size are external variables.

I can't program but i tried to do it.
This is what i have but it doesn't open any trades in backtest.

Could anybody help me?
Thanks a lot.

Code:
//+------------------------------------------------------------------+
//|                                                           TH.mq4 |
//|                      Copyright © 2006, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

//---- input parameters
extern int       StartHour=0;
extern int       StartMinute=00;
extern int       TakeProfit=10;
extern int       StopLoss=20;
extern int       Lots=1;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
   if (Hour()==StartHour && Minute() == StartMinute)
   {
   OrderSend(Symbol(),OP_BUY,Lots,Ask,3,StopLoss,Ask+TakeProfit*Point,"TH_Buy",16384,0,Green);
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+
Reply With Quote