Download MetaTrader 5

How to validate freemargin before i send the order?

To add comments, please log in or register
Having troubles understanding the code? Articles can help you!
Sherif Hasan
7290
Sherif Hasan 2015.10.22 17:27 

Currently i use the following code to check freemargin before send the order

if(AccountFreeMarginCheck(Symbol(),OP_BUY,Lots)<=0 return;  

But some brokers has StopoutLevel, so how to validate for the situaltion?

tried following code. but not validating.

if (((AccountStopoutMode() == 1)
&& (AccountFreeMarginCheck(Symbol(), OP_BUY, Lots) > AccountStopoutLevel()))
|| ((AccountStopoutMode() == 0)
&& (((AccountFreeMarginCheck(Symbol(), OP_BUY, Lots)/AccountEquity()) * 100) > AccountStopoutLevel())))
whroeder1
14530
whroeder1 2015.10.22 20:07  
  1. You place the stop where it needs to be - where the reason for the trade is no longer valid. E.g. trading a support bounce the stop goes below the support.
  2. Account Balance * percent = RISK = |OrderOpenPrice - OrderStopLoss| * OrderLots * DeltaPerlot (Note OOP-OSL includes the SPREAD)
  3. Do NOT use TickValue by itself - DeltaPerlot
  4. You must normalize lots properly and check against min and max.
  5. You must also check FreeMargin to avoid stop out
To add comments, please log in or register