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

 
I'll be back tomorrow... bye. Thank you!
 
borilunad:


There's only one thing left to do, invite him to invest our accounts! :))

Agreed! Especially - the investment account is already ready! :-)
 

Hello.

We need the function that calculates the lot in increments. What would be possible to adjust, for example, for every 500 come increase lots

So depo 1000 - lot 0.1

Depo 1500 - lot 0.15

2000 - lot 0.2

Please post the function.

 

Good morning! What does the gap condition mean? When the price goes 35 pips up, my stoploss moves 10 pips below the order, i.e. its distance from the price is 45 pips.

Or what kind of gap are we talking about?

 
T-G:

Hello.

You need the function to calculate the lot incrementally. That would be possible to adjust, for example, for every 500 lot increase

So depo 1000 - lot 0.1

Depo 1500 - lot 0.15

depo 2000 - lot 0.2

Please post the function.


It is possible without functions:

extern double depo = 1000.0;

extern double lot    = 0.1; 

double Lot; 

//--------------------------------

int start()

//--------------------------------

double Equ = AccountEquity();

Lot  = NormalizeDouble(lot*Equ/depo,2);
 
T-G:

Hello.

We need the function that calculates the lot incrementally. That would be possible to adjust, for example, for every 500 lot increase

So depo 1000 - lot 0.1

Depo 1500 - lot 0.15

Depo 2000 - lot 0.2

Please post the function.

You could do it this way:

//IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII+
//|  Автор : TarasBY, taras_bulba@tut.by                                              |
//+-----------------------------------------------------------------------------------+
//|        Расчитываем размер лота (ступенчато)                                       |
//IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII+
double fGet_Lots (double fd_BeginLot = 0.1,        // начальный размер лота
                  int fi_BeginDepo = 1000,         // начальный размер депозита
                  int fi_IncrementDepo = 500,      // приращение депозита
                  double fd_IncrementLot = 0.05)   // приращение лота
{
    double ld_Balance = AccountBalance();
//----
    if (ld_Balance < fi_BeginDepo + fi_IncrementDepo) return (fd_BeginLot);
    int li_K_Lot = (ld_Balance - fi_BeginDepo) / fi_IncrementDepo;
//----
    return (fd_BeginLot + fd_IncrementLot * li_K_Lot);
}
//IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII+

just don't forget to normalize the lot.

 
Issued a ticket above the start. Now it only modifies one order, but that's another error! Otherwise, the variable was declared inside the ifs.
 
Dimka-novitsek:

Good morning! What does a gap condition mean? When the price goes 35 pips up, my stoploss moves 10 pips below the order, i.e. its distance from the price is 45 pips.

Or what kind of gap are we talking about?


Good morning, refreshed head!

While we are sending, receiving and executing a modification order, the price is not standing still, up or down, who knows!

#include <stderror.mqh>
#include <stdlib.mqh> 
//-------------------

extern int prev = 30;//зазор! Для 5-знака!
extern int sl   = ??;
extern int tp   = ??;
//------------------
int start()
{
//------------------
//----------------------/  Stops & Trailing  \----------------------\\
  for(int i = 0; i < OrdersTotal(); i++)
  {
    if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
    {
      if(OrderSymbol() != Symbol() && OrderMagicNumber() != Magic) continue;
      if(OrderCloseTime() != 0) continue;
      if(OrderType() == OP_BUY)
      {
        if(OrderStopLoss() < OrderOpenPrice() || OrderStopLoss() == 0)
        {
//----------------------
          if(OrderStopLoss() == 0)
          if(Bid < OrderOpenPrice() && Bid > NormalizeDouble(OrderOpenPrice()-sl*Point+prev*Point,Digits))
          if(Bid > NormalizeDouble(OrderOpenPrice()-sl*Point+prev*Point,Digits))
          {
            SL = NormalizeDouble(OrderOpenPrice()-sl*Point,Digits);
            if(Bid < NormalizeDouble(OrderOpenPrice()+tp*Point-prev*Point,Digits))
            {
              TP = NormalizeDouble(OrderOpenPrice()+tp*Point,Digits);
              ModifyOrder(OrderTicket(),OrderOpenPrice(),SL,TP,0,Blue);return(0);
        } } }
//-----------------------
//------------------------/  Modify Order  \------------------------\\
void ModifyOrder(int ticket,double price,double stoploss,double takeprofit,datetime e,color arrow_color)
{
  int ModifyCnt = 0, err;
  while(ModifyCnt < 3)
  {
    if(OrderModify(ticket,NormalizeDouble(price,Digits),NormalizeDouble(stoploss,Digits),
    NormalizeDouble(takeprofit,Digits),0,arrow_color))
    ModifyCnt = 3;
    else err = GetLastError();
    if(err > 0)
    { 
      Print(ModifyCnt," #",ticket," Error modifing order: (", err , ") " , ErrorDescription(err));
      Sleep(3000); RefreshRates(); ModifyCnt++;
} } }

And for Sall it's appropriately the other way round! Good luck figuring it out without commentary, which is redundant in my opinion!

And, please, look in the Russian explanatory dictionary, so that your posts are more readable.

I look it up sometimes, as I've been thinking in a different language for over 10 years now and am not up to date with your "innovations"... :))

 
Dimka-novitsek:

Good afternoon! Order modification error 4051. I've been thinking for an hour. Seems to be the right parameter there!!! Briefly, note by note. The parameter price is the opening price of the order, OrderOpenPrice(), it is standard.

Our stop price is 10 points below the open price, and we have memorized the price. We store it in the variable tsena when opening the order.

We have two orders, one with a profit and one without. It seems to be clear. What is the error? What else could it be?

Yes, the condition seems to be clear, although it is not really relevant. I.e., price has moved by 30 points, the condition worked (tsena+30*Point).

We set perenos=true once; These conditions actually seem to work.

I don't know how to think about it.

Actually Wear once perenos=true; These conditions didn't have to be observed, as it didn't wear anywhere.

This line:

        int tacket = OrderSend (Symbol(), OP_BUY, lot, NormalizeDouble (Ask, Digits), 5, NormalizeDouble (Ask - (35 * Point), Digits), 
            NormalizeDouble (Ask + (45 * Point), Digits), NULL, 450, 0, CLR_NONE);

and then using (not on this tick) this variable to modify an order with tick = 0 (the variable will be reset), shows that you don't know the basics - start with the concepts of local and global variables.

And opening a copy of just opened order after 2 seconds - THIS IS THE HIGHEST PILOTAGE!!! - i'm crying... :)))

 
THANK YOU!!!