[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 17

 

Hi ! Question is how do we know if the object is deleted manually if we only know the description of the object. i.e. object with an unknown name , take profit is attached to the object , if the object is deleted remove take profit , and we do not know the name of the object ....

Is there any way to change the name of the object ????

 

Please help me refine the EA! I want it to open one order when the signal comes, when the next one comes, and so on, regardless of whether there are open orders or not.

Please tell me what is wrong!

 m0=iMA(NULL,0,PeriodMA,0,MODE_SMA,PRICE_CLOSE,0);
    m1=iMA(NULL,0,PeriodMA,0,MODE_SMA,PRICE_CLOSE,1);
    lwma=iMA(NULL,0,PeriodLWMA,0,MODE_LWMA,PRICE_CLOSE,0);
    lwma1=iMA(NULL,0,PeriodLWMA,0,MODE_LWMA,PRICE_CLOSE,1);
    sar=iSAR(NULL,0,step,maximum,0);
    sar1=iSAR(NULL,0,step,maximum,1);
//+------------------------------------------------------------------+
   
      Lots=NormalizeDouble(AccountFreeMargin(),0)*MaxRisk/1000;
     if(Lots<0.01) 
    return(Lot);
//--------------------------------------------------------------------
    balans=NormalizeDouble(AccountFreeMargin(),2);
//--------------------------------------------------------------------
   total=OrdersTotal();
   if(OrdersTotal()>=0)
     {
   x=1;
   x++;  
//==========================Медленный==================================
   if( m1>lwma1 && m0<lwma && balans>0 && total<x)
     {
     ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+sl*Point,Ask-tp*Point,"0",Magik,0,Red);
     }
   if(ticket>0)
     {
     Alert("Продажа №",ticket,"\n",Symbol());
     return(0);
     }
//-------------------------------------------------------------------- 
   if ( m1<lwma1 && m0>lwma && balans>0 && total<x)
    {
      ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-sl*Point,Bid+tp*Point,"0",Magik,0,Blue);
     }
  if(ticket>0)
     {
      Alert("Покупка № ",ticket,"\n",Symbol());
      return(0);  
     }
//========================Быстрый=====================================
   
    if(sar1<Bid && sar>Ask && balans>0 && total<x)
      {
       ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+sl1*Point,Ask-tp1*Point,"0",Magik1,0,Red); return;
      }
    if(ticket>0)
      {
      Alert("Продажа №",ticket,"\n",Symbol());
       return(0);
      }
//---------------------------------------------------------------------
  if(sar1>Ask && sar<Bid && balans>0 && total<x)
      {
      ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-sl1*Point,Bid+tp1*Point,"0",Magik1,0,Blue);
      }
   if(ticket>0)
     {
         Alert("Покупка №",ticket,"\n",Symbol());
         return(0);
        }
       }
 

deadlock.....

if(Ma_1>Ma_2 && flagg==0) {PlaySound("news.wav"); flagg=1; flag=0; }

if(Ma_1<Ma_2 && flag==0) {PlaySound("ok.wav"); flag=1; flagg=0; }

Print(flag,flagg);

Ma_1 - short
Ma_2 - long

when Ma_1>Ma_2 beeps news.wav without stopping, and prints 0 1 (i.e. flag=0 flagg=1)

but how can it be that when flagg=1, the condition (Ma_1>Ma_2 && flagg==0) is fulfilled and {PlaySound("news.wav") passes ???

 
Hello all, I need to remake the EA to close all positions after a certain percentage of the initial amount of the requited amount, for example, if no order is opened, for example, the requitty of 1000 and the % of the requitty is set to 5%, so it closes all positions with requitty 1050, I made the EA recorded a global variable and that he had this value to count and close positions but the EA does not want to close,I have done it so, the balance increases and I have to close some positions at 5% of 'Equity' but it is not 1050 and sometimes I have to wait some more, or the price changes direction and I get a loss instead of profit, please help who knows and has faced global changes!!! Thanks a lot for the reply.
Files:
 
Good evening! Do I understand correctly that in
iStochastic
mode
Is it the K or D line I'm referring to? Moreover, 0 is K and 1 is D?
 

And look at a variant like this, without global variables.

if(Profit>AccountEquity( )*koefitsientudaleniya){  
   int Total=OrdersTotal();
    for( i=OrdersTotal()-1;i>=0;i--){
  OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
  if(OrderSymbol() != Symbol()) continue; 
   if (OrderMagicNumber() != 450) continue;
   if(OrderType()==OP_SELL) {
  OrderClose(OrderTicket(),OrderLots(),Ask,6,Red);Print(" i " , i,"  GetLastError()CloseOP_SELL ", GetLastError()  );}
   if(OrderType()==OP_BUY)  {
  OrderClose(OrderTicket(),OrderLots(),Bid,6,Red);Print(" i " , i,"  GetLastError()CloseOP_BUY ", GetLastError()  );}}} и виличины, закрываем все ордера!
//----
 
 
Yes, there shouldn't be any signals before you change mashes!!! Sort of... Probably look at the whole code! I don't know, it doesn't seem to show...
 
i need the advisor to remember the eQuity value when there are no open orders, for example 1000 and as i wrote %-5 the eQuity value is 1050 when all positions are closed, i got it so some orders are closed and the balance increases but the profit is negative of all orders and the advisor waits until the profit is + then closes all positions
 
lottamer:

deadlock.....

if(Ma_1>Ma_2 && flagg==0) {PlaySound("news.wav"); flagg=1; flag=0; }

if(Ma_1<Ma_2 && flag==0) {PlaySound("ok.wav"); flag=1; flagg=0; }

Print(flag,flagg);

Ma_1 - short
Ma_2 - long

when Ma_1>Ma_2 beeps news.wav without stopping, and prints 0 1 (i.e. flag=0 flagg=1)

but how can it be that when flagg=1, condition (Ma_1>Ma_2 && flagg==0) is fulfilled and {PlaySound("news.wav") passes ???


Print the state of the flags separately for each condition. You got it so because second flag's state is not taken into account in conditions.

P.S. And it's more convenient to print outPrint("flag=",flag, "flagg=",flagg) to avoid confusion;

 

That's how I have the robot in the demo. I don't remember in detail how I came up with the idea to write it.

if(Profit>AccountBalance()*koefitsientudaleniya){
int Total=OrdersTotal();
for( i=OrdersTotal()-1;i>=0;i--){
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol() != Symbol()) continue;
if(OrderMagicNumber() != 450) continue;
if(OrderType()==OP_SELL) {
OrderClose(OrderTicket(),OrderLots(),Ask,6,Red);Print(" i " , i," GetLastError()CloseOP_SELL ", GetLastError() );}
if(OrderType()==OP_BUY) {
OrderClose(OrderTicket(),OrderLots(),Bid,6,Red);Print(" i " , i," GetLastError()CloseOP_BUY ", GetLastError() );}}} // If the profit exceeds some value we have specified, we close all the orders!
//----

Or let our elder friends advise us...

Reason: