
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
The code you provided does not check if an order is already open or set stoploss and takeprofit
Ok, here's your more complex code:
Simple script: it opens a BUY position. In this case, you can set Stop loss and Take profit.
I've coded the EA and it works fine most of the time, stoploss and takeprofit are set perfectly, i noticed that sometimes the EA glitches and it keeps running on every tick. For example, i had a trade on CADJPY and i had stoploss set at 100 pips and take profit at 250 pips, i also had a print stated coded into the EA, the EA would open the trade and set stoploss a tick above and takeprofit a tick below on a sell trade or vice versa on a buy trade and the console would print every on every single tick, its not a problem with JPY pairs and the same problem occured with other pairs as well, any fix ?
It is necessary to strictly control the chain: signal - trade order - execution of a trade order.
I gave an example in
Forum on trading, automated trading systems and testing trading strategies
How to start with MQL5
Vladimir Karputov, 2020.10.22 20:31
We catch the transaction
Code: We catch the transaction.mq5
This is a blank - an example of how to control a trading signal. This code avoids the situation: opening multiple positions. How it works: after a trade order is generated, we increase the 'SPosition' structure. In OnTick, if 'SPosition' is greater than zero, go to the block for opening positions. In OnTradeTransaction, we monitor the situation when a position appears exactly on our signal.
Can i send you my code through a personal message and could you tell me whats wrong with it ?
Not.
This is my code excluding the logic, i know its very shabby but i need help figuring out what is wrong with it as i am still new to programming
Your code won't compile. Your code contains a huge bunch of errors.
And one more thing - you are committing the BIGGEST MISTAKE: you CREATE an indicator handle AT EVERY TICK! Remember: in MQL5, the indicator handle MUST BE CREATED ONCE !!! And you need to do this in OnInit () !!!
Your code won't compile. Your code contains a huge bunch of errors.
That's the thing, it compiles fine, the only errors i get are to check OrderSend, that's why i dont understand what im doing wrong, if you could guide me as to how i can fix it, thank you
That's the thing, it compiles fine, the only errors i get are to check OrderSend, that's why i dont understand what im doing wrong, if you could guide me as to how i can fix it, thank you
Forum on trading, automated trading systems and testing trading strategies
How to start with MQL5
Vladimir Karputov, 2021.03.05 05:24
Your code won't compile. Your code contains a huge bunch of errors.
And one more thing - you are committing the BIGGEST MISTAKE: you CREATE an indicator handle AT EVERY TICK! Remember: in MQL5, the indicator handle MUST BE CREATED ONCE !!! And you need to do this in OnInit () !!!
Receiving data from an indicator in an MQL5.
Receiving data from an indicator in an MQL5.
Thanks a ton, is everything else in the code fine ?
im using multiple symbols and timeframes through loops, declaring handles in OnInit will not work without looping