What am I doing wrong?

 

Here's my EA... I'm trying to keep it simple... it tells me there's an error on line 3, the first "if" function... "semicolon expected"


int start()

if(Hour() == 15)
if(Minute() == 29)
OrderSend(Symbol(),OP_BUY,1.0,Ask,10,Ask-15*Point,Ask+30*Point,"BUYER",0,0,Green);

 
Try this:
int start()
{
if(Hour() == 15)
if(Minute() == 29)
OrderSend(Symbol(),OP_BUY,1.0,Ask,10,Ask-15*Point,Ask+30*Point,"BUYER",0,0,Green);
return(0);
}

 
Roger:
Try this:

thanks, that worked perfectly... but i have a new problem


when i use this ea on the strategy tester, it closes all the trades before any time goes by, and says next to each closed trade, "close at stop"


how to i make it continue through the following minutes to come using strategy tester?

 
deymer:

thanks, that worked perfectly... but i have a new problem


when i use this ea on the strategy tester, it closes all the trades before any time goes by, and says next to each closed trade, "close at stop"


how to i make it continue through the following minutes to come using strategy tester?

int start()
{

if(OrdersTotal()==0)
  {
   if(Hour() == 15)
    {
    if(Minute() == 29)
      {
       OrderSend(Symbol(),OP_BUY,1.0,Ask,1,Ask-15*Point,Ask+30*Point,"BUYER",0,0,Green);
      }
    }
  }

return(0);
}

Your EA is opening too many orders at the specified time. As a result, the price moves only a few pips and all orders are closed. Therefore, I added the OrdersTotal==0 conditional-if requirement.


I got it to run without the extra braces, but it was ignoring the time requirement, so I added the additional braces. The trades now open at the specified time.


Also, I reduced the trade size to one lot per trade.

 
FXtrader2008:

Your EA is opening too many orders at the specified time. As a result, the price moves only a few pips and all orders are closed. Therefore, I added the OrdersTotal==0 conditional-if requirement.


I got it to run without the extra braces, but it was ignoring the time requirement, so I added the additional braces. The trades now open at the specified time.


Also, I reduced the trade size to one lot per trade.







again, thank you, but i have one last question


i want to have multiple trades placed second by second, and i know how to add the "Seconds" parameter... i need to know how to add more trades to the list, with different stop loss and profit take levels.

 
deymer:

again, thank you, but i have one last question


i want to have multiple trades placed second by second, and i know how to add the "Seconds" parameter... i need to know how to add more trades to the list, with different stop loss and profit take levels.

Obviously you cannot open trades every second you will run out of money. You need to establish some limits to your buying spree.


You can open multiple trades upon any signal. In your case, the signal was Hour=15 and Minute=29. Unless you place a limit on the number of trades, it will open a new trade every tick until the Minute=30.


If you want to stop the number of open trades at say 10, change the OrdersTotal conditional-if statement to read:


If(OrdersTotal<=10)

 
FXtrader2008:

Obviously you cannot open trades every second you will run out of money. You need to establish some limits to your buying spree.


You can open multiple trades upon any signal. In your case, the signal was Hour=15 and Minute=29. Unless you place a limit on the number of trades, it will open a new trade every tick until the Minute=30.


If you want to stop the number of open trades at say 10, change the OrdersTotal conditional-if statement to read:


If(OrdersTotal<=10)




here's what i have so far...


#include <stdlib.mqh>
#include <WinUser32.mqh>

extern double Lots = 1.0;
extern double Hours = 15;
extern double Minutes = 29;



int start()
{


//begin--------------------------------------------------------------+
if(OrdersTotal() == 0)
{
if(Hour() == Hours)
{
if(Minute() == Minutes)
{
if(Seconds() == 0)

{
OrderSend(Symbol(),OP_BUY,Lots,Ask,1,Ask-15*Point,Ask+30*Point,"BUYER",0,0,Green);
}
}
}
}
//end----------------------------------------------------------------+
//begin--------------------------------------------------------------+
if(OrdersTotal() == 1)
{
if(Hour() == Hours)
{
if(Minute() == Minutes)
{
if(Seconds() == 2)

{
OrderSend(Symbol(),OP_BUY,Lots,Ask,1,Ask-15*Point,Ask+30*Point,"BUYER",0,0,Green);
}
}
}
}
//end----------------------------------------------------------------+
//begin--------------------------------------------------------------+
if(OrdersTotal() == 2)
{
if(Hour() == Hours)
{
if(Minute() == Minutes)
{
if(Seconds() == 5)

{
OrderSend(Symbol(),OP_BUY,Lots,Ask,1,Ask-15*Point,Ask+30*Point,"BUYER",0,0,Green);
}
}
}
}
//end----------------------------------------------------------------+
//begin--------------------------------------------------------------+
if(OrdersTotal() == 3)
{
if(Hour() == Hours)
{
if(Minute() == Minutes)
{
if(Seconds() == 8)

{
OrderSend(Symbol(),OP_BUY,Lots,Ask,1,Ask-15*Point,Ask+30*Point,"BUYER",0,0,Green);
}
}
}
}
//end----------------------------------------------------------------+
//begin--------------------------------------------------------------+
if(OrdersTotal() == 4)
{
if(Hour() == Hours)
{
if(Minute() == Minutes)
{
if(Seconds() == 11)

{
OrderSend(Symbol(),OP_BUY,Lots,Ask,1,Ask-15*Point,Ask+30*Point,"BUYER",0,0,Green);
}
}
}
}
//end----------------------------------------------------------------+
//begin--------------------------------------------------------------+
if(OrdersTotal() == 5)
{
if(Hour() == Hours)
{
if(Minute() == Minutes)
{
if(Seconds() == 14)

{
OrderSend(Symbol(),OP_BUY,Lots,Ask,1,Ask-15*Point,Ask+30*Point,"BUYER",0,0,Green);
}
}
}
}
//end----------------------------------------------------------------+
//begin--------------------------------------------------------------+
if(OrdersTotal() == 6)
{
if(Hour() == Hours)
{
if(Minute() == Minutes)
{
if(Seconds() == 17)

{
OrderSend(Symbol(),OP_BUY,Lots,Ask,1,Ask-15*Point,Ask+30*Point,"BUYER",0,0,Green);
}
}
}
}
//end----------------------------------------------------------------+
//begin--------------------------------------------------------------+
if(OrdersTotal() == 7)
{
if(Hour() == Hours)
{
if(Minute() == Minutes)
{
if(Seconds() == 20)

{
OrderSend(Symbol(),OP_BUY,Lots,Ask,1,Ask-15*Point,Ask+30*Point,"BUYER",0,0,Green);
}
}
}
}
//end----------------------------------------------------------------+

return(0);
}
//+------------------------------------------------------------------+





when i use the strategy tester with this expert, it works perfectly on gbp/jpy, but not on any of the other currency pairs... is it safe to assume it will still work even though the strategy tester suggests otherwise?

 
deymer:



... is it safe to assume it will still work .......


No. Never assume. That is why we have a Strategy Tester. Use it until it bleeds. Try all kinds of settings. Multiple currencies, and multiple years. The beauty of digital data is it never wears out.


Actually I'm a bit surprised that your EA launches trades when you added the conditional-if (Seconds()==2) statement because in order for that condition to be met, you have to have a tick occur when the time is showing two seconds. The flow of incoming ticks is very erratic varying from over 100 ticks per minute when trade is heavy to zero ticks in a couple minutes. The following graphs show the frequency of ticks.






As you can see, the arrival of incoming ticks at your trade station is very erratic.


I'm curious: what is magical about launching a trade a 15H 29M 0S, and 15H 29M 2S, and 15H 29M 4S, etc????? It would seem to me there are better criteria for launching trades.

 

I'm curious: what is magical about launching a trade a 15H 29M 0S, and 15H 29M 2S, and 15H 29M 4S, etc????? It would seem to me there are better criteria for launching trades.






there's really nothing magical about it, it's a play on a news report that is released at 15:30. I'm trying to place a series of trades in the previous minute(s). 40 trades in 2 minutes is what i'm trying to do.


this ticking issue can be a problem... is this just during strategy tester? or will the trades be executed at the designated time regardless if there is a tick or not

 
deymer:

40 trades in 2 minutes is what i'm trying to do.


this ticking issue can be a problem... is this just during strategy tester? or will the trades be executed at the designated time regardless if there is a tick or not

Ticking is definately an issue. But issues can be dealt with once you understand the issue.


Add a time keeping variable that remembers the time the last trade was launched. Then when the next tick arrives, compare the new time to the time of the last trade and if it exceeds 2 seconds, launch another trade.


eg


CurrentTime=Seconds()

{

your other launch criteria

if(CurrentTime-LastTradeTime>2)

{

launch trade

LastTradeTime=CurrentTime

}

}


Remember --- you can not launch a trade until you have a new quotes (tick) at your trade station. You cannot launch trades at fixed intervals.


Trading the news is tricky business. Trading is very heavy during news events and you will encounter trade server busy signals, or the server will be overloaded altogether.

 

Actually, there is perhaps another way to launch trades that just occurred to me.


You could run your EA in a continous "while" loop and use the internal clock on your computer to launch the trades, instead of waiting for an incoming tick to launch the Start() function.

Reason: