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

 
I, too, sometimes wonder why the developers, instead of all the nonsense, could not just make two buttons in the terminal: "earn" and "drain". The problems would be reduced by an order of magnitude.
 
Necron >>:

Добрый всем! В общем проблема следующего плана. Есть тс, по которой нужно открывать позицию тройным лотом, после чего каждый лот сопровождается отдельно(со своим TP, сигналом закрытия). Интересуют способы реализации. Мне на ум пришел такой способ: использовать три отложенника, запоминать их тикеты, а потом каждый отдельно выбирать и закрывать по своему условию. Есть ли какие-либо другие способы (или более удобные)?

PS. Поймите правильно, около месяца назад только своего первого советника на машках написал=)))))

set a comment for each order ("lot_1", "lot_2"....), recognise orders from the comment...

If it is not clear, then write more details can be described...

 
StatBars >>:

установите каждому ордеру свой коммент("lot_1","lot_2"....), по коменту распознавайте ордера...

Если не понятно то пишите подробнее можно будет описать...

Thanks, StatBars! It's just that I've already started doing with the magician's choice. Your option I think would look like this? (I confess I remembered there was a similar one in one of the EAs =)) Then which option is the most optimal?

if ( (OrderSymbol() == Symbol()) &&
(StringSubstr(OrderComment(),0,0) == "lot_1") )

 
Necron >>:

Спасибо, StatBars! Просто я уже начал делать с выбором по магику. Ваш вариант думаю так будет выглядеть? (признаюсь, вспомнил что в одном из советников было похожее =)) Тогда какой вариант наиболее оптимален?

if ( (OrderSymbol() == Symbol()) &&
(StringFind(OrderComment(),"lot_1") >= 0) )

Corrected a bit.

I usually use magik and the symbol to identify "my" EA's orders.

I put all other information in the comment.

I would not say that this would be anything optimal, because you can't see what you will do with the orders later and whether another 3 orders can open....

 
chief2000 >>:



Будет срабатывать на каждом тике пока выполняется условие. Небось код для тещи переделываете? :)





A huge THANK YOU! Compiled everything works, beeps at every tick.

My mother-in-law isn't here yet, but if anything..., I'll take this idea on board)))

 

Sorry, there is a question. how to crash a client programmatically.

In my research on decompilation I came across the ambiguity of decompilation. now the question arises how to use it.

The choices are to crash the system.

or hang the decompiler.

 
StatBars >>:

Поправил немного.

Магик и символ обычно использую для идентификации "своих" ордеров эксперта.

Всю остальную информацию запихиваю в коммент.

Я бы не сказал что тут будет что-то оптимальнее, не видно же что Вы потом будуте делать с ордерами и может ли открыться ещё одна 3-ка ордеров....

Thank you! Corrected in the Expert Advisor to your variant. I will finish this miracle and upload it to Code Base as my first (more or less) serious creation!) The system by which I write the Expert Advisor is called Muteki, but it is a little bit with my additions (for position management). It is good that at least there is an indicator, that will build all these trends=)))

Only another question has arisen. How do I open three positions simultaneously (or approximately one quote)? Is it correct, or there are other ways? I can't do it with pendants=(( Small distance is sometimes too much:(


if(b1==0 && !IsTradeContextBusy())
{
if(Low[0]<HHL_1 && Bid>=HHL_1 && trade_buy==true)
{
ticket=OrderSend(Symbol(),OP_BUY,lot,Ask,slippage*PointX,sl_b,BuyTarget1,"lot_1_buy",Magic,0,Lime);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("lot_1_buy order opened : ",OrderOpenPrice());
b1=1;
}
else Print("Error opening BUY order : ",GetLastError());

return(0);
}
}

 
// ищем самый последний закрытый ордер
for( i=OrdersHistoryTotal(); i>=0; i--){
  if(OrderSelect( i, SELECT_BY_POS, MODE_HISTORY)){
    if(OrderSymbol()==Symbol()){
      if(OrderMagicNumber()==16384){
        if(OrderCloseTime()!=0){
          if(OrderCloseTime()> time){
          time=OrderCloseTime();
          profit=OrderProfit();
          
            //мартин
            if( profit<=0) Lots=OrderLots()*2;
            //----
            
            
          }
        }
      }
    }
  }
}
//-----

The function searches for the last closed lot, if it made a loss, its lot for opening a new deal will be multiplied by twice.

In practice, each new deal, regardless of whether the deal was profitable or not, is doubled in lot.


Question: what is wrong?

 
Summer:

I remember a function I was redoing. Here's the code. Lots (in ordersend) =getLots(), koeff= lot increment factor (default is 2) Only up to ten lots (from 0.1) I got in my test=))))

double getLots() {

double minlot = MarketInfo(Symbol(), MODE_MINLOT);
double maxlot = MarketInfo(Symbol(), MODE_MAXLOT);
int round;
if(minlot==0.01)round=2;
if(minlot==0.1) round=1;
double koeff=2;
double result=Lots;

int total = OrdersHistoryTotal();
double spread = MarketInfo(Symbol(), MODE_SPREAD);

for (int i = 0; i < total; i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_HISTORY);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
{
if (OrderProfit() > 0)
{
result = Lots;

} else {
result = OrderLots() * koeff;

}
}
}
result = NormalizeDouble(result, round);
if (result > maxlot) {
result = maxlot;
}
if (result < minlot) {
result = minlot;
}
RefreshRates();
return(result);
}

 

there's an error in the function, I can't find it, it's either with ( or with {

I attached the code.

Reason: