[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 39

 
forexnew:

If you initially defined the ratio of StartBalance to StarLots according to the set risks, then the equity value has to be determined:

if(AccountEquity()<StartBalance) Top-up = (AccountBalance()+(StartBalance-AccountEquity()))*New Lot/StarLots

This is excluding AccountCredit(). If I understand you correctly, of course.


A formula is already given there:

You cancalculate the required (additional) volume using the formula: V(extra)= (SumInv / Equity) * Lots

Where:
SumInv - Amount of new addition - its size should be somehow known programmatically calculated for the specific moment of time (previously known),
Equity - Equity of the account at the same point in time - this value is obtained from the function getting information on the trading account:

double AccountEquity( ) 
Возвращает сумму собственных средств для текущего счета.  


Lots - Volume of assets purchased earlier (at the start), let's say 1 lot.
This means that in order to correct positions, you need to know the value of the variableSumInv...

What is the best way to solve the programmatic calculation of this variable, provided it is not equal to zero?

 
Roman.:


The formula is already given there:

You cancalculate the required (additional) volume using the formula: V(extra) = (SumInv / Equity) * Lots

Where:
SumInv - Amount of new addition - its size should be somehow known programmatically calculated for the specific moment of time (previously known),
Equity - Equity of the account at the same point in time - this value is obtained from the function getting information on the trading account:


Lots - Volume of assets purchased earlier (at the start), let's say 1 lot.
This means that in order to correct positions, you need to know the value of the variableSumInv...

What is the best way to solve the programmatic calculation of this variable, as long as it is not zero?

I don't know what to base your calculations on if you don't know how many lots you want to increase your starting lot by. This is purely a human factor:

SumInv = "I want to increase my balance by x quid" + StartBalance-Equity

Or do you not know the optimal starting balance to rely on? It has to be calculated based on the size of stops and the leverage.

In my EA, all calculations are based on the size of stops, hence the optimal starting balance (it is not necessarily equal to the initial balance), and then there is an automatic calculation of the starting lot.


 
forexnew:

I don't know what to start with when you don't know how many lots you want to increase the starting lot. This is purely a human factor:

SumInv = "I want to increase my balance by x quid" + StartBalance-Equity

Or don't you know the optimal starting balance? It has to be calculated from the size of stops and leverage.

In my EA, all calculations are based on the size of stops, hence the optimal starting balance (it is not necessarily equal to the initial balance), and then goes automatic calculation of the starting lot.


Everything is known. The initial lot is increased in proportion to the deposits made according to the formula above. Once again, read the link to read the information - adjustments to the volume of the position when you deposit/withdraw funds.
You, if you're on the topic - just try to answer the question: How to determine the software (using an algorithm, or any formulas, if you can not directly to the account information function ) - were there any additions to a trading account at what time (previously known) during the day (say, at 00 o'clock). The other variables for calculating the additional volume in the formula above, required for topping up to the previous (starting) one, are known.

Guys, tell me...

 
Roman.:

It's all known. The initial lot is increased in proportion to the deposits made according to the formula above. Once again, read the link info - adjustments to position volume when you deposit/withdraw funds.
You, if you're on the topic - just try to answer the question: How to determine the software (using an algorithm, or any formulas, if you can not directly to the account information function ) - were there any additions to a trading account at any (previously known) time during the day (say at 00 o'clock). The other variables for calculating additional volume in the formula above, required for topping up to the previous (starting) one, are known.

Guys, a hint...

Now it is clear. Suppose we need to calculate programmatically whether there has been a refill/withdrawal in the last day. I am attaching the indicator. You only need to enter the balance that was at the beginning of the calculation time period and the number of days of calculation. I hope now I understand you correctly.

Files:
balans_9.mq4  6 kb
 

Hello all!

I'm with my indicator again. On the advice of my old friends, I tried to construct a loop that calculates the value of a line point and fill the array of the indicator with these values.

It seems to get it right one by one. Together it hangs the terminal :=(

//for (i=Vnf2;i>0;i--)

// {int k=Vnf2;

// ArrayResize(Buf_DN,Vnf2+1);

// Buf_DN[i]= EquationDirect(Vnf2,VMF2,Vnf1,VMF1,k);

// k--;

// }

 

A small mistake, but it still hangs in this variant

int k=Vnf2;

for (i=Vnf2;i>0;i--)

// {

// ArrayResize(Buf_DN,Vnf2+1);

// Buf_DN[i]= EquationDirect(Vnf2,VMF2,Vnf1,VMF1,k);

// k--;

// }


 
Вопрос:  как сделать так ,чтобы эксперт мог открыть только одну позицию?

int NumberOfOrders(string sy="", int op=-1, int mn=-1) {
  int i, k=OrdersTotal(), ko=0, ot;

  if (sy=="0") sy=Symbol();
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      ot=OrderType();
      if (ot>1 && ot<6) {
        if ((OrderSymbol()==sy || sy=="") && (op<0 || ot==op)) {
          if (mn<0 || OrderMagicNumber()==mn) ko++;
        }
      }
    }
  }
  return(ko);

}

использую это примерно так:

if(NumberOfOrders(NULL)==0)
            {
            Print("Вошли в цикл");
            
             
                  Print("Покупаю");
                  NumderOrder=OrderSend(Symbol(),OP_BUY,lot,Ask,3,Ask-50*Point,Ask+50*Point,"1",0,0,Red);
                  Print(GetLastError());

                  }

В результате он все равно открывает несколько подряд не закрыв старую. Не могу понять в чем дело. Помогите плиз.

 
nuan:
if (ot>1      У ордеров  Buy ot=0, мож в этом дело?
 
nuan:
You are using Igor Kim's functions. He has definitions for orders and positions. Orders are pending orders and positions are market positions.
You are trying to calculate the number of pending orders, not the number of open market positions.
 
Thank you very much.
Reason: