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

 
Michey25 >>:

что тут не так?

Короче этот советник я прикрепляю к часовому графику, и если цена в начале часа выше чем cn1 а текущая не привышает её на 8 пунктов то ордер должен открыться (также если цена ниже текущего уровня) А он у меня почему-то сразу открывает позицию. Почему?

And where is the 8-point condition written? Better to multiply eight by MarketInfo(NULL,MODE_POINT);

 
splxgf >>:

А где записано условие на 8 пунктов? лучше восемь умножать на MarketInfo(NULL,MODE_POINT);

(a-cn1)<0.0008)

 
Help me to merge two EAs. Expert PYLOSE closes orders with a certain MAGIKOM when a given amount of money, and the EA Trailing trails equity when it reaches a given amount.help me insert some code from Trailing in PYLOSE, it also trails, but does not close orders with a given MAGIKOM when it reaches a specified amount.and possibly comment on the trailing funds displayed on the screen.thanks!
Files:
archive_1.zip  10 kb
 

Michey25


when i was answering the code was a bit different ;)

Although there are some questions, the result of op(0) depends a lot on the current timeframe. it's not clear where the cn comes from and what type they are.

Can't you make Alert(Open[0],cn1,Open[0]<cn1,a,(a-cn1)<0.0008)?

Also better use break instead of i=1, this will exit the loop immediately instead of running all commands to the end.

int i=0;
   double a,b;
   while (i==0)
   {
     a=MarketInfo("USDCAD", MODE_ASK);
     b=MarketInfo("USDCAD", MODE_BID); 
     if((Open[0]<cn1)&&((a-cn1)<0.0008))
      {
       OrderSend("USDCAD",OP_BUY,1,a,1,SL,cn2);
       i=1;
       }
     if((Open[0]>cn11)&&((cn11-b)<0.0008))
      {
       OrderSend("USDCAD",OP_SELL,1,b,1,SL1,cn21);
       i=1;
      }  
   }
 

Hello. Please help me implement the following thing. There are 2 independent conditions in one EA, based on which separate orders are opened, each with its own magic. At any given time on one chart there can be only one order for each of the conditions, and they can be at the same time with each other. To check the possibility of opening orders, I do the following structure

int CalculateCurrentOrders(string symbol)
  {
   int buys=0, sells=0, buystop=0, sellstop=0;
//----
   for(int i=0; i<OrdersTotal(); i++)
     {
      if(OrderSelect( i, SELECT_BY_POS, MODE_TRADES)==false) break;
      if(OrderSymbol()==Symbol() && (OrderMagicNumber()== MAGIC1 || OrderMagicNumber()== MAGIC2))
              {
         if(OrderType()==OP_BUY)  buys++;
         if(OrderType()==OP_SELL) sells++;
          if(OrderType()==OP_BUYSTOP)  buys++;
         if(OrderType()==OP_SELLSTOP) sells++;
        }
     }
//----
   if( buys>0) return( buys);
   else       return(- sells);

But the orders are only opened with the second magic.

Then the orders are also closed independently of each other. At the same time, the order with the first magic uses a trawl and the second does not

I have used this example, but the closing either does not happen according to the rules of either the first or the second condition, or does not happen at all

 

  for(int i=0; i<OrdersTotal(); i++)
     {
      if(OrderSelect( i, SELECT_BY_POS, MODE_TRADES)) 
      if(OrderSymbol()==Symbol() && OrderMagicNumber()== MAGIC1)
     if(OrderType()==OP_BUY) 
     if ( Sell1==1)
             {
              OrderClose(OrderTicket(),OrderLots(),Bid,3,Red);
              return(0);
             }
                     
      if(OrderType()==OP_SELL) 
      if ( Buy1==1)
             {
              OrderClose(OrderTicket(),OrderLots(),Ask,3,Green);
              return(0);
             }
  
      if(OrderType()==OP_BUYSTOP && Sell1==1)
         {
         OrderDelete(OrderTicket());
         return(0);
         }
      if(OrderType()==OP_SELLSTOP && Buy1==1)
         {
         OrderDelete(OrderTicket());
         return(0);
         }
    }
   
   for(int i2=0; i2<OrdersTotal(); i2++)
     {
      if(OrderSelect( i2, SELECT_BY_POS, MODE_TRADES)) 
   
         if(OrderSymbol()==Symbol() && OrderMagicNumber()== MAGIC2)
     if(OrderType()==OP_BUY)
      if ( Sellcl0==1)
       {

       OrderClose(OrderTicket(),OrderLots(),Bid,3,Red);
              return(0);
            }
                 
    if(OrderType()==OP_SELL) 
    if ( Buycl0==1)
    
            {
              OrderClose(OrderTicket(),OrderLots(),Ask,3,Green);
              return(0);
          
        }
     if(OrderType()==OP_BUYSTOP) 
     if ( Sellcl0==1)
         {
         OrderDelete(OrderTicket());
         return(0);
         }
      if(OrderType()==OP_SELLSTOP && Buycl0==1)
        {
         OrderDelete(OrderTicket());
        return(0);
         }
      }   
    
     // MODIFICATION -------
     
     TrailingPositionsBuy( parab);
    TrailingPositionsSell( parab);
   // TrailingPositionsBuystop(parab);
   // TrailingPositionsSellstop(parab);
    return (0);
   }
/*bool ExistPositions() {
   for (int i=0; i<OrdersTotal(); i++) {
      if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
         if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) {
            return(True);
         }
      } 
   } 
   return(false);
}*/
     
void TrailingPositionsBuy(double parab) { 
   for (int i=0; i<OrdersTotal(); i++) { 
      if (OrderSelect( i, SELECT_BY_POS, MODE_TRADES)) { 
         if (OrderSymbol()==Symbol() && OrderMagicNumber()== MAGIC1) { 
            if (OrderType()==OP_BUY) { 
             //  if (Bid-OrderOpenPrice()>trailingStop*Point) { 
              //    if (OrderStopLoss()<Bid-trailingStop*Point) 
                     ModifyStopLoss( parab);
                                   
               } 
            } 
         } 
      } 
   } 
//} 
void TrailingPositionsSell(double parab) { 
   for (int i=0; i<OrdersTotal(); i++) { 
      if (OrderSelect( i, SELECT_BY_POS, MODE_TRADES)) { 
         if (OrderSymbol()==Symbol() && OrderMagicNumber()== MAGIC1) { 
            if (OrderType()==OP_SELL) { 
             //  if (OrderOpenPrice()-Ask>trailingStop*Point) { 
             //     if (OrderStopLoss()>Ask+trailingStop*Point || OrderStopLoss()==0)  
                     ModifyStopLoss( parab);
                  
               } 
            } 
         } 
      } 
   } 

Sell1, buy1, sellcl0, buycl0 are descriptions of closing conditions.


Would such a double override of positions work at all? Thank you!

 
exolon >>:

Здравствуйте. Помогите пожалуйста реализовать такую вещь. В одном эксперте работают 2 независимых условия, на основе которых открываются отдельные ордера, каждый со своим magic. В каждый момент времени на одном графике может быть только один ордер по каждому из условий, при этом они могут быть одновременно друг с другом. Для проверки возможности открытия ордеров делаю такую конструкцию

Но открываются ордера только со вторым magic.

Далее, закрываются ордера тоже независимо друг от друга. При этом ордер с первым magic использует трал, а второй нет

Применил вот такой вариант, но закрытия либо происходят не по правилам ни от первого, ни от второго условия, либо не происходят вообще

sell1, buy1, sellcl0, buycl0 - описания условий на закрытие.


Будет ли вообще работать такой двойной перебор позиций? Благодарю!


after closing and deleting orders, remove the returnee and put it at the end of the function or put a continuum instead

 

Hi all, I'm writing my first mql program and learning the language at the same time.

I have a question, can you advise me?


I've got a question: if I'm writing my first mql program, I'd like to know what's wrong with it. Can you tell me what's wrong? I've spent four hours looking through the reference book, I don't understand it myself.


void CheckSell()
{
while(!(NormalizeDouble(Price,Digits) < NormalizeDouble(MA10,Digits)))
{
Sleep(5);
RefreshRates();
}
Sell();
}

 
Jahspear писал(а) >>

Hi all, I'm writing my first mql program and learning the language at the same time.

I'm learning the language. Can you advise me please?

I've got a question: if I've got a buy, then the function that checks conditions for sale is called, and then the tester hangs and the code is not executed any more. Can you tell me what's wrong? I poked around the reference book for about four hours, I don't understand it.

void CheckSell()
{
while(!(NormalizeDouble(Price,Digits) < NormalizeDouble(MA10,Digits)))
{
Sleep(5);
RefreshRates();
}
Sell();
}

And what I did the loop for. If there is no condition we should not wait for some unknown number of days for the signal to appear.

 

Good afternoon.

The indicator has IndicatorShortName("iC_C_mod, ..... ");

I need, however, besides this caption, to insert a comment with a dynamically changing variable in the indicator window.

Like f-i Comment();

I need it in the indicator window, but not on the chart.

Please advise ?

 
Jahspear >>:



void CheckSell()
{
if((NormalizeDouble(Price,Digits) < NormalizeDouble(MA10,Digits)))
Sell();
}


Probably something like this, because infinite loops take a very long time on modern hardware.
Reason: