[Archive!] Writing an advisor for free - page 26

 
Necron >>:

Так в чем у Вас проблема? Вы же написали на что хотите изменить (и притом как изменить:)). Осталось только открыть MetaEditor и исправить код. А чтобы количество пунктов можно было изменить сделайте так:

PS. Писать один и тот же вопрос в нескольких темах не есть хорошо:)


Please help me close a position!!! I have 3 BUY orders, a signal comes out to close one BUY position and the last order I opened is closed, but I need to close the first one (the earliest one) Thanks a lot!
//---------------Закрытие ордеров----------------------------- 8 --

   while(true)                                  // Цикл закрытия орд.
     {
      if ( Tip==0 && Cls_B==true)                // Открыт ордер Buy..
        {                                       //и есть критерий закр
         Alert("Попытка закрыть Buy ", Ticket,". Ожидание ответа..");
         RefreshRates();                        // Обновление данных
         Ans=OrderClose( Ticket, Lot,Bid,2);      // Закрытие Buy
         if ( Ans==true)                         // Получилось :)
           {
            Alert ("Закрыт ордер Buy ", Ticket);
            break;                              // Выход из цикла закр
           }
         if ( Fun_Error(GetLastError())==1)      // Обработка ошибок
            continue;                           // Повторная попытка
         return;                                // Выход из start()
        }
 
      if ( Tip==1 && Cls_S==true)                // Открыт ордер Sell..
        {                                       // и есть критерий закр
         Alert("Попытка закрыть Sell ", Ticket,". Ожидание ответа..");
         RefreshRates();                        // Обновление данных
         Ans=OrderClose( Ticket, Lot,Ask,2);      // Закрытие Sell
         if ( Ans==true)                         // Получилось :)
           {
            Alert ("Закрыт ордер Sell ", Ticket);
            break;                              // Выход из цикла закр
           }
         if ( Fun_Error(GetLastError())==1)      // Обработка ошибок
            continue;                           // Повторная попытка
         return;                                // Выход из start()
        }
      break;                                    // Выход из while
     }
 
Serg-s-n >>:


Помогите пожалуйста закрыть позицию!!! У меня стоит 3 ордера BUY, выходит сигнал на закрытие одной позиции BUY и у меня закрывается последний ордер, который я открывал, а мне нужно закрыть первый( самый ранний) Заранее спасибо!

You have a ticket to close, and the most recent ticket of the order is remembered. Therefore it is the last order that is closed. Use more than one ticket, and when closing, simply select the one you want. Then you will not have this problem.

PS. Writing one and the same question in several threads is not good :)))).

 
Necron >>:

Так в чем у Вас проблема? Вы же написали на что хотите изменить (и притом как изменить:)). Осталось только открыть MetaEditor и исправить код. А чтобы количество пунктов можно было изменить сделайте так:

PS. Писать один и тот же вопрос в нескольких темах не есть хорошо:)

Thank you so much I didn't know where else to go

 
Necron >>:

У Вас закрытие по тикету, а запоминается самый последний тикет ордера. Поэтому именно последний ордер и закрывается. Используйте несколько тикетов, а при закрытии просто выберите необходимый. Тогда этой проблемы не будет.

PS. Писать один и тот же вопрос в нескольких темах не есть хорошо:)-к Вам это тоже относится)))


How to do this in an EA, I am not yet familiar with such programming, at least show me approximately how to do it
 
Serg-s-n >>:


А как это сделать в советнике, я в таких тонкостях программирования еще не разбираюсь, хотя бы примерно покажите как это сделать

I'm not good at the finer points either:))) And I've only been writing for a little over a month:)). Post the code here and someone will help you. I did it like this in one of my EAs:

int               b1, b2, b3, s1, s2, s3;


int start()
   int      ts1, ts2, ts3, tb1, tb2, tb3;
      

if(OrdersTotal()==0)
         {
             b1=0; b2=0; b3=0; s1=0; s2=0; s3=0;
         }

     if( b1==0)
      {
        if( условие для открытия ордера)
            {
            tb1=OrderSend(Symbol(),OP_BUYSTOP, lot, HL,3* PointX, sl_b, BuyTarget1,"lot_1_buy", Magic,0,Lime);
            if( tb1>0)
              {
                  if(OrderSelect( tb1, SELECT_BY_TICKET, MODE_TRADES))
                     {
                     b1= tb1;
                     Print("lot_1_buy order opened : ",OrderOpenPrice());
                     }
              }
            else Print("Error opening BUY order : ",GetLastError());
            return(0);
            }         
      }

And so for each of the six orders (3 to buy and three to sell). And then after the order is closed, zero all b and s values. Maybe someone will suggest some other way.

  for( cnt=0; cnt< total; cnt++)
     {
         OrderSelect( tb1, SELECT_BY_TICKET);
         if(OrderClosePrice()>0) { b1=0;}
         OrderSelect( tb2, SELECT_BY_TICKET);
         if(OrderClosePrice()>0) { b2=0;}
         OrderSelect( tb3, SELECT_BY_TICKET);
         if(OrderClosePrice()>0) { b3=0;}
         OrderSelect( ts1, SELECT_BY_TICKET);
         if(OrderClosePrice()>0) { s1=0;}
         OrderSelect( ts2, SELECT_BY_TICKET);
         if(OrderClosePrice()>0) { s2=0;}     
         OrderSelect( ts3, SELECT_BY_TICKET);
         if(OrderClosePrice()>0) { s3=0;} 
     }
 

Hello gentlemen programmers. Could you please help, pull from the indicator forums to calculate from the two indicators in order to insert into the EA, determine the value of D_RSI for the desired candle and line Ghana........

Files:
 
miha-28 >>:

Здравствуйте господа программисты. Не могли бы вы помочь, выдернуть из индикатора форумы для расчета из двух индикаторов для того чтобы вставить в советник, определить значение D_RSI для нужной свечи и линии Гана……..





Most likely Forums == Formulas, if so, why would you use iCustom https://docs.mql4.com/ru/indicators/iCustom and you'll be happy.
 

Who will write an indicator advisor?
ikarfx@mail.ru

 
SofTAA

Many human thanks!!!!!!!

 
Gentlemen programmers )

There are two trading strategies I need:

1. Turtles. (similar seen here but not that) with automatic adjustment of an order to enter the market by an indicator, as long as the deal does not happen! And the same exit strictly by the indicator! Well, for insurance purposes, you can disable stop-loss and trailing.

2. Alligator. (I will tell you right away that you don't have to rub my nose in BARS ALLIGATOR and on the alligator Vol.1.1 - I have seen them)

Basically, you can take this one https://www.mql5.com/ru/code/8749 It enters the market well, but then the shit happens. We just need to tweak it a bit in the section exiting a position STRICTLY by crossing allick lines! + stop on 15 pips at position opening WITHOUT trailing! and no TProfits!

for all questions svs-trade@rambler.ru
Also, of course I will send you detailed descriptions of strategies with pictures on request to e-mail.