Forex
Google

Go Back   Forex Trading > Downloads > Expert Advisors - Metatrader 4
Forex Forum Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack (1) Thread Tools Display Modes
  #31 (permalink)  
Old 04-09-2008, 03:23 PM
mauro269 mauro269 is offline
Member
 
Join Date: Mar 2008
Posts: 44
mauro269 is on a distinguished road
I didn't understand.

This EA seems that starts and finishes to work for the time that you choice in the settings. Now, is it able to open a sell and buy order in the same time on the same pair with prefixed TP and SL?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #32 (permalink)  
Old 04-11-2008, 03:40 AM
Flying Fish Flying Fish is offline
Junior Member
 
Join Date: Sep 2007
Posts: 3
Flying Fish is on a distinguished road
Quote:
Originally Posted by matrixebiz View Post
What is this actually doing? I don't understand what this code is doing.
Thanks you
I thought you were asking for some programming help, I missed the part were you wanted someone to code it for you. Please disregard my post.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #33 (permalink)  
Old 04-13-2008, 05:40 PM
matrixebiz's Avatar
matrixebiz matrixebiz is offline
Senior Member
 
Join Date: Oct 2006
Posts: 1,042
matrixebiz is on a distinguished road
Add code to existing code

Hello, I have this TimeBased EA that opens trade at a specific time;
Code:
//+------------------------------------------------------------------+
//|                                                  TimeBasedEA.mq4 |
//|                      Copyright © 2008, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
//changed by:       "forex4capital@yahoo.ca"

// Time frame: M5 and higher

extern int     MagicNumber = 20080122;
extern int     OpenHour     = 8;        
extern int     OpenMinute   = 55;      
extern double  TakeProfit  = 10;
extern double  StopLoss    = 10;
extern double  Lots        = 0.1;
extern bool    OpenBuy     = true;
extern bool    OpenSell    = false;
extern int     NumBuys     = 1;
extern int     NumSells    = 1;
extern int     Slippage    = 3;

//+------------------------------------------------------------------+
//|                        S T A R T                                 |
//+------------------------------------------------------------------+
int start()
  {
   int cnt, ticket, total;
   //int ct;
//-------------------------------------+
   if(Bars<100)
     {
      Print("bars less than 100");
      return(0);  
     }
//-------------------------------------+
   if(TakeProfit<10)
     {
      Print("TakeProfit less than 10");
      return(0);  // check TakeProfit
     }
//-------------------------------------+
   //ct = Hour() * 100 + Minute();
   total=OrdersTotal();
   if(total<1) 
     {
      // no opened orders identified
      if(AccountFreeMargin()<(1*Lots))
        {
         Print("We have no money. Free Margin = ", AccountFreeMargin());
         return(0);  
        }
      // check for long position (BUY) possibility
      if (Hour()==OpenHour && Minute()>=OpenMinute && OpenBuy)
      //if(ct == StartHour && Close[1]>Open[1] && OpenBuy)
      //if(ct == StartHour && High[1]<Open[0] && OpenBuy)
        {
         for ( cnt = 0; cnt < NumBuys; cnt++)
         {
           ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Bid-StopLoss*Point,Ask+TakeProfit*Point,"",MagicNumber,0,Blue);
           if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
           }
           else Print("Error opening BUY order : ",GetLastError()); 
         }
         return(0); 
        }
      // check for short position (SELL) possibility
      if (Hour()==OpenHour && Minute()>=OpenMinute && OpenSell)
      //if(ct == StartHour && Close[1]<Open[1] && OpenSell)
      //if(ct == StartHour && Low[1]>Open[0] && OpenSell)
        {
         for ( cnt = 0; cnt < NumSells; cnt++)
         {
           ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,Ask+StopLoss*Point,Bid-TakeProfit*Point,"",MagicNumber,0,Red);
           if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
           }
           else Print("Error opening SELL order : ",GetLastError());
         } 
         return(0); 
        }
     }
   return(0);
  }
// the end
How do I add in Close code to Close the trade at another specific time?
Code:
//---- Close input parameters
extern int   CloseHour     = 7;      // Время закрытия, часы
extern int   CloseMinute   = 0;      // Время закрытия, минуты
bool  UseCurrSymbol = True;  // Использовать только один инструмент
extern color clCloseBuy    = Blue;   // Цвет закрытия покупки
extern color clCloseSell   = Red;    // Цвет закрытия продажи.....

.............

  if (Hour()==CloseHour && Minute()>=CloseMinute) {
    for (int i=OrdersTotal()-1; i>=0; i--) {
      if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
        if (!UseCurrSymbol || OrderSymbol()==Symbol()) {
          if (OrderType()==OP_BUY) {
            pBid=MarketInfo(OrderSymbol(), MODE_BID);
            OrderClose(OrderTicket(), OrderLots(), pBid, Slippage, clCloseBuy);
          }
          if (OrderType()==OP_SELL) {
            pAsk=MarketInfo(OrderSymbol(), MODE_ASK);
            OrderClose(OrderTicket(), OrderLots(), pAsk, Slippage, clCloseSell);
          }
        }
      }
    }
  }
}
Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #34 (permalink)  
Old 04-13-2008, 05:48 PM
newdigital newdigital is offline
Administrator
 
Join Date: Sep 2005
Posts: 15,422
newdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud of
Explanation about EA (with the same name and functions so may be it is the same EA) is on the first page of this thread.

And the other EAs are on this thread (as th links) Buy/sell EA
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #35 (permalink)  
Old 04-13-2008, 05:59 PM
matrixebiz's Avatar
matrixebiz matrixebiz is offline
Senior Member
 
Join Date: Oct 2006
Posts: 1,042
matrixebiz is on a distinguished road
Quote:
Originally Posted by Flying Fish View Post
I thought you were asking for some programming help, I missed the part were you wanted someone to code it for you. Please disregard my post.
No, I just want to know what the code means or is telling me so I can understand what it is doing. You don't have to write another EA, just explain or clarify what the code is it's meanings, got it? because I was trying to add "if (Hour()==CloseHour && Minute()>=CloseMinute)" but was getting errors/warnings ('CloseHour' - expression on global scope not allowed)

Last edited by matrixebiz : 04-13-2008 at 06:05 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #36 (permalink)  
Old 04-14-2008, 02:03 PM
waltini waltini is offline
Senior Member
 
Join Date: May 2006
Posts: 131
waltini is on a distinguished road
Matrixebiz

Hope this works
Attached Files
File Type: mq4 Matrix.mq4 (4.3 KB, 62 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #37 (permalink)  
Old 04-15-2008, 10:54 PM
matrixebiz's Avatar
matrixebiz matrixebiz is offline
Senior Member
 
Join Date: Oct 2006
Posts: 1,042
matrixebiz is on a distinguished road
Quote:
Originally Posted by waltini View Post
Hope this works
No it didn't close the trade it kept opening and closing the trade in a loop and didn't allow different currencies to open, and doesn't work with USD/CHF

Last edited by matrixebiz : 04-15-2008 at 10:59 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #38 (permalink)  
Old 04-16-2008, 09:57 PM
waltini waltini is offline
Senior Member
 
Join Date: May 2006
Posts: 131
waltini is on a distinguished road
Works fine for me

Hi Matrixebiz,

I have tested it again on a mini ibfx platform and it works fine for me.

Please post your set file and I will try it with your settings.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #39 (permalink)  
Old 04-17-2008, 12:09 AM
waltini waltini is offline
Senior Member
 
Join Date: May 2006
Posts: 131
waltini is on a distinguished road
http://www.forex-tsd.com/attachment....d=12083906 40


I am trying my first picture
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #40 (permalink)  
Old 05-21-2008, 05:44 PM
Jeeves's Avatar
Jeeves Jeeves is offline
Junior Member
 
Join Date: May 2008
Posts: 5
Jeeves is on a distinguished road
Straddle Ea (Help needed)

Hello there.
I have traded a demonstration account for a year and would like my system made into an EA. I do not know how to do it. But it is a very easy system.
I place a straddle trade using the high and the low of the 12:00pm 1 hour candle. Broker time.
Tp 15
SL 15
No more.
I would like to change the TP & SL if I want. Also the bar time.
If you can help I would be very happy.
Thank you
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

LinkBacks (?)
LinkBack to this Thread: http://www.forex-tsd.com/expert-advisors-metatrader-4/8067-help-how-write-simple-ea-buy-sell-specific-time.html
Posted By For Type Date
ШЇШ±Ш®Щ€Ш§ШіШЄ Indicator Щ€ expert - ШµЩЃШ­Щ‡ 84 - Sarmaye Forums This thread Refback 03-23-2008 11:36 AM

Similar Threads
Thread Thread Starter Forum Replies Last Post
Detecting price trend independent of a specific time frame gee Metatrader 4 4 02-24-2007 04:53 PM
Anyone want to write a simple EA? Kaper Suggestions for Trading Systems 6 10-29-2006 10:36 PM
A Simple Buy/Sell Script excite2 Expert Advisors - Metatrader 4 8 07-18-2006 03:16 AM
Simple question of determining the time of day Fishtank Metatrader 4 2 04-04-2006 04:12 AM


All times are GMT. The time now is 01:57 AM.