Aleksei Stepanenko #: Well, there you have it, beautiful.
No one was quarrelling. If you don't like the answer, go ahead... What's there to be offended about? People are all different. And in a previous post I said this about all programmers. I myself sometimes ask questions in topics for newbies. What's the point of creating a whole thread because of a question that can be answered with just one post?
wrote a robot... The tester gives an OrderSend error 148. What's the problem ?
//+------------------------------------------------------------------+//| эксперт пустой.mq4 |//| Copyright 2021, MetaQuotes Software Corp. |//| https://www.mql5.com |//+------------------------------------------------------------------+#property copyright"Copyright 2021, MetaQuotes Software Corp."#property link"https://www.mql5.com"#property version"1.00"#property strict//+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+intOnInit()
{
//---//---return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| Expert deinitialization function |//+------------------------------------------------------------------+voidOnDeinit(constint reason)
{
//---
}
//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+voidOnTick()
{
//---int pu;
//делаем сделку один раз при октрытии бараint i=1;//номер ордераint posup=0,possell=0;
int pos_sum=0;
int posa_close=0;
double posa_close_summ=0.03;//объем закрытой позицииdatetime bar_otkr=Time[0];
if (Time[0]>bar_otkr)
while ( i<OrdersTotal())
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
pu=pu+OrderProfit();
if (OrderType()== OP_BUY) posup++;
if (OrderType()== OP_SELL) possell++;
if (posup>0)pos_sum=1;//направление байif (possell>0)pos_sum=0;//направление селл
i++;
}
;
printf(posup,possell);
if (Close[0]>Open[0]&&pu==0) OrderSend(Symbol(),OP_BUY,0.03,Bid,2,Ask+15,0,0,0,0,0);//свеча бай при начале работыif (Close[0]<Open[0]&&pu==0) OrderSend(Symbol(),OP_SELL,0.03,Bid,2,Ask+15,0,0,0,0,0);//свеча селл при начале работыif(Close[0]>Open[0]&&pu>0&&pos_sum==1) OrderSend(Symbol(),OP_BUY,0.03,Bid,2,Ask+15,0,0,0,0,0);//свеча бай при прибыли при покупках - покупаем 0.03if (Close[0]<Open[0]&&pu>0&&pos_sum==1)//свеча селл при прибыли при покупках- кроем 0.01while (i<OrdersTotal())
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if (OrderLots()>=0.01&&posa_close==0) OrderClose(i,0.01,Bid,3);posa_close=1 ;
if (posa_close==1)break ; else posa_close=0;
i++;
}
;
if (Close[0]<Open[0]&&pu<0&&pos_sum==1)//свеча селл при убытках при покупках- кроем 0.03while (i<OrdersTotal())
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if (OrderLots()==0.03&&posa_close==0) OrderClose(i,0.03,Bid,3);posa_close=1 ;
if (posa_close==1)break ; else posa_close=0;
if (posa_close==0&&OrderLots()==0.02)OrderClose(i,OrderLots(),Bid,3);posa_close_summ=posa_close_summ-0.02;if (posa_close_summ==0)posa_close=1;
if (posa_close==0&&OrderLots()==0.01)OrderClose(i,OrderLots(),Bid,3);posa_close_summ=posa_close_summ-0.01;if (posa_close_summ==0)posa_close=1;
i++;
}
;
if(Close[0]<Open[0]&&pu>0&&pos_sum==0)OrderSend(Symbol(),OP_SELL,0.03,Bid,2,Ask+15,0,0,0,0,0);// свеча селл при продаже и прибыли - покупаем 0.03if (Close[0]>Open[0]&&pu>0&&pos_sum==0)//свеча бай при продаже и прибыли- кроем 0.01while (i<OrdersTotal())
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if (OrderLots()>=0.01&&posa_close==0) OrderClose(i,0.01,Bid,3);posa_close=1 ;
if (posa_close==1)break ; else posa_close=0;
i++;
}
;
// свеча селл при продаже и убытке - ничего не делаемif (Close[0]>Open[0]&&pu<0&&pos_sum==0)// свеча бай при продаже и убытке - кроем 0.03while (i<OrdersTotal())
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if (OrderLots()==0.03&&posa_close==0) OrderClose(i,0.03,Bid,3);posa_close=1 ;
if (posa_close==1)break ; else posa_close=0;
if (posa_close==0&&OrderLots()==0.02)OrderClose(i,OrderLots(),Bid,3);posa_close_summ=posa_close_summ-0.02;if (posa_close_summ==0)posa_close=1;
if (posa_close==0&&OrderLots()==0.01)OrderClose(i,OrderLots(),Bid,3);posa_close_summ=posa_close_summ-0.01;if (posa_close_summ==0)posa_close=1;
i++;
}
;
}
//+------------------------------------------------------------------+
I don't want to open trades properly... what could be the problem... No errors during compilation
//+------------------------------------------------------------------+//| эксперт пустой.mq4 |//| Copyright 2021, MetaQuotes Software Corp. |//| https://www.mql5.com |//+------------------------------------------------------------------+#property copyright"Copyright 2021, MetaQuotes Software Corp."#property link"https://www.mql5.com"#property version"1.00"#property strict//+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+intOnInit()
{
//---//---return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| Expert deinitialization function |//+------------------------------------------------------------------+voidOnDeinit(constint reason)
{
//---
}
//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+voidOnTick()
{
//---int pu;
//делаем сделку один раз при октрытии бараint i=1;//номер ордераint posup=0,possell=0;
int pos_sum=0;
int posa_close=0;
double posa_close_summ=0.03;//объем закрытой позицииstaticdatetime New_Time=0;
bool New_Bar=false;
if(New_Time!=Time[0])
{
New_Time=Time[0];
New_Bar=true;
}
if (New_Bar)
{
Print(New_Bar);
while ( i<OrdersTotal())
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
pu=pu+OrderProfit();
if (OrderType()== OP_BUY) posup++;
if (OrderType()== OP_SELL) possell++;
if (posup>0)pos_sum=1;//направление байif (possell>0)pos_sum=0;//направление селл
i++;
}
;
if (Close[0]>Open[0]&&pu==0) OrderSend(Symbol(),OP_BUY,0.03,Bid,2,Ask+15,0,0,0,0,0);//свеча бай при начале работыif (Close[0]<Open[0]&&pu==0) OrderSend(Symbol(),OP_SELL,0.03,Bid,2,Ask+15,0,0,0,0,0);//свеча селл при начале работыif(Close[0]>Open[0]&&pu>0&&pos_sum==1) OrderSend(Symbol(),OP_BUY,0.03,Bid,2,Ask+15,0,0,0,0,0);//свеча бай при прибыли при покупках - покупаем 0.03if (Close[0]<Open[0]&&pu>0&&pos_sum==1)//свеча селл при прибыли при покупках- кроем 0.01while (i<OrdersTotal())
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if (OrderLots()>=0.01&&posa_close==0) OrderClose(i,0.01,Bid,3);posa_close=1 ;
if (posa_close==1)break ; else posa_close=0;
i++;
}
;
if (Close[0]<Open[0]&&pu<0&&pos_sum==1)//свеча селл при убытках при покупках- кроем 0.03while (i<OrdersTotal())
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if (OrderLots()==0.03&&posa_close==0) OrderClose(i,0.03,Bid,3);posa_close=1 ;
if (posa_close==1)break ; else posa_close=0;
if (posa_close==0&&OrderLots()==0.02)OrderClose(i,OrderLots(),Bid,3);posa_close_summ=posa_close_summ-0.02;if (posa_close_summ==0)posa_close=1;
if (posa_close==0&&OrderLots()==0.01)OrderClose(i,OrderLots(),Bid,3);posa_close_summ=posa_close_summ-0.01;if (posa_close_summ==0)posa_close=1;
i++;
}
;
if(Close[0]<Open[0]&&pu>0&&pos_sum==0)OrderSend(Symbol(),OP_SELL,0.03,Bid,2,Ask+15,0,0,0,0,0);// свеча селл при продаже и прибыли - покупаем 0.03if (Close[0]>Open[0]&&pu>0&&pos_sum==0)//свеча бай при продаже и прибыли- кроем 0.01while (i<OrdersTotal())
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if (OrderLots()>=0.01&&posa_close==0) OrderClose(i,0.01,Bid,3);posa_close=1 ;
if (posa_close==1)break ; else posa_close=0;
i++;
}
;
// свеча селл при продаже и убытке - ничего не делаемif (Close[0]>Open[0]&&pu<0&&pos_sum==0)// свеча бай при продаже и убытке - кроем 0.03while (i<OrdersTotal())
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if (OrderLots()==0.03&&posa_close==0) OrderClose(i,0.03,Bid,3);posa_close=1 ;
if (posa_close==1)break ; else posa_close=0;
if (posa_close==0&&OrderLots()==0.02)OrderClose(i,OrderLots(),Bid,3);posa_close_summ=posa_close_summ-0.02;if (posa_close_summ==0)posa_close=1;
if (posa_close==0&&OrderLots()==0.01)OrderClose(i,OrderLots(),Bid,3);posa_close_summ=posa_close_summ-0.01;if (posa_close_summ==0)posa_close=1;
i++;
}
;
}
}
//+------------------------------------------------------------------+
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Well, there you have it, beautiful.
No one was quarrelling. If you don't like the answer, go ahead... What's there to be offended about? People are all different. And in a previous post I said this about all programmers. I myself sometimes ask questions in topics for newbies. What's the point of creating a whole thread because of a question that can be answered with just one post?
wrote a robot... The tester gives an OrderSend error 148. What's the problem ?
People ... help! there is a new bar...
how do i open an order only when a new bar opens?
how do i open an order only when a new bar opens?
I don't want to open trades properly... what could be the problem... No errors during compilation
Hi all, I need a piece of code to close all purchases by a certain symbol.
wrote a robot... The tester gives an OrderSend error 148. What's the problem ?
There are no internal functions in MQL, only external.
Do you know how to fix it or do you need a qualified help? )))
There are no internal functions in MQL, only external ones.
Do you know how to fix it, or do you need expert help? )))
error 148 has already been solved
It says wrong take profit - what's wrong?
I put zero instead of Bid-tp - it works!
How do you initialise the tp?