[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 918

 
How do I determine which order type is a sell or buy order, open and for which lot?
 
Maniac:

Hi there! My Expert Advisor has the following code (see below). I understand that the signal to open a position is taken from the values of two indices. How to make the order open on the basis of only one indicator, for example CCI? Thank you very much.

Instead of calling getSignal() to determine the opening criterion, call either checkCCI() or checkMomentum(). Both of these functions return the same signals as getSignal(), namely 0, 1 and -1.

The getSignal() function just compares two values returned by checkCCI() and checkMomentum() and if they are the same, it returns 1 (for buying) or -1 (for selling), or 0 if nothing is done...

 
_SS_:
How do you find out which order type is Sell or Buy, and for which lot?

To enumerate the orders of the terminal, check the magik of the selected order, its type and its lot.

The magik is used to identify whether the order belongs to your EA or not, and the type and lot are the values you are looking for.

If you are looking for the last open order, compare its open time with the open time of other orders and, if its time is the longest, then this is it.

If you are searching for a ticket, you should select it using the ticket but keep in mind that the selection is made from two arrays - market and closed orders.

To find out if the order is a market order, you should check the time of its closing and if it is higher than zero (and only then), then the order is already closed, otherwise - it is a market order.

 
how do you get the magician out?
 
forex-k:
it should work. is the smiley face smiling?


extern double StopLoss=50.0;
extern double TakeProfit=50.0;
extern double Lots=1;
extern int total;

int start()
{
double Price_1, Price_2, min, max;
RefreshRates();
Price_1=Bid;
Price_2=Ask;

min=iLow(NULL,0,2);
max=iHigh(NULL,0,2);
total=OrdersTotal();
if(total<1)
{

if(Price_1>max)
OrderSend(Symbol(),OP_BUY,Lots,Ask,5,Bid-StopLoss*Point,Ask+TakeProfit*Point, "My order#",16384,0,Green);

if(Price_2<min)
OrderSend(Symbol(),OP_SELL,Lots,Bid,5,Ask+StopLoss*Point,Bid-TakeProfit*Point, "My order#",16384,0,Green);
}
}
return(0);

Yes it works, the smiley face is smiling all the time, but it won't work, positions won't open.

 
rustein:

Help, EA does not close all orders when reaching a profit

Open and pending orders are closed with different functions


void CloseAllOrders()
{
for (int i = 0; i < OrdersTotal(); i++)
{
if (OrderSelect(i, SELECT_BY_POS))
{
if (OrdersTotal() > 1 && OrderSymbol() == Symbol() && AccountProfit() >= AccountBalance()*AllProfit/100)
{
if((OrderType()==OP_BUY)) OrderClose(OrderTicket(), OrderLots(),Bid,0);
if((OrderType()==OP_SELL)) OrderClose(OrderTicket(), OrderLots(),Ask,0);
if((OrderType()==OP_BUYSTOP || OrderType()==OP_BUYLIMIT|| OrderType()==OP_SELLSTOP || OrderType()==OP_SELLLIMIT))OrderDelete(OrderTicket());
if(UseSound == true)
{
PlaySound(SuccesSound);
}
}
}
}
}
 
forex-k:

open and pending orders are closed by different functions


Thanks :)
 

Can you tell me how to delete the objects created by the indicator in the window when the indicator itself is removed from the chart?

 
Maniac:

Hi all! I have the following code in my Expert Advisor (see below). As I understand it, the signal to open a position is taken from the indicators of two indices. How can we make the orders open based on only one indicator, e.g. CCI? Thank you very much.


int getSignal() { 
   int CCI = checkCCI();
   return (CCI);
}
int checkCCI() {
   double CCI = iCCI(NULL, 0, 60, PRICE_TYPICAL, 1);
   Print("CCI: ", CCI);
   if (CCI > 0.0) return (1);
   if (CCI < 0.0) return (-1);
   return (0);
} 
 

Good afternoon to all. I need a function to search for highs / lows in N number of bars. Let's say hai/low for 55 bars. Seen it somewhere - can't find it.

Reason: