[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 389

 
Dimka-novitsek:
When the EA starts nothing, it is just to check if new orders will not open with every tick
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();
      }
   }
}

This is your code, i did not make any changes

You wrote that the order will be placed if you select the order of the tiket order and the magic symbol, and the total number of orders is less than 2.

 
Thank you!!! I'm sorry, and I definitely wrote nonsense.
 
drknn:


Without the code it is hard to say. It is quite possible that the EA is written for four digits, but the demo account is five-digit. You understand that if we set, for example, a stop loss of 10 pips in the five-digit EA, it is the same distance as 1 pip in the four-digit EA. 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 won't be able to tell you the reason without opening the bonnet and listening to how the car reacts to attempts to start...

I have tried to run a strategy tester by EURUSD and to execute it by several currencies, EURUSD, GBPUSD, USDJPY, but it didn't work. I used Point when sending Buy/Sell orders, so it should work for all symbols. What I don't understand the most is why the tester shows results, but the EA does not open positions on a demo account. In what cases can this happen?

Anyway thanks for the reply, I will post the code in the evening.

 
Dimka-novitsek:


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

All of them: )))))))))))))))))))

Let's start from the beginning:

//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int      tiket, tikett;
int      i=0, R1=0, R2=0, A=1;
double   volume=0.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);
}
//+------------------------------------------------------------------+

Initially two variables are initialized with zero:

int      tiket, tikett;

then the first line of code is where we select the ticket order:

OrderSelect (tiket, SELECT_BY_TICKET, MODE_TRADES);

here the variable ticket is zero. That is, we try to select an order with a zero ticket. In doing so, we haven't even read the help, since the pool parameter is ignored when selecting by ticket, and you still specify MODE_TRADES. This is not an error - it is an extra parameter in this case that is simply ignored. Accordingly, the order with a zero ticket is not selected - it doesn't exist...

Further, everything goes in the nested conditions; the first condition is:

if(OrderSymbol()==Symbol())

... If the symbol of the selected order matches the symbol of the current chart... And since no order has been chosen, we will safely get to the exit from start() without doing anything.

I can assure you... Further on you have no less interesting, but... It's not interesting to poke around.

Start with searching for already opened positions or pending orders that have been set.

Good luck.

 
ilunga:

this is your code, I haven't made any changes

You have written that orders will be placed if you select the tiket order of the given symbol and the given magic order and there are less than 2 orders in total.


Ah, no, that's right, when you start an order less than two, two pending orders are placed, and on the next tick there are two of them and nothing happens.

I must be having some kind of crisis in my head.

 
Dimka-novitsek:


Ah, no, that's right, when you start an order less than two, two pending orders are placed, and on the next tick there are two and nothing happens.

I must be having some kind of crisis in my head.

I have already told you step by step where you have a crisis...
 
Sersad:

I ran a strategy tester on EURUSD, tried to run it for execution on several currencies, EURUSD, GBPUSD, USDJPY - it didn't work anywhere. I used Point when sending buy/sell orders, so it should work for all symbols. What I don't understand the most is why the tester shows results, but the EA does not open positions on a demo account. In what cases can this happen?

Anyway, thanks for the answer, I will post the code in the evening.


The point is that the Point value is different.

 
PapaYozh:


That's the point: the Point value varies.

The Point value differs from quote to quote, but its essence is the same for all quotes with any number of decimal places - it is the minimum price step.

That is why the fact that I have used for a stop-loss, for example, Ask-30*Point instead of Ask-0.003 negates drknn's comment.

"It is quite possible that the EA is written for a four-digit, while the demo account is five-digit. You see, if you set, for example, a stop loss order of 10 pips, then it is the same distance on a five-digit EA as 1 pip on a 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. It is clear that the server would simply reject the command to set an order with a stop of 10 points...".

double Point - Size of the point of the current instrument in the quote currency.
 

A word of advice.

I wrote a simple script to output the value of minimum stop loss/stake profit level in pips.

int start()
{
int min=MarketInfo(Symbol(),MODE_STOPLEVEL);
Alert(min);
return(0);
}

Outputs zero. Is this a standard value for this parameter?

 

fx_max:

I wrote a simple script which outputs the value of the minimum allowable stop loss/stake profit level in pips.


int min=MarketInfo(Symbol(),MODE_STOPLEVEL);

It outputs zero. Is this a standard value for this parameter?


no
Reason: