externint TakeProfit=18;
externint StopLoss=18;
externdouble Lot=0.01;
externint StartTime=0;
int Today=0;
int h=10;
int h1=26;
int mag=777;
bool b=0,s=0, //соответственно бай или селл
bs=0,// если закрытие по стоплоссу ордера бай
ss=0,// если закрытие по стоплоссу ордера sell
bt=0,
st=0;// то же по ТПdouble bl=0,sl=0; // лоты соответсвенно для бай и селл//+------------------------------------------------------------------+//| expert start function |//+------------------------------------------------------------------+int start()
{
if(DayOfWeek()==0 || DayOfWeek()==6) return(0); // в выходные не работаемif(!IsTradeAllowed()) return(0); // пропустим тик если терминал занятint total = OrdersTotal();
if(total == 0)
{NewOrder(OP_BUY,Lot);
NewOrder(OP_SELL,Lot);
NewOrder(OP_BUYLIMIT,Lot);
NewOrder(OP_SELLLIMIT,Lot);
NewOrder(OP_BUYSTOP,Lot);
NewOrder(OP_SELLSTOP,Lot);
Today=TimeDay(TimeCurrent());}
{
for(int cnt=OrdersHistoryTotal();cnt>0;cnt--)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_HISTORY);
{if(OrderMagicNumber()== mag &&
OrderSymbol()==Symbol())
{ if (OrderType() == OP_BUY ) {b=1; if (OrderClosePrice()==OrderTakeProfit()) bt=1;
if (OrderClosePrice()==OrderStopLoss()) bs=1; bl=OrderLots()*100; break;}
if (OrderType() == OP_SELL) {s=1; if (OrderClosePrice()==OrderTakeProfit()) st=1;
if (OrderClosePrice()==OrderStopLoss()) ss=1; sl=OrderLots()*100; break;}
}
}
}
}//endif(bs==1||bl==1)
{
NewOrder1(OP_BUYLIMIT,Lot);
Today=TimeDay(TimeCurrent());}
and here's the order opening
int NewOrder1(int Cmd,double Lot)
{double TP=0; //тейкпрофитdouble SL=0; //стоплоссdouble PR=0; //Ценаdouble LT=0; //Лотwhile(!IsTradeAllowed()) Sleep(100);
if(Cmd==OP_BUYLIMIT)
{PR=Ask-Point*h;
if(TakeProfit>0) TP=PR+TakeProfit*Point;
if(StopLoss>0) SL=PR-StopLoss*Point;
if(Lot>0) LT=3*Lot;}
int tic1=OrderSend(Symbol(),Cmd,LT,PR,3,SL,TP,0,mag,0,CLR_NONE);
//-----------if(tic1<0) Print(GetLastError());
if(tic1>0){
b=0;s=0; //соответственно бай или селл
bs=0;// если закрытие по стоплоссу ордера бай
ss=0;// если закрытие по стоплоссу ордера sell
bt=0;
st=0;// то же по ТП
bl=0;sl=0; // лоты соответсвенно для бай и селл
}
//-----------return(tic1);}
Could you please give me the code of the function that will put a stop once at breakeven level, when the profit will be for example 20 pips
Thanks in advance for the reply:)
You can find it and many other useful functions on Igor Kim's site http://www.kimiv.ru. And the one you need is called MovingInWL(), if I'm not mistaken.
Boris, it's even simpler than that. You drop this line:
At the very top of the code (to be separate, not in any function). And then in those places where there is a call of the OrderSend(...) function, just enclose it in an additional hug of the if operator
Now before opening the next order, the operator will check if there are deals or no deals at the current bar. If they have been, then the current bar has been stored in the variable new and if the current bar coincides with the stored one, then no position will be opened. Accordingly, if the bar is new, then its opening time will not coincide with the data of the variable new, the deal will be opened and the variable new will get a new value.
I don't know exactly the architecture of your EA, but this method should work in most cases.
There is an indicator with a bunch of arrays. The second indicator needs to work with these arrays. To calculate and output the result to its own table.
The easiest way would be to call this indicator but it seems that this is not possible.
I don't understand how it feels at all... The braces don't match each other, one closing bracket is missing... I don't know what's going on. Clean up your code... It's hard to deal with, and there's no way to compile and run it - we're working on our own codes...
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.
Still opens this order in a batch.
this is how I set the variables in my ekspert
and here's the order opening
Could you please give me the code of the function that will put a stop once at breakeven level, when the profit will be for example 20 pips
Thanks in advance for the reply:)
Boris, it's even simpler than that. You drop this line:
At the very top of the code (to be separate, not in any function).
And then in those places where there is a call of the OrderSend(...) function, just enclose it in an additional hug of the if operator
Now before opening the next order, the operator will check if there are deals or no deals at the current bar. If they have been, then the current bar has been stored in the variable new and if the current bar coincides with the stored one, then no position will be opened. Accordingly, if the bar is new, then its opening time will not coincide with the data of the variable new, the deal will be opened and the variable new will get a new value.
I don't know exactly the architecture of your EA, but this method should work in most cases.
Thank you so much! It fits perfectly!
I can't think of a better way to proceed.
There is an indicator with a bunch of arrays. The second indicator needs to work with these arrays. To calculate and output the result to its own table.
The easiest way would be to call this indicator but it seems that this is not possible.
How to get to other arrays?
I don't know.
Hello, could you please tell me how to view logs in MT4?
You don't have to post 15 messages with only one content. And if you do, it is desirable to clean up after yourself. Do not wait for the uncles.
You must really need to... :) Or the mouse is stuck...
It's not the mouse that's stuck. It's impatience. It took me 20 minutes to delete 15 posts in the end.
It's not the mouse that's stuck.
Still opens this order in a batch.
this is how I set the variables in my ekspert
and here's the order opening
It's not the mouse that's stuck. It's impatience. It took me 20 minutes to delete 15 posts in the end.