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
Algorithm: issue the 'ChartOpen' command -> check the value, if the value is greater than '0' -> try the template using the 'ChartApplyTemplate' command.
Code: ChartOpen ChartApplyTemplate.mq5
Expert Advisor
Code: Example Bullish Bearish.mq5
To get OHLC from the advisor, it is optimal to request CopyRates to the array of the MqlRates structure. Apply to the array
- now in the 'rates' array element [0] corresponds to the rightmost bar on the chart.
Result:
Thanks for helping me, it works fine. But sometimes the strategy of my logic is executed after another 3 candles or so and the ChartOpen ChartApplyTemplete is executed again and the same chart is opened again, how can i code it so that if chart already is open dont open again, Thank you
Keep records of open charts (more precisely, keep records of not chart numbers, but records of actions: the symbol "such and such", the timeframe "such and such" is already open.
Code: Example Bullish Bearish.mq5
To get OHLC from the advisor, it is optimal to request CopyRates to the array of the MqlRates structure. Apply to the array
- now in the 'rates' array element [0] corresponds to the rightmost bar on the chart.
Result:
Not regular bullish or bearish candles, small bodied candles with large wicks on both sides
You have to take my sample and make changes from it yourself. I can't see your code. I do not see your desire to code.
This works fine when i test on a script and run, but i use it in my logic of my expert advisor and even if the condition is false, the code is executed without any problems
im using bollinger bands and before trading i check if the distance between upper and lower bollinger band is minimum 30 pips
This works fine when i test on a script and run, but i use it in my logic of my expert advisor and even if the condition is false, the code is executed without any problems
What is your question?
Example: how to get the value of the iSAR indicator in an advisor.
Code: iSAR Get Value.mq5
ATTENTION: In OnInit we get the indicator handle (type 'int') - we do it ONCE. Further, we get the indicator values using CopyBuffer .
Advisor code:
Result:
Problem: there can be only one position at a time. The check is the same for netting and hedge accounts.
We check if there is a position by symbol, while there is no check by Magic number.
Code: IsPositionExists.mq5