[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 388

 
KostelloArtua:
2011.05.16 09:06:08 Expert Moving Average New-Svecha EURUSD,M30: loaded successfully
2011.05.16 09:04:21 Expert Moving Average New-Svecha EURUSD,M30: loaded successfully
2011.05.16 08:14:25 '81415': DataCenter connecting failed [6]


If you run the terminal and then the EA, nothing else appears in the log and the EA shows the work...


If ticks are running, the icon of EA is "smiling", EA should make deals (i.e. conditions for it appear), but it does not make them, then it is necessary to debug.

Arrange the price() command in the code of the EA, especially in those places where it is compared and see what exactly is being compared. Maybe, the comparison result is always false, while you're assuming that the variables are equal.

 

Good afternoon everyone.

I've been studying MQL4 for about a month. I wrote a simple Expert Advisor that buys or sells on MACD bar changes (I can send the code in the evening if I need it). It compiles without problems and my demo account has a smiley face on top right corner(I enabled my EA to trade in preferences). The Strategy Tester shows results for the strategy (though negative, but this is a step towards further refinement). But on a demo account in MT4 the Expert Advisor does not open trades at all. It seems to me that the problem is not with the program (otherwise why would the tester show results?), but somewhere in some settings.

Can you tell me what it may be?

 
Sersad:.

Can you tell me what might be wrong?


How much money do you have in your account and what lot do you enter?
 
Roger:

How much money do you have in your account and what lot do you enter?

On a 10,000 USD demo account, I enter with 0.1 lot (mini lot).

If you mean money management, I don't think that's the case...

 
Sersad:

Good afternoon everyone.

I've been studying MQL4 for about a month. I wrote a simple Expert Advisor that buys or sells on MACD bars change (I can send the code in the evening if I need it). It compiles without problems and my demo account has a smiley face on top right corner (I enabled my EA to trade in preferences). The Strategy Tester shows results for the strategy (although negative, but this is a step towards further refinement). But on a demo account in MT4 the Expert Advisor does not open trades at all. It seems to me that the problem is not with the program (otherwise why would the tester show results?), but somewhere in some settings.

Can you advise what may be the problem?


Without the code it's hard to say. It is possible that the EA is written for four-digit, and the demo account is written for five-digit. You see, if we set, for example, a 10 point stop loss for the order, it is the same distance to the five-digit EA as 1 pip on the four-digit one. If we set the minimum allowed distance for setting stop orders at, say, 3 points, then on a five-digit market this would be thirty points instead of three. The server will quite understandably reject the command to set an order with a stop of 10 points at the five digits.

But the reason might be different. You see, you have asked people why their car would not start. People cannot tell you the reason without opening the bonnet and listening to the car's reaction to attempts to start...

 


I'm sorry, I've written some nonsense here, if you could show me where I'm completely clueless.

Poses do not seem to open at all, nothing happens.

I removed the division by zero - still, and no error is written in the log.

//+------------------------------------------------------------------+
//| for avalanche.mq4 |
//| Copyright © 2011, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
extern double stoploss=0; extern double takeprofit=20; extern int otstup=20; extern datetime expiration=0;

//+------------------------------------------------------------------+
//| expert initialisation function |
//+------------------------------------------------------------------+
int init()
{
//----

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

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int tiket,tikett;double volume=0.1;int i=0,R1=0,R2=0,A=1 ;double price=PRICE_OPEN;
// R1=((PRICE_OPEN- stoploss*Point)*stoploss)/stoploss;R2=((PRICE_OPEN+ stoploss*Point)*stoploss)/stoploss;


int start()
{
//----

OrderSelect()tiket,SELECT_BY_TICKET, MODE_TRADES );
if(OrderSymbol()==Symbol()){
if(OrderMagicNumber( )==1000||OrderMagicNumber( )==2000 ){i=OrdersTotal() ;
if (i<2){
tiket= OrderSend( Symbol(), OP_BUYSTOP, volume*A, price+otstup*Point, Point*3, R1, PRICE_OPEN+takeprofit*Point+otstup, "OP_BUYSTOP", 1000, expiration, Red);
Alert ("OP_BUYSTOP", GetLastError( );
tikett= OrderSend( Symbol(), OP_SELLSTOP, volume*A, price -otstup*Point, Point* 3,R2, PRICE_OPEN-takeprofit*Point-otstup, "OP_SELLSTOP", 2000, expiration,C'0,128,255' );
Alert ("OP_SELLSTOP", GetLastError( );
i=OrdersTotal() ; } } }

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

I.e., two pending orders are opened, one above the price at a distance otstup=20, the other below, no stop, and before opening check if there are no orders of this EA and not more than two.

 
alexr7:
Thank you very much for the quick response!!!!!!!!!!!!!! The criterion is a standard Bollinger Bands indicator with parameters: period 20, shift 0, deviation 2, Weighted Close(HLCC/4)!!!!!!!

These are not the criteria I asked you about. These are bollinger parameters. They may be different and they are set in the settings...

I asked you - how do you determine if the position is on the bollinger midline?

 
alexr7:
Thank you very much for the quick response!!!!!!!!!!!!!! The criterion is a standard Bollinger Bands indicator with parameters: period 20, shift 0, deviation 2, Weighted Close(HLCC/4)!!!!!!!

The Bollinger average line is iMA(NULL, 0, 20, 0, MODE_SMA, PRICE_WEIGHTED, 1);
 
Dimka-novitsek:


I'm sorry, I've written some nonsense here, if you could show me where I'm completely sheepish.

The poses don't seem to open at all, nothing happens.

I removed the division by zero - still, and no error is not written in the log.

//+------------------------------------------------------------------+
//| for avalanche.mq4 |
//| Copyright © 2011, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
extern double stoploss=0; extern double takeprofit=20; extern int otstup=20; extern datetime expiration=0;

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----

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

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int tiket,tikett;double volume=0.1;int i=0,R1=0,R2=0,A=1 ;double price=PRICE_OPEN;
// R1=((PRICE_OPEN- stoploss*Point)*stoploss)/stoploss;R2=((PRICE_OPEN+ stoploss*Point)*stoploss)/stoploss;


int start()
{
//----

OrderSelect( tiket,SELECT_BY_TICKET, MODE_TRADES );
if(OrderSymbol()==Symbol()){
if (OrderMagicNumber( )==1000||OrderMagicNumber( )==2000 ){i=OrdersTotal() ;
if (i<2){
tiket= OrderSend(), OP_BUYSTOP, volume*A, price+otstup*Point, Point* 3, R1, PRICE_OPEN+takeprofit*Point+otstup, "OP_BUYSTOP", 1000, expiration, Red);
Alert ("OP_BUYSTOP", GetLastError( );
tikett= OrderSend( Symbol(), OP_SELLSTOP, volume*A, price -otstup*Point, Point* 3,R2, PRICE_OPEN-takeprofit*Point-otstup, "OP_SELLSTOP", 2000, expiration,C'0,128,255' );
Alert ("OP_SELLSTOP", GetLastError( ));
i=OrdersTotal( ) ; } } }

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

Ie, open like two pending orders, one above the price at a distance otstup=20, the other below, no stop, and before opening check if the order of this EA and not more than two.

1) use SRC

2) Your first command is OrderSelect. Who are you going to select before setting orders?

 

When the EA starts nothing, it is just to check, so that new riders do not open at every tick afterwards

1) use SRC A, it is a root thank you!

I.e. if there are no orders at all, or less than 2, they open immediately!

Reason: