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

 
Vinin:

I will do it my way and the countdown will be different. I always go from the past to the present. It's a matter of taste though. In fact, with the right approach it doesn't really matter.

Hello,

Please help with the page. (Post 56, 58 pages).

 
Roger:


Probably too fast, you should have studied a bit. :-)

Then you would know that you buy at the ask and sell at the bid. If we sold them, their price would be lower than their offer price.


No, it's just the opposite of what you wrote. Of course, thank you for your attention. I thought hard, figured it out this way and that, and you're wrong.

In general, I see that the problem is not in the Aks and Bids, and I have not solved it.

 
Dimka-novitsek:

Sorry, I'm with mine too. Here, I just gushed the code and it doesn't work.

//+------------------------------------------------------------------+
//| order type.mq4 |
//| Copyright © 2011, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, MetaQuotes Software Corp.
#property link "http://www.metaquotes.net"

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----

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

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
double New_Time=0,razniza, r;int i=0,h=0,q=0,w=0,s=0,g=0;
int start()
{int M,Y;
//----
double ticket,Lots=0.2,fractal_u=Ask,TakeProfit=50,Points = MarketInfo (Symbol(), MODE_POINT);
//----
if (i<10)
{
ticket=OrderSend(Symbol(),OP_BUYSTOP,Lots,fractal_u+5*Points,3,0,fractal_u+5*Points+TakeProfit*Points,
"open a position",163899,0,Red);if (New_Time==0){ New_Time = Time[0];} Alert("New_Time",New_Time);i++; }
Alert("OrderTypeOP_BUYSTOP",OrderType());OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES );
OrderClose( ticket,Lots,Bid,5, 0 );



if (h<10)
{
ticket=OrderSend(Symbol(),OP_SELLSTOP,Lots,fractal_u-5*Points,3,0,fractal_u-5*Points+TakeProfit*Points,
"open a position",163899,0,Red);if (New_Time==0){ New_Time = Time[0];} Alert("New_Time",New_Time);h++; }
Alert("OrderTypeOP_SELLSTOP",OrderType());OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES );
OrderClose( ticket,Lots,Ask,5, 0 );

if (q<10)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Bid,3,0,5*Points+TakeProfit*Points,
"open a position",163899,0,Red);if (New_Time==0){ New_Time = Time[0];} Alert("New_Time",New_Time); q++; }
Alert("OrderTypeOP_BUY",OrderType());OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES );
OrderClose( ticket,Lots,Bid,5, 0 );

if (w<10)
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Ask,3,0,5*Points+TakeProfit*Points,
"open a position",163899,0,Red);if (New_Time==0){ New_Time = Time[0];} Alert("New_Time",New_Time);w++; }
Alert("OrderTypeOP_SELL",OrderType());OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES );
OrderClose( ticket,Lots,Ask,5, 0 );

if (s<10)
{
ticket=OrderSend(Symbol(),OP_BUYLIMIT,Lots,fractal_u-5*Points,3,0,fractal_u-5*Points+TakeProfit*Points,
"open a position",163899,0,Red);if (New_Time==0){ New_Time = Time[0];} Alert("New_Time",New_Time); s++; }
Alert("OrderTypeOP_BUYLIMIT",OrderType());OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES );
OrderClose( ticket,Lots,Ask,5, 0 );

if (g<10)
{
ticket=OrderSend(Symbol(),OP_SELLLIMIT,Lots,fractal_u+5*Points,3,0,fractal_u+5*Points+TakeProfit*Points,
"open a position",163899,0,Red);if (New_Time==0){ New_Time = Time[0];} Alert("New_Time",New_Time);g++; }
Alert ("OrderTypeOP_SELLLIMIT",OrderType());OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES );
OrderClose( ticket, Lots, Bid, 5, 0 );






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

I made it pretty fast, I set it up with the purpose to get a numeric value of the order type, it opens and closes all orders in a row, I mean all types. I checked OrderClose with the instruction, the parameters seem to be prescribed reasonably, correctly and in their places. What the hell else does he need?????

 

Alert("Current time day", iTime(NULL,PERIOD_D1,5));

this gives me 0, added:

Alert("",GetLastError());

gives an error 4054

ERR_INCORRECT_SERIESARRAY_USING4054Incorrect use of time series array

What am I doing wrong?


 

Please help. The code should delete all market orders on all pairs, but in practice it only deletes those on the window where the EA is thrown. Please help me to find the error.


void CloseAll_b(int Prosk){
string SMB=Symbol();
for (int i=OrdersTotal()-1;i>=0;i--){
if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)){
Alert("Error ",GetLastError()," when order number is selected ",OrderTicket()," by pair ",Symbol());
}
else{
if(OrderSymbol()!=Symbol()){continue;}
RefreshRates();
if(OrderType()==OP_BUY){
if(!OrderClose(OrderTicket(),OrderLots(),Bid,Prosk,CLR_NONE)){
Alert("Error ",GetLastError(),",OrderTicket(),",Symbol()) when closing the Buy order;
}
}
if(OrderType()==OP_SELL){
if(!OrderClose(OrderTicket(),OrderLots(),Ask,Prosk,CLR_NONE)){
Alert("Error ",GetLastError(),{ when Sell order number is closed ",OrderTicket(),{ by pair ",Symbol());
} } } } }

Thank you in advance.

 
nemo811:

Please help. The code should delete all market orders on all pairs, but in practice it only deletes those on the window where the EA is thrown. Please help me to find the error.


but you set the constraint yourself :))

if(OrderSymbol()!=Symbol()){continue;}

 
sergeev:

but you set the constraint yourself :))

if(OrderSymbol()!=Symbol()){continue;}


I agree - stupid :)) How should it be?
 
nemo811:

I agree - stupid :))) What's the right way?
... You just have to remove it. You don't want to weed out currencies. So you have to remove the condition.
 
I have removed it, but the orders for other pairs are still not closed. Error 129 (wrong price) started to pop up
 
nemo811:
I have removed it, but my orders for other pairs are not closing anyway. Error 129 (wrong price) keeps popping up

right it pops up.

You have to take Bid and Ask from MarketInfo function

like - ask= MarketInfo(OrderSymbol(), MODE_ASK);

and do not forget to normalize
ask=NormalizeDouble(ask, MarketInfo(OrderSymbol(), MODE_DIGITS))

Reason: