- Can someone help me before I loose my mind......agagghhhhhhh
- Frank EA and 10p3 EAs
- USD to Russian
- I doubt you are calculating the correct size if you are getting those errors.
- If you want help with your code, you need to post your code. Always post all relevant code (using Code button) or attach the source file.
We can't see your broken code.
-
Risk depends on your initial stop loss, lot size, and the value of the symbol. It does not depend on margin and leverage. No SL means you have infinite risk (on leveraged symbols). Never risk more than a small percentage of your trading funds, certainly less than 2% per trade, 6% total.
-
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.
-
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.)
-
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)
Is there an universal solution for Tick value? - Currency Pairs - General - MQL5 programming forum (2018)
Lot value calculation off by a factor of 100 - MQL5 programming forum (2019) -
You must normalize lots properly and check against min and max.
-
You must also check Free Margin to avoid stop out
-
For MT5, see 'Money Fixed Risk' - MQL5 Code Base (2017)
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.
-
- I doubt you are calculating the correct size if you are getting those errors.
- If you want help with your code, you need to post your code. Always post all relevant code (using Code button) or attach the source file.
We can't see your broken code.
-
Risk depends on your initial stop loss, lot size, and the value of the symbol. It does not depend on margin and leverage. No SL means you have infinite risk (on leveraged symbols). Never risk more than a small percentage of your trading funds, certainly less than 2% per trade, 6% total.
-
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.
-
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.)
-
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)
Is there an universal solution for Tick value? - Currency Pairs - General - MQL5 programming forum (2018)
Lot value calculation off by a factor of 100 - MQL5 programming forum (2019) -
You must normalize lots properly and check against min and max.
-
You must also check Free Margin to avoid stop out
-
For MT5, see 'Money Fixed Risk' - MQL5 Code Base (2017)
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.
-
I attached the code of the EA as a source file below. Note that I am calculating risk correctly as it works as designed around 75% of the time. Thank you for your help.
- If you want help with your code, you need to post your code. Always post all relevant code (using Code button) or attach the source file.
We can't see your broken code.
-
Code Button (Alt+S)
- 2019.03.05
- www.mql5.com
I attached the code of the EA as a source file below. Note that I am calculating risk correctly as it works as designed around 75% of the time. Thank you for your help.
I would say that sometimes your SL doesn’t work… you should print your SL value and your Resistance() and Suport() functions results …
Sorry I dont know what this means. Im new to learning MQL5 language and used EAbuilder.com to make this. Im thinking it could be an error with how EA builder wrote the code for TP as S or R and the SL as a 1:1.
-How do I check function results
-Is there another way I can go in and write code for The TP as the 20HR High (longs) and 20HR low (shorts) and a SL as a 1:1 function of the TP.
I appreciate everyones help. This is a huge obstacle as im finally making profits as an algo trader and this is my last roadblock in an otherwise good system.
Also read the following to improve your code ...
The checks a trading robot must pass before publication in the Market
MetaQuotes, 2016.08.01 09:30
Before any product is published in the Market, it must undergo compulsory preliminary checks in order to ensure a uniform quality standard. This article considers the most frequent errors made by developers in their technical indicators and trading robots. An also shows how to self-test a product before sending it to the Market.
Just downloaded and had a look at this first code file you posted and I see that it was generated with EABuilder. Most generators make very bad code and mess things up quite a bit.
Forum on trading, automated trading systems and testing trading strategies
William Roeder, 2023.04.02 19:56
Yep. Stop using ChatGPT.
Help needed to debug and fix an AI EA - Trading Systems - MQL5 programming forum (2023)ChatGPT (the worst), “Bots Builder”, “EA builder”, “EA Builder Pro”, EATree, “Etasoft forex generator”, “Forex Strategy Builder”, ForexEAdvisor (aka. ForexEAdvisor STRATEGY BUILDER, and Online Forex Expert Advisor Generator), ForexRobotAcademy.com, forexsb, “FX EA Builder”, fxDreema, Forex Generator, FxPro, Molanis, Octa-FX Meta Editor, Strategy Builder FX, Strategy Quant, “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 Code button) and state 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.
ChatGPT
- Even it says do not use it for coding.*
- Mixing MT4 and MT5 code together.
- Creating multiple OnCalculate/OnTick functions.
- OnCalculate returning a double.
- Filling buffers with zero in OnInit (they have no size yet). Setting buffer elements to zero but not setting Empty Value to correspond.
- Calling undefined functions.
- Sometimes, not using strict (MT4 code).
- Code that will not compile.
- Creating code outside of functions.*
- Creating incomplete code.*
- Initialization of Global variables with non-constants.*
- Assigning a MT5 handle to a double or missing the buffer and bar indexes in a MT4 call.*
- Useing MT4 Trade Functions without first selecting an order.*
- Uses NULL in OrderSend.*
bot builder Creating two OnInit() functions.* EA builder EATree Uses objects on chart to save values — not persistent storage (files or GV+Flush.) No recovery (crash/power failure.) ForexEAdvisor
- Non-updateing global variables.
- Compilation errors.
- Not checking return codes.
- Not reporting errors.
FX EA Builder
- Not checking return codes.
- Loosing open tickets on terminal restart. No recovery (crash/power failure.)
- Not adjusting stops for the spread .*
- Using OrdersTotal directly.
- Using the old event handlers.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use