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

 
gheka:

I'm still stumped and don't get it, I don't understand where the unique sequence number comes from, everything is different in the examples,

if I'm not mistaken I don't create it, for example


The ticket (order) number is given by the brokerage company.
 
gheka:

I'm still stumped and don't get it, I don't understand where the unique sequence number comes from, everything is different in the examples,

if I'm not mistaken, I don't create it, for example

It's not me who creates it, it's the DC who assigns it. Does it matter to you that much where exactly it comes from and why?

The main thing is that it exists and you can use it to select your order. But do not forget about the situation when at the end of the day the orders are re-opened with the assignment of a new ticket. So, if you don't know about it and don't take it into account, you may lose it when choosing a position by the ticket.

 
He's smiling! Turned it on, of course.
 
 
Here, the deposit is in place.
 
artmedia70:

The DC assigns it to him. Does it matter that much to you where it comes from and why?

The main thing is that it is there and you can use it to select your order. But do not forget about the situation when at the end of the day the orders are re-opened and a new ticket is assigned. So, if you do not know about it and do not take it into account, you may lose it when choosing a position by the ticket.

Well, let's say I don't need to know where it is coming from, then "The main thing is that it exists and you can use it to select your order.

 
Dimka-novitsek:
Here, the deposit is in place.

You have to look at the rules of the brokerage company. Maybe autotrading is forbidden (although the rules may not say so), you should check with the technical support. Or maybe you just need to check the Expert Advisor code. Check it on another brokerage company
 
gheka:

OK, let's say I don't need to know where it comes from, then "The important thing is that it is there and you can use it to select your order", how can I select it if I don't even know the number?


This question can only be answered if you know under what conditions you want to select it and for what purpose. If you want to store the ticket of an open order in a variable or in the array of orders (in the function of orders accounting of the EA, for example), then immediately after the position opening use the function OrderTicket() - it will return the number of the selected order.
 
There is a need for an EA to smooth out volatility (here is the value: High[iHighest(NULL, 0, MODE_HIGH, 30, 1)] - Low[iLowest(NULL, 0, MODE_LOW, 30, 1)] ) of the exponential moving average. As far as I understand, it cannot be done by standard iMA and I need to write a function for that? Can someone help me with the code?
 

Here it is

//+------------------------------------------------------------------+
//| Dimon's Borders .mq4 |
//| Copyright © 2010, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, MetaQuotes Software Corp.
#property link "http://www.metaquotes.net"

//+------------------------------------------------------------------+
//| expert initialisation function |
//+------------------------------------------------------------------+
extern int BandsPeriod=20,i=1 ;extern int BandsShift=0;
extern double BandsDeviations=2.0;
extern double Lots=0.1,TakeProfit=50,stoploss=10 ;double PointX;
int init()
{ if(Digits==5 || Digits==3) PointX = Point * 10; // Correction Point for three or five digits
if(Digits==4 || Digits==2) PointX = Point;
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialisation function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{ int total=OrdersTotal();// Comment(" total ",total); Alert (" total ",total);
if ( total !=0 ){return;}

double Average,Verhnyayaghranytsa,Nyzhnyayaghranytsa,newres,sum,deviation;
string text; int ticket; int err;
text="macd sample";
Average=iMA(NULL,0,BandsPeriod,BandsShift,MODE_SMA,PRICE_CLOSE,i);
int k,counted_bars=IndicatorCounted();

//----
//----
for( k = 0; k<BandsPeriod; k++)
{ newres=Close[k]-Average;//Alert (" Average ",Average);
sum+=((newres*100)*(newres*100))/10000;//Alert (" newres ",newres);
}




deviation=BandsDeviations*MathSqrt(sum/BandsPeriod);
Verhnyayaghranytsa=Average+deviation;
Nyzhnyayaghranytsa=Average-deviation;//Alert (" sum ",sum);
// Alert (" deviation ",deviation);
//----
if (Verhnyayaghranytsa<Close[i])
{ Comment(" buoy ",Verhnyayaghranytsa );
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-stoploss*PointX,Ask+TakeProfit*PointX, "macd sample",16384,0,Green);

}


if (Nyzhnyayaghranytsa>Close[i])
{ Comment(" sell! ",Nyzhnyayaghranytsa );

ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+stoploss*PointX,Bid-TakeProfit*PointX, "macd sample",16384,0,Red);
Alert (GetLastError());

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

Reason: