Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 38

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Then pass the argument to the function, since it is provided. Although it is better to remove it, it is a tautology.
And not all orders in the loop will be recalculated.
The ticket with overwriting, working from the last order with a Martin.
and then how to remove the 'count' hides global declaration at line...
it is interesting to make it work as it should.
So far, the tester shows quite good results, and sometimes "insurmountable errors in the Expert Advisor".
Greetings.
Stumbled across a recording in this format:
I.e...here the conditional if statement has been replaced by a bool-type trade function instead of an expression. Do I understand correctly that such writing is equal to :
if(OrderSelect(ticket,SELECT_BY_TICKET))==true {OrderModify(ticket,OrderOpenPrice(), SL, TP,0};?
I've looked both in Help and in the tutorial - I haven't found such a format.
Can I use this way to directly write functions of a different type instead of an expression? And if so, what would be the algorithm?
I fixed it, put an argument, put it into global scope, now it generates a warning that this argument is already used as input in other functions
Ticket with overwriting, work from last order with martin
and then how to remove declaration of 'count' hides global declaration at line...
It is interesting to make it work as it should.
So far, the tester shows quite good results, and sometimes "insurmountable errors in the Expert Advisor".
Greetings.
Stumbled across a recording in this format:
I.e...here the conditional if statement has been replaced by a bool-type trade function instead of an expression. Do I understand correctly that such writing is equal to :
if(OrderSelect(ticket,SELECT_BY_TICKET))==true {OrderModify(ticket,OrderOpenPrice(), SL, TP,0};?
I've looked both in Help and in the tutorial - I haven't found such a format.
Can I use this way to directly write functions of a different type instead of an expression? If so, what would be the algorithm?
Just like thisif(OrderSelect(ticket,SELECT_BY_TICKET))==true {OrderModify(ticket,OrderOpenPrice(), SL, TP,0}; will not work. The condition must not be thrown out of brackets.
Butif(OrderSelect(ticket,SELECT_BY_TICKET)==true) {OrderModify(ticket,OrderOpenPrice(), SL, TP,0}; you can.
Just like thisif(OrderSelect(ticket,SELECT_BY_TICKET))==true {OrderModify(ticket,OrderOpenPrice(), SL, TP,0}; will not work. The condition must not be thrown out of brackets.
Butif(OrderSelect(ticket,SELECT_BY_TICKET)==true) {OrderModify(ticket,OrderOpenPrice(), SL, TP,0}; you can.
Please show me the corrected version, because without the code it is guessing.
Okay.
Sort of finished what I could. The description is done. The goal is to understand why it doesn't work the way I want it to.
//| ОТЛОЖКИ.mq4 |
//+------------------------------------------------------------------+
extern double StopLoss = 1000; //Стоплосс ордера
extern double TakeProfit = 1500; //Тейкпрофит ордера
extern double TrailingStop = 1000; // трал
extern int Delta = 100; //Расстояние от цены для установки ордера
extern double LOT = 0.1; //Объём позиции
extern int Magic =200;
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
if (TrailingStop!=0) Trailing();
//ИНДИКАТОР RSI
double RSI0=iRSI(NULL,0,5,PRICE_CLOSE,0);
double RSI1=iRSI(NULL,0,5,PRICE_CLOSE,1);
int b,s,p,res;
double BuyPrice=Ask+Delta*Point;
double SellPrice=Bid-Delta*Point;
for (int i=0; i<OrdersTotal(); i++)
{
if (OrderSelect(i, SELECT_BY_POS)==true)
{
if (OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic) continue;
if (OrderType()==OP_BUY || OrderType()==OP_SELL) p++;
if (OrderType()==OP_BUYSTOP) b++;
if (OrderType()==OP_SELLSTOP) s++;
}
}
double SL,TP;
//---- buy stop
if(RSI0>50&&RSI1<50)
{
res=OrderSend(Symbol(),OP_BUYSTOP,LOT,BuyPrice,0,BuyPrice-StopLoss*Point,BuyPrice+TakeProfit*Point,"ОТЛОЖКИ",Magic,OP_SELLSTOP,Blue);
}
//---- sell stop
if(RSI0<50&&RSI1>50)
{
res=OrderSend(Symbol(),OP_SELLSTOP,LOT,SellPrice,0,SellPrice+StopLoss*Point,SellPrice-TakeProfit*Point,"ОТЛОЖКИ",Magic,OP_BUYSTOP,Red );
}
//---- buy stop делете
if(RSI0<50&&RSI1>50)
{
OrderDelete( OrderTicket());
}
//---- sell stop делете
if(RSI0>50&&RSI1<50)
{
OrderDelete( OrderTicket());
}
//----
return(0);
}
//--------------------------------------------------------------------
//---------ФУНКЦИЯ ТРАЛА----------------------------------------------
//--------------------------------------------------------------------
void Trailing()
{
for(int i=0; i<OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
if(OrderSymbol()==Symbol()||OrderMagicNumber()==Magic)
if(OrderType()==OP_BUY)
{
if(TrailingStop>0)
{
if(Bid-OrderOpenPrice()>TrailingStop)
{
if(OrderStopLoss()<Bid-TrailingStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop,OrderTakeProfit(),0,Green);
}
}
}
}
if(OrderType()==OP_SELL)
{
if(TrailingStop>0)
{
if((OrderOpenPrice()-Ask)>TrailingStop)
{
if((OrderStopLoss()>(Ask+TrailingStop)) || (OrderStopLoss()==0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+TrailingStop,OrderTakeProfit(),0,Red);
}
}
}
}
}
}
//+------------------------------------------------------------------------------------+
//+------------------------------------------------------------------------------------+--------------------------------------------------------------------+
and how did you get the ticket for the unopened order?
{
if (OrderSelect(i, SELECT_BY_POS)==true)
{
if (OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic) continue;
if (OrderType()==OP_BUY || OrderType()==OP_SELL) p++;
if (OrderType()==OP_BUYSTOP)
if (сигнал_bue) OrderDelete(OrderTicket());
else b++;
if (OrderType()==OP_SELLSTOP)
if (сигнал_sell) OrderDelete(OrderTicket());
else s++;
}
}
Right? I just can't get it in there.
{
if (OrderSelect(i, SELECT_BY_POS)==true)
{
if (OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic) continue;
if (OrderType()==OP_BUY || OrderType()==OP_SELL) p++;
if (OrderType()==OP_BUYSTOP)
if (сигнал_bue) OrderDelete(OrderTicket());
else b++;
if (OrderType()==OP_SELLSTOP)
if (сигнал_sell) OrderDelete(OrderTicket());
else s++;
}
}