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

 
Well, yes, I've been looking at the code letter by letter for hours.
 

This is amazing. I'm placing orders with the sethinker in exactly the same way. With the same everything - lot, opening price, profit. And the first order is not defined by OrderType - it is 0, although the first one is in fact a buy limit. But the next open orders are determined by OrderType ( ) correctly, in this code, I have them 4 or 5 and they behave normally.

I also can't delete the first order using OrderDelete(OrderTicket( )) The next ones get deleted exactly the same way, without any problems

 
Dimka-novitsek:

This is amazing. I'm placing orders with the sethinker in exactly the same way. With the same everything - lot, opening price, profit. And the first order is not defined by OrderType - it is 0, although the first one is in fact a buy limit. But the next open orders are determined by OrderType ( ) correctly, in this code, I have them 4 or 5 and they behave normally.

I also can't delete the first order using OrderDelete(OrderTicket( )) The subsequent ones just like that, the order is deleted correctly.


Looks like the psychics are on holiday. We should show you the whole code.

Although, considering what has been posted before, there are errors a lot

 
I don't have an error in the logic code. Where should I go? Is this some kind of nidachet by the language or platform makers.
 
//+------------------------------------------------------------------+
//|                                                      показзз.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);
  }
  
  int tiket,tikett;double volume=0.1;int i=0,R1=0,R2=0,A=1 ;double price; int stsBUY;int stsSELL;double Price;int C=0;int GH;
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
   if (GH<10){
//----
   double price=(Ask+Bid)/2; 
   
    Alert ("OrdersTotal()",OrdersTotal());
       
       if(C==0){ Price = price ;  C=1;}
   //----    
       
       tiket= OrderSend( Symbol(), OP_BUYSTOP,  volume*A, Price +otstup*Point, Point* 3, R1, Price+takeprofit*Point+otstup*Point, "OP_BUYSTOP", 1000,  expiration, Red); 
   Alert ("OP_BUYSTOP", GetLastError( )); 
   
   for(int i=OrdersTotal();i>0;i--){Alert ("i", i);OrderSelect(i,SELECT_BY_POS );Alert ("OrderType( )OP_BUYSTOP", OrderType( ));
   OrderDelete(OrderTicket( )) ; Alert ("OrderDelete-vseOP_BUYSTOP",  GetLastError( ) );}
              
//----
  tikett= OrderSend( Symbol(), OP_SELLSTOP,  volume*A, Price -otstup*Point, Point* 3,R2, Price-takeprofit*Point-otstup*Point, "OP_SELLSTOP" , 2000,  expiration,C'0,128,255' );
    Alert ("OP_SELLSTOP", GetLastError( )); 
    for( i=OrdersTotal();i>0;i--){Alert ("i", i);OrderSelect(i,SELECT_BY_POS );Alert ("OrderType( )OP_SELLSTOP", OrderType( ));
     OrderDelete(OrderTicket( )) ; Alert ("OrderDelete-vseOP_SELLSTOP",  GetLastError( ) );}
//----
 
   //tiket= OrderSend( Symbol(), OP_BUY,  volume*A, Bid, Point* 3, R1, Price+takeprofit*Point+otstup*Point, "OP_BUY", 1000,  expiration, Red); 
   //Alert ("OP_BUY", GetLastError( ));
   //for( i=OrdersTotal();i>0;i--){Alert ("i", i);OrderSelect(i,SELECT_BY_POS );Alert ("OrderType( )OP_BUY", OrderType( ));              
   //OrderClose( OrderTicket( ), OrderLots( ), OrderClosePrice( ) , 0, CLR_NONE);Alert ("OrderCloseOP_BUY",  GetLastError( ) ); }
    
//----
    //tikett= OrderSend( Symbol(), OP_SELL,  volume*A, Ask, Point* 3,R2, Price-takeprofit*Point-otstup*Point, "OP_SELLSTOP" , 2000,  expiration,C'0,128,255' );
    //Alert ("OP_SELL", GetLastError( )); 
    //for( i=OrdersTotal();i>0;i--){Alert ("i", i);OrderSelect(i,SELECT_BY_POS );Alert ("OrderType( )OP_SELL", OrderType( ));
    //OrderClose( OrderTicket( ), OrderLots( ), OrderClosePrice( ) , 0, CLR_NONE);Alert ("OrderCloseOP_SELL",  GetLastError( ) ); } 
    GH++;
    
                         }

Yeah, yeah, here.

In the so-called showroom, orders are simply placed and immediately deleted.

 
It started when the avalanche advisor started to place three orders instead of two
 
Dimka-novitsek:
It started when the avalanche advisor started to place three orders instead of two

What a mess. The EA was not able to get the order to be deleted. What you put in, you get.
 
abolk:

https://docs.mql4.com/ru/basis/types/datetime

bool ObjectCreate( string name, int type, int window, datetime time1, double price1, datetime time2=0, double price2=0, datetime time3=0, double price3=0)

I did so:
ObjectCreate(Up,OBJ_TREND,0,iTime( NULL, PERIOD_D1, 0),UpPrice,(iTime( NULL, PERIOD_D1, 0)+86399),UpPrice); //resign lines
ObjectSet(Up,OBJPROP_COLOR,DeepPink);

I want to draw a line till end of current day, but it is infinite for some reason ?

 
Stells:

I did so:
ObjectCreate(Up,OBJ_TREND,0,iTime( NULL, PERIOD_D1, 0),UpPrice,(iTime( NULL, PERIOD_D1, 0)+86399),UpPrice); //resign lines
ObjectSet(Up,OBJPROP_COLOR,DeepPink);

I want the line to be drawn until the end of the current day, but it is infinite for some reason ?

ObjectSet(Up,OBJPROP_RAY,false);
 
Vinin:

What a mess. One of the orders should be deleted right away. What you put in, you get.


Yes, it's just a check to see how it works, all that's not clear. The first thing I do is to place a pending bylimit order, 20 pips above the price. Then I immediately check it with OrderType,

and it turns out it's not zero. It's zero!!!!. How can it be zero, it's a bylimit!!! Besides, it's not deleted either, it says some kind of error. In addition, all subsequent orders are corrected as 4 or 5, are deleted normally, behave normally.

Moreover, even the orders opened above the first one behave normally, with the same lot, location, in short, all in one! All except the first.