Margin hedged issue

Report any bugs with the Tickstory Lite software here. Please give as much detail as possible so the issue can be identified and resolved as soon as possible.
Post Reply
alimarmarchi
Posts: 2
Joined: Mon Nov 28, 2022 3:44 am

Margin hedged issue

Post by alimarmarchi »

Hi,

Suppose you have opened BUY positions and have used all your margin for these BUY positions; Now you don't have any free margin and in fact, the free margin is negative. In this case, my broker allows you to open SELL positions because the hedged margin is zero.
My problem is that I don't know which setting I have to change during "Export to MT4" to let my EA open SELL positions in such a situation. By default settings, my EA cannot open SELL and BUY when the free margin goes negative.

Appreciate your quick answer in advance.
Ali

tickstory
Posts: 4883
Joined: Sun Jan 06, 2013 12:27 am

Re: Margin hedged issue

Post by tickstory »

Hi Alimarmarchi,

We're not sure there is such a setting to alter the behavior of the Strategy Tester in this way. Your best bet to see on the MQL forums whether these modes of testing are at all possible.

Hope this helps.

alimarmarchi
Posts: 2
Joined: Mon Nov 28, 2022 3:44 am

Re: Margin hedged issue

Post by alimarmarchi »

Hi tickstory,

Thanks for your reply.
I'm sure that there is no such a setting in MQL4/MT4. And I'm pretty sure that this behavior that no position(either buy or sell) can be opened at a negative-margin situation is something that needs to be solved at the time of "Export to MT4". My reason for this expectation is that my broker (Coinexx) confirmed that opening a reverse position is possible (as I explained in my previous post). So the natural behavior/settings of MT4 allow traders to do so because otherwise, the broker couldn't allow this.
I think my only option is to completely understand what these 5 margin-related settings do in tickstory and finally solve it myself. Unfortunately, I couldn't find explanations for what those settings do and I would really appreciate it if you could write me back with the functionality explanations of each of the followings:
1-Margin calc
2-Margin init
3-Margin maint
4-Mgn hedged
5-Mgn divider

Many Thanks

tickstory
Posts: 4883
Joined: Sun Jan 06, 2013 12:27 am

Re: Margin hedged issue

Post by tickstory »

Hi Alimarmarchi,

Here is the only information we have that describes each of the margin fields:

Code: Select all

   
   int               leverage;           // Account leverage (default: 100). Same as: AccountLeverage()
   int               free_margin_mode;   // Free margin calculation mode { MARGIN_DONT_USE=0, MARGIN_USE_ALL=1, MARGIN_USE_PROFIT=2, MARGIN_USE_LOSS=3 }. Same as: AccountFreeMarginMode()
   int               margin_mode;        // Margin calculation mode { MARGIN_CALC_FOREX=0, MARGIN_CALC_CFD=1, MARGIN_CALC_FUTURES=2, MARGIN_CALC_CFDINDEX=3 }. Same as: MarketInfo(MODE_MARGINCALCMODE)
   int               margin_stopout;     // Margin Stop Out level (default: 30). Same as: AccountStopoutLevel()

   int               margin_stopout_mode;// Check mode for Stop Out level { MARGIN_TYPE_PERCENT=0, MARGIN_TYPE_CURRENCY=1 }. Same as: AccountStopoutMode()
   double            margin_initial;     // Initial margin requirement (in units). Same as: MarketInfo(MODE_MARGININIT)
   double            margin_maintenance; // Maintenance margin requirement (in units). Same as: MarketInfo(MODE_MARGINMAINTENANCE)
   double            margin_hedged;      // Hedged margin requirement for positions (in units). Same as: MarketInfo(MODE_MARGINHEDGED)
   double            margin_divider;     // Margin divider used for leverage calculation.
   char              margin_currency[12];// Margin currency. Same as: AccountCurrency().
   
Do note that all these settings are typically taken directly from your broker. If your broker is working a specific way, then it should pass on these settings to the Strategy Tester and, if the Strategy Tester is capable of it, replicate the same behavior.

The Strategy Tester doesn't necessarily replicate the full trading behavior of your broker, so it may be worthwhile posing the question on the MQL forums to see if what you want to do is possible. Alternatively, as you suggest, you can do your own tests by tweaking these settings and see if you get what you need (please let us know if you do find the answer!).

Thanks.

Post Reply