How to validate freemargin before i send the order?

 

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())))
 
  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
Reason: