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

 

Still opens this order in a batch.

this is how I set the variables in my ekspert

extern int TakeProfit=18;
extern int StopLoss=18;
extern double Lot=0.01;
extern int 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;}
            }
         }
      }


}//end

if(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);}
 
profitinvesting:

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.
 
ToLik_SRGV:

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?

 
Abzasc:

I don't know.

I got it.
 
LAIT123:

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.
 
artmedia70:

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.
 
Vinin:

It's not the mouse that's stuck.
He thought it was a chat room :)
 
FoxUA:

Still opens this order in a batch.

this is how I set the variables in my ekspert

and here's the order opening

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...
 
Vinin:

It's not the mouse that's stuck. It's impatience. It took me 20 minutes to delete 15 posts in the end.
:) Impatience is usually practiced in another office... :)
Reason: