Trading with insufficient funds - error message

To add comments, please log in or register

I have created a bunch of EAs using Strategy Quant and am backtesting these in MT4 on a demo account.

Originally, i wasnt getting any trades created at all and i checked the journal, it said there was not enough money on the account. I chucked in a million demo pounds and the trades were created, so the strategies execute as expected. However, on a real account obviously this will be different...

Each EA will trade only 1% of available value, so if i put in £100 per strategy, thats £1 per trade, plus the margin requirements of the ccy pair, but still no trades. Also doesnt work on £1000 which seems odd - i can place a trade manually but the error seems only with the EA.

Unless there is a minimum set somewhere by the broker (but i doubt this would come up in the MT4 journal) - how can i figure out the minimum amount i need to make the EA work?

And i appreciate you dont know the details of the EA - i can attach if useful, but my question really relates to whether there is somewhere in MT4 where i can find out more info on the error message and how that deficit leading to it is calculated.

Thank you for your advice!
Catalin Zachiu
Catalin Zachiu  
Try in the tester with 100 $ start balance and lower that 1% to 0.1 , 0.01 , 0.001 risk and see if it opens trades.
William Roeder
William Roeder  
MFinch: bunch of EAs using Strategy Quant
  1. EA builder, EATree, Etasoft forex generator, Forex Strategy Builder, FOREXEADVISOR STRATEGY BUILDER, FX EA Builder, fxDreema, FxPro, Molanis, Online Forex Expert Advisor Generator, Quant, Strategy Builder FX, Visual Trader Studio, MQL5 Wizard, etc., are all the same. You will get something quick, but then you will spend a much longer time trying to get it right, than if you learned the language up front, and then just wrote it.
    • Since you haven't learned MQL4/5, therefor there is no common language for us to communicate.
      If we tell you what you need, you can't code it.
      If we give you the code, you don't know how to integrate it into yours.
      We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem, but we are not going to debug your hundreds of lines of code. You are essentially going to be on your own.

    • EA builder makes bad code counting up while closing multiple orders.
      EA builder makes bad code Bars is unreliable (Max bars in chart), volume is unreliable (miss ticks.) Always use time.
      EA builder makes bad code, not adjusting for 4/5 digit brokers, TP/SL and slippage.
      EA builder makes bad code, not adjusting for ECN brokers. pre-Build 500)
      EA builder makes bad code, not
      checking return codes.
      EATree uses objects on chart to save values — not persistent storage (files or GV+Flush.) No recovery (crash/power failure.)

    • FX EA Builder makes bad code, not checking return codes.
      FX EA Builder makes bad code, loosing open tickets on terminal restart. No recovery (crash/power failure.)
      FX EA Builder makes bad code, not adjusting stops for the spread.
      FX EA Builder makes bad code, using OrdersTotal directly.

    • FOREXEADVISOR STRATEGY BUILDER makes bad code, non-updateing global variables.
      FOREXEADVISOR STRATEGY BUILDER makes bad code, compilation errors.
      FOREXEADVISOR STRATEGY BUILDER makes bad code, not checking return codes.

    Learn to code it, or pay someone (Freelance) someone to code it.
              Hiring to write script - General - MQL5 programming forum

  2. If you are worried about margin and leverage, you are not controlling your risk. Never risk more than a small percentage of your account, certainly less than 2% per trade, 6% total. In code (MT4): Risk depends on your initial stop loss, lot size, and the value of the pair. It does not depend on margin and leverage.
    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. AccountBalance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the spread, and DeltaPerLot is usually around $10/pip but it takes account of the exchange rates of the pair vs. your account currency.)
    3. Do NOT use TickValue by itself - DeltaPerLot and verify that MODE_TICKVALUE is returning a value in your deposit currency, as promised by the documentation, or whether it is returning a value in the instrument's base currency.
                MODE_TICKVALUE is not reliable on non-fx instruments with many brokers - MQL4 programming forum 2017.10.10
                Is there an universal solution for Tick value? - Currency Pairs - General - MQL5 programming forum 2018.02.11
                Lot value calculation off by a factor of 100 - MQL5 programming forum 2019.07.19
    4. You must normalize lots properly and check against min and max.
    5. You must also check FreeMargin to avoid stop out

    Most pairs are worth about $10 per PIP. A $5 risk with a (very small) 5 PIP SL is $5/$10/5 or 0.1 Lots maximum.

To add comments, please log in or register