Your code logic is strange. LORT is a global variable you set in OnTradeTransaction() but in the posted code you taking the first trend line that match your condition without checking it's the one corresponding the the trade from OnTradeTransaction. You should not assume that your code (EA) and the chart display are synchronized, they are not and at full speed it matters.
Alain Verleyen #:
Your code logic is strange. LORT is a global variable you set in OnTradeTransaction() but in the posted code you taking the first trend line that match your condition without checking it's the one corresponding the the trade from OnTradeTransaction. You should not assume that your code (EA) and the chart display are synchronized, they are not and at full speed it matters.
Your code logic is strange. LORT is a global variable you set in OnTradeTransaction() but in the posted code you taking the first trend line that match your condition without checking it's the one corresponding the the trade from OnTradeTransaction. You should not assume that your code (EA) and the chart display are synchronized, they are not and at full speed it matters.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
I have this code that runs onTick on a EA (normally it runs only on new candles, but to isolate the problem it's running onTick).
LORT is a enum which value is set OnTradeTransaction based on the deal reason and other logic.
Basically
'was_take' is DEAL_REASON_TP,
'was_stop' is DEAL_REASON_SL,
'was_zero' is if the profit value is zero to a degree of error.
The problem is that when the speed is fast the colors don't apply properly while in normal speed the colors are ok. My objective is to change the default trendline colors to match the result of the last closed operation: red for SL, green for TP and wheat for near zero profit.
Running each tick
Max speed colors are wrong, see file "SPEED BUG.jpg"
Fast but not so, colors are how I expect, see file "SPEED OK.jpg"
Is there something I can do to avoid this problem (other than not using max speed) or is it that the chart runs faster than my EA can process my function?
Thanks