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

 
WindSW:

My code makes it easier to determine the number of iterations via ArrayRange.

Why do I get 0 when I write xDelH[countDH][0]=HBar[countH][0]; (although HBar[countH][0] is already filled and has its own value)? Can I do this at all?

How do you check the value of xDelH[countDH][0] after this assignment operation?
 
Please tell me which function remembers the Take Profit price of the last open order
 
Frostr:
Please tell me which function remembers the Take Profit price of the last open order

If you need to remember exactly, just save theTakeProfit value in a variable each time you open an order.
 

I just need to

//average by calculating the average price
double averageprice = NormalizeDouble(sum/allots, Digits);
//modify all orders of the series by moving the same TakeProfit for each open order
for ( trade = OrdersTotal() - 1; trade >= 0; trade-- )
{
if ( OrderSelect(trade, SELECT_BY_POS, MODE_TRADES) && OrderMagicNumber() == Magic && OrderSymbol() == Symbol())
{
//take profit for a BUY order
if ( OrderType() == OP_BUY) tp = averageprice + TP * Point;
//take profit for a SELL order
if ( OrderType() == OP_SELL) tp = averageprice - TP * Point;
//modify the order belonging to the series
OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), NormalizeDouble(tp, Digits), 0, Yellow);
}
}
}

modified old orders, changed their TakeProfit to TakeProfit of the new opened order (if the price closes the last order at Stop then all previous orders will be closed too)

 
Frostr:

I just need to

//averaging by calculating the average price
double averageprice = NormalizeDouble(sum/allots, Digits);
//modify all the orders of the series by moving the same TakeProfit for each open order
for ( trade = OrdersTotal() - 1; trade >= 0; trade-- )
{
if ( OrderSelect(trade, SELECT_BY_POS, MODE_TRADES) && OrderMagicNumber() == Magic && OrderSymbol() == Symbol())
{
//Profit for BUY order
if ( OrderType() == OP_BUY) tp = averageprice + TP * Point;
//take profit for a SELL order
if ( OrderType() == OP_SELL) tp = averageprice - TP * Point;
//modify an order that belongs to the series
OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), NormalizeDouble(tp, Digits), 0, Yellow);
}
}
}

modify old orders, change their TakeProfit to TakeProfit of a new open order (if the price closes the last order at stop, all previous orders will also close)


The previous ones will close if you set a single stoploss for the whole series. This will help to save the profit made on these orders, or reduce the loss if the price has changed. If you leave the stop loss different for each order (without changing it), then only one order will be closed. The TakeProfit value for other orders of the series will have to be either recalculated or set equal to the previous value.
 
paladin80:
How do you check the value of xDelH[countDH][0] after this assignment operation?

Via Print
 

Good day!!! you know, I place two orders with this place - by design, one with a stop and one without. In the tester, both are deleted!!!!

 if   (Svetsja_1 &&  !Svetsja_2  && !Svetsja_3  &&  !Orderbuy ){
    //стоп лосс 25 п. профит 30 п;стоп лосс 25 п. тралится по MA 20    
         
        RefreshRates();
          OrderSend (Symbol( ), OP_BUY, lot ,NormalizeDouble(Ask, Digits), 5, NormalizeDouble( Ask- (25*Point),Digits),   NormalizeDouble( Ask+( 30*Point),Digits), NULL, 450, 0, CLR_NONE);
           int Error=GetLastError();if (Error==0){  
           Sleep(2000); RefreshRates(); 
          OrderSend (Symbol( ), OP_BUY,  lot ,NormalizeDouble(Ask, Digits), 5, NormalizeDouble( Ask- (25*Point),Digits),   0, NULL, 450, 0, CLR_NONE); }
            Error=GetLastError(); Orderbuy=1; 
            if (Error!=0){ string errorcomment = "Ошибка открытия  ордера OP_BUY"  + " " + Symbol() +  " " + ErrorDescript(Error); 
            Print (errorcomment);}   }  } }

I have absolutely no idea what's going on here.


 
Dimka-novitsek:

Good day!!! you know, I place two orders with this place - by design, one with a stop and one without. In the tester, both are deleted!!!!

I have absolutely no idea what's going on here.



Look closely, you set stoploss for both of them and takeprofit for only one. So it's like you wrote: both will be closed at stoploss and only one will be closed at takeprofit.
 
Dimka-novitsek:

Good day!!! you know, I place two orders with this place - by design, one with a stop and one without. In the tester, both are deleted!!!!

I don't understand what's going on here at all.

It's probably too early for you to "smoke" it - COULD BE SUSPENDED! :)))
 
Yes, thank you!!! It was me coming straight from the street to the computer and I was totally confused!
Reason: