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

 

Couldn't we calculate separately for each position opened subsequently and then sum it up? There is a reason why

AccountFreeMarginCheck(sy, op, lot); 

The symbol, trade operation and lot are passed to it... You may calculate the margin for each position separately, decide on the overlapping positions and print the result.

Write a script that will print both your calculation and what is returned by your brokerage company. And compare it...

MODE_MARGINHEDGED 31 Margin charged on overlapped positions per 1 lot


So calculate your lots. Count the number of lots overlapped by the value returned by MODE_MARGINHEDGED
Remaining unoverlapped count by the value returned by MODE_MARGINREQUIRED

 

I have encountered a problem with MRC. For example, when I want to execute this code :

double OpPriceF5B = OrderClosePrice()- OrderOpenPrice();

I want to know difference between opening price and swap price.

How do I do that?

I'm trying to figure it out like this:

for (i=1; i <=OrdersTotal();i++){
    if (OrderSelect(i-1,SELECT_BY_POS)==true){
       if (OrderType()== OP_BUY ){
          if (OrderMagicNumber() == Magic_N_F5){
             double OpPriceF5B = OrderClosePrice()- OrderOpenPrice();
          }
       }      
    }   
}
 

Experiment with AccountFreeMarginCheck():

- BUY order open on the terminal

- Balance: 94919.36 Funds: 94921.16 Collateral: 1273.39 Free: 93647.07 Level: 7454.15%

- I ask: AccountFreeMarginCheck(Symbol(),OP_BUY,0.1) - gives remainder of level Free

- I ask: AccountFreeMarginCheck(Symbol(),OP_SELL,0.1) - gives the balance from the Funds level


In general, my problem can not be solved so.

But my question (task) is the following: several orders should be opened simultaneously, and they should remain open like this

the first one - sell with the lot 0.10

the second one - buy with lot 0.26

third - sell lot 0.43
fourth - buy lot 0.72

The fifth - sell by lot 1.19, etc.

Price 1.2737, leverage 100, minimum lot 0.1

There is a possibility that on some cycle of the next order placing, the Stop Out will come.

It means we should calculate this worst case scenario using the DC's methodology, of course. And make a conclusion: up to what total amount of lots on the orders opened in the specified order we can go without being afraid of getting into a Stop Out? That is "at the beginning of the beginning" :) Calculate the total margin for the orders that may be opened. Again, the order of opening is shown above and the order of lots for each order is known in advance.

 
ikatsko:

Experiment with AccountFreeMarginCheck():

- BUY order open on the terminal

- Balance: 94919.36 Funds: 94921.16 Collateral: 1273.39 Free: 93647.07 Level: 7454.15%

- I ask: AccountFreeMarginCheck(Symbol(),OP_BUY,0.1) - gives remainder of level Free

- I ask: AccountFreeMarginCheck(Symbol(),OP_SELL,0.1) - gives the balance from Funds level


In general, my problem can not be solved so.

But my question (task) is the following: several orders should be opened simultaneously, and they should remain open like this

the first one - sell with the lot 0.10

the second one - buy with lot 0.26

third - sell lot 0.43
fourth - buy lot 0.72

The fifth - sell by lot 1.19, etc.

Price 1.2737, leverage 100, minimum lot 0.1

There is a possibility that on some cycle of the next order placing, the Stop Out will come.

It means we should calculate this worst case scenario using the DC's methodology, of course. And make a conclusion: up to what total amount of lots on the orders opened in the specified order we can go without being afraid of getting into a Stop Out? That is "at the beginning of the beginning" :) Calculate the total margin for the orders that may be opened. I should repeat, the order of opening is shown above and the order lot sizes for each order are known in advance.

Let us think about it.

All Bai: 0.26 + 0.72 = 0.98.

All Balls: 0.1+0.43+1.19 = 1.72

Overlapped: number of lots of Bai is less than the number of lots of Sell, so the overlapped number of lots is equal to the number of Bai lots = 0.98

Remaining unidirectional Sell lots: 1.72-0.98 = 0.74

So what do we do? Add Bai's and subtract Sell's: -0.1+0.26-0.43+0.72-1.19= -0.74 If minus, then we have a unidirectional Sell

For the overlapped ones, take value from MODE_MARGINHEDGED and multiply by the number of overlapped lots.

And for the unidirectional ones, take value of MODE_MARGINREQUIRED and multiply by MathAbs(amount of unidirectional lots);

Well, and everything else, too, try to factor in ...

SZY. I was not thinking long here - so between cases - I scribbled - I admit omissions, so take only as a possible course of action... :)

 

So... the logic becomes clear. Thank you! Let's try to check it now.

By the way, I did an experiment on the DEMO:

first BUY with 0.1 lot price 1.27339 - showed Bail=1273.39. Ie 0.1 * 1000000 * 1.27339/100.

The second SELL by lot 0.26 price 1.27039 -showed total Bail=3305.18. And it is very similar to this 0.26*1000000*1.27039/100=3303.01 ??? Weirdness?

It turns out that the deposit is taken from the maximum number of lots that overlap the orders opened in the opposite direction?

Waiting for the next BUY to open

 
eugggy:
Good afternoon to all. Is there a clear definition of the term operator or is it like "what is the meaning of life" (you can't explain it)?

:) An operator as such is an elastic term - he can also be the operator of a moonshine machine... :)

You would ask questions in the context in which you want the meaning of the word. Hopefully not too long a sentence :)

 
eugggy:
Good afternoon all. Is there a clear definition of the term operator or is it like "what is the meaning of life"(can't be explained)?

=Commando. See wikipedia.

https://ru.wikipedia.org/wiki/%D0%9E%D0%BF%D0%B5%D1%80%D0%B0%D1%82%D0%BE%D1%80_(%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%BC%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5)

 
ikatsko:

So... the logic makes sense. Thank you. Let's try to check it now.

By the way, I did an experiment on the DEMO:

first BUY with 0.1 lot price 1.27339 - showed Bail=1273.39. Ie 0.1 * 1000000 * 1.27339/100.

the second SELL lot 0.26 price 1.27039 -showed total Bail=3305.18. And it is very similar to this 0.26*1000000*1.27039/100=3303.01 ??? Weirdness?

It turns out that the deposit is taken from the maximum number of lots that overlap the orders open in the opposite direction?

Waiting for the next BUY to open

Eh... I wish I had time to think it over... :) It's an interesting task, but I'm pressed for time.

I think if there's a resemblance, but not a similarity, it's not true. It's just an oddity... :) Try to calculate the difference for the maximum lot...

For such "strangeness", the Dezlas will get their legs ripped off by serious clients... :)

You have to think in a different direction...

Waiting for your next order :)

 
eugggy:
(chuckling): (chuckling): (as the operator of a moonshine machine)). If I've understood correctly, the operator (in MQL4 as well) is the smallest and most meaningful expression in program code.... something like this.

О ... mother-my-grandmother... Can't you live without it? Standing in a hammock? Why complicate your life?

Read it here... and that's the end of it...

 

However, how sometimes simple questions baffle :) (I mean the operator).

I found the most accessible (simple) definition in BSE:

"In computer science, a prescription... intended to specify some completed action..."

And here in the documentation:

"An operator is a part of a program... prescribing a certain order of information conversion."

So the function behaves the same way...

Interesting.