What's wrong with that? - page 3

 

Please tell me why this script does not open deals and shows error 0, i.e. no error, but does not open deals.

extern int MagicNumber = 10001;
extern double Lots = 0.1;
extern double StopLoss = 50;
extern double TakeProfit = 50;
extern int TrailingStop = 25;
extern int Slippage = 3;
//+------------------------------------------------------------------+
//    expert start function
//+------------------------------------------------------------------+
int start()
{
  double MyPoint=Point;
  if(Digits==3 || Digits==5) MyPoint=Point*10;
  
  double StochMain = iStochastic(NULL,0,7,10,4,MODE_LWMA,1,MODE_MAIN,0);
  double StochSignal = iStochastic(NULL,0,7,10,4,MODE_LWMA,1,MODE_SIGNAL,0);
  double MaSi = iMA(NULL,0,100,0,MODE_EMA,PRICE_CLOSE,0);
  
  if( TotalOrdersCount()==0 ) 
  {
     if((StochMain > StochSignal)&&(Close[1] > MaSi)) // Here is your open buy rule
     {
     OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Ask+StopLoss*MyPoint,Ask+TakeProfit*MyPoint,"Открыта сделка на покупку!!",MagicNumber,0,Yellow);
     }
     else
     {
        if(GetLastError() != 0)
        Alert("Ошибка ",GetLastError());
     }
  }
  
 
I think your stoploss is bigger than the opening price
 
Right, and there's no error.
 

Tell me how to decipher this, I don't understand how this piece works

    for(int cnt=0;cnt<OrdersTotal();cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

So first we set the cnt variable to 0

Then, if the number of orders exceeds 0, OrderSelect is triggered.

But what is this same variable cnt with value 0 responsible for?

 OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
 
Try just reading about the function and it will be clear in no time.
 

No nothing has become clear, why exactly 0? Are the orders numbered from zero or what?

And there is more.

OrderType()<=OP_SELL

How do I know if this is less than or equal to a sell order? Which one is smaller and which one is bigger?

 
sss2019:

No nothing has become clear, why exactly 0? Are the orders numbered from zero or what?

yep, from scratch. just like everything else.

And there is more.

How do I know if this is less than or equal to a sell order? How do we know which one is smaller and which one is bigger?


because OP_SELL is constant=1
 

So

OP_BUY - 0
OP_SELL - 1
OP_BUYLIMIT - 2
OP_BUYSTOP - 3
OP_SELLLIMIT - 4
OP_SELLSTOP - 5

that's how it works?

 
sss2019:

So

OP_BUY - 0
OP_SELL - 1
OP_BUYLIMIT - 2
OP_BUYSTOP - 3
OP_SELLLIMIT - 4
OP_SELLSTOP - 5

that's how it works?


Right. True, there is another value that equals 6.
 
What else is it going to be?
Reason: