[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 425

 
sss2019:

Is there any way to make not more than one order open on the current bar? That is, I need one order to be opened on the current fractal, but no more than that, and on the next one, etc.

Can it be done somehow?

Yes, it is possible. There is only a double question. If we open on the current bar, it is the zero bar. And the fractal is formed at least on the second one.

Save the time of the fractal bar in the variable and, if a position has already been opened for this fractal with such a time, do not open more positions with it. As soon as a new fractal is formed, its bar time will change and then open a new position and, after its successful opening, store the new fractal time in the variable.

 

I don't mean to be intrusive. Help with my question. Can't close an order. It's giving me an error with the wrong ticket. The problem is in the ticket, how do I call it and close the order? How do I close a ticket? Thank you.

I am writing my EA in a way that sell is opened after buy and vice versa, but for some reason only the first order is closed and the others are not.


OrderSend(Symbol(),OP_SELL,1,Bid,3,0,0,NULL,12345,CLR_Blue);

Makes an error, wrong ticket. The problem is in the ticket, how do I call it and close the order? Thank you.

 

Hello! In the window on which the EA is attached, how do I display the red Right price marker of the opening price of that order, on the bar on which it opened?

Ticket=OrderSend(Symb,OP_SELL,Lts,Bid,2,SL,TP);
 
kolaider:

I don't mean to be intrusive. Help with my question. Can't close an order. It's giving me an error with the wrong ticket. The problem is in the ticket, how do I call it and close the order? How do I close a ticket? Thank you.

I am writing my EA in a way that sell is opened after buy and vice versa, but for some reason only the first order is closed and the others are not.


OrderSend(Symbol(),OP_SELL,1,Bid,3,0,0,NULL,12345,CLR_Blue);

I got an error with a wrong ticket. The issue is in the ticket, how do I call it and close the order? Thank you.

OrderSend(Symbol(),OP_SELL,1,Bid,3,0,0,NULL,12345,0,CLR_Blue);

You are missing an expiry option (highlighted in red)

Do you want to open a Sell position when you close a Buy position and vice versa?

In the list of closed orders, find the last closed order, view its type and open the opposite one.

To close an order, you must first select it, take its ticket and close it.

 
kolyango:

Hi! How do I display the red Right price marker of the opening price of that order, on the window where the EA is attached, as the SELL market order opened?


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

Creates an object with the specified name, type and initial coordinates in the specified sub-window of the graph. The number of coordinates associated with the object can be from 1 to 3 depending on the type. The function returns TRUE if the object is created successfully, otherwise FALSE. To get more information about the error, call the GetLastError() function.
Objects of type OBJ_LABEL ignore the coordinates. Use ObjectSet() to set the OBJPROP_XDISTANCE and OBJPROP_YDISTANCE properties.
Notes: The chart subwindows (if there are any indicator subwindows in the chart) are numbered starting from 1. The main chart subwindow is always present and has the index 0.
Coordinates must be passed in pairs - time and price. For example, the OBJ_VLINE object only needs time, but the price (any value) must also be passed.
Parameters:
name - Unique name of the object.
type - Type of object. Can be any type of object.
window - Index of the window to which the object will be added. Window index must be greater than or equal to 0 and less than WindowsTotal().
time1 - Time of the first coordinate.
price1 - Price of the first coordinate.
time2 - Time second coordinate.
price2 - Price of the second coordinate.
time3 - Time for the third coordinate.
price3 - Price of the third coordinate.
Example:
 // new Text object if(!ObjectCreate("text_object", OBJ_TEXT, 0, D'2004.02.20 12:30', 1.0045)) { Print("error: can't create text_object! code #",GetLastError()); return(0); } // new TextLabel object if(!ObjectCreate("label_object", OBJ_LABEL, 0, 0)) { Print("error: can't create label_object! code #",GetLastError()); return(0); } ObjectSet("label_object", OBJPROP_XDISTANCE, 200); ObjectSet("label_object", OBJPROP_YDISTANCE, 100);
 

artmedia70:


You can. Only the question is twofold. If you open on the current bar, it is zero bar. And the fractal is formed at least on the second bar.

Save the bar time of the fractal bar in the variable and, if that fractal has already been opened with that time, do not open another position with it. As soon as a new fractal is formed, its bar time will change and you open a new position and, after its successful opening, store the new fractal time in the variable.


How can I save it, into a global variable? I have created a simple variable, but it seems it is not saved and the orders keep opening. See

int start()
  {
  double MyPoint = Point;
  if(Digits == 3 || Digits == 5)
    {
    MyPoint = Point * 10;
    }
  
   double upperfractal;
   int upperi;
//----
   for(upperi=1;upperi<Bars;upperi++)
     {
     upperfractal=iFractals(Symbol(), Period(), MODE_UPPER, upperi); if (upperfractal>0) break;
     }
     
   datetime opentime;
     
   if(upperfractal>0 && upperi > 2 && opentime != Time[upperi])
     {
     if(OrderSend(Symbol(),OP_BUYSTOP,Lot,upperfractal + 10 * Point,3,0,0,"comment",1354453,0,Green) == true)
       {
       opentime = Time[upperi];
       }else
       {
       Alert("",GetLastError());
       }
     }

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

Variable opentime

I would like to ask somebody to help me please.

I even tried to make the variable global, but it still opens many trades, as if the variable is reset every time.

datetime opentime = 0;

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
  double MyPoint = Point;
  if(Digits == 3 || Digits == 5)
    {
    MyPoint = Point * 10;
    }
  
   double upperfractal;
   int upperi;
//----
   for(upperi=1;upperi<Bars;upperi++)
     {
     upperfractal=iFractals(Symbol(), Period(), MODE_UPPER, upperi); if (upperfractal>0) break;
     }
     

     
   if(upperfractal>0 && upperi > 2 && opentime != Time[upperi])
     {
     if(OrderSend(Symbol(),OP_BUYSTOP,Lot,upperfractal + 10 * Point,3,0,0,"comment",1354453,0,Green) == true)
       {
       opentime = Time[upperi];
       }else
       {
       Alert("",GetLastError());
       }
     }

//----
   return(0);
 
T-G:

Please advise how to deal with a trivial problem - I have a hole in EUR history for June 2011 and then September and a bit of September is lost

in the \terminal\history\downloads\EURUSD folder there are these files

EURUSD_2011_06_81625bcefc91bf488a04d5a1dae0c93f
EURUSD_2011_09_2557787db3eb2fe87073c783f21cdd66

EURUSD_2011_10_15793a4a4f9d001b78a82e248872bc3b

I tried several terminals from different brokers, including native MQ. I also tried it on different machines with XP and Win7. Tried deleting symbols.raw and symgroups.raw and downloading them again - did not help.


I wonder if it is crucial for you to have a history of this particular period?
 
nadya:
I wonder if it is crucial for you to have a history of this particular period?
What do you think? Since I'm asking, yes!
 
T-G:
What do you think? Since I'm asking, yes!
Well then, ask for a story from the storage people.
 
sss2019:


How do I save it to a global variable? I made a regular variable, but it doesn't seem to be saved and the orders keep opening. Here is

Variable opentime

I am trying to make this variable global.

I even tried to make the variable global, but it still opens a lot of trades, as if the variable is reset every time.

OrderSend returns an integer value, it is not a Boolean function, be careful
Reason: