Abdul Wahab Mughal #: No the problem doesn’t correlate with the conditions combined being too rare.
As what’s happening is let’s say RSI, BB and MA1 are enabled only. The expert after being placed on chart will open trades even when RSI and BB are not met. However I noticed that whether it’s a buy or sell is following the MA1 logic.
So it seems the Moving Average logic is somehow overriding the other indicators logic. Or is being prioritised. It could be due to using MA1Direction variable in the firing block of code.
For the second version. Let’s say only RSI is enabled. The expert doesn’t trade at all. I’ve tried all the indicators individually, I’ve tried different combinations of enabled indicators and I’ve tried all together. No orders are being fired at all.
Even if I just modify the original code like below expert stops trading completely.
Just one change at RSI stops it from working completely.
Okay a separate question if you were trying to use 4 indicators and achieve the same desired function as me How would you code it? Maybe that would be a good starting point to figure the issue out
Kind Regards
The simplest way would be to assign a maximum score at the beggining based on how many indicators are on .
Then if an indicator fires you add one to the score . (you set the score to 0 before starting the check).
The simplest way would be to assign a maximum score at the beggining based on how many indicators are on .
Then if an indicator fires you add one to the score . (you set the score to 0 before starting the check).
By using a tally wouldn’t that mean that I can’t disable indicators. So if one day I wanted to use just RSI or just BB I can’t as the tally is hard coded.
The code works and combines the RSI and BB when they’re only enabled. The problem is with Moving Averages logic. How would you code a single moving average expert.
Let’s say just MA1, would you use the same logic I have been taught. Which includes the MaDirection Variable?
Could you send an example for Buy or Sell logic of how you would do conditions for moving averages?
By using a tally wouldn’t that mean that I can’t disable indicators. So if one day I wanted to use just RSI or just BB I can’t as the tally is hard coded.
The code works and combines the RSI and BB when they’re only enabled. The problem is with Moving Averages logic. How would you code a single moving average expert.
Let’s say just MA1, would you use the same logic I have been taught. Which includes the MaDirection Variable?
Could you send an example for Buy or Sell logic of how you would do conditions for moving averages?
Kind Regards
it would not be hardcoded . The user enables or disables indicators .
Then the initialization counts the enabled indicators . That is the max tally
it would not be hardcoded . The user enables or disables indicators .
Then the initialization counts the enabled indicators . That is the max tally
With Fast and Slow ma ? or price ?
Using price for ma.
Ah I see so you’d set the maximum tally number needed based on enabled indicators during Initialisation.
I’m not sure how to do that could you provide a code template for your suggestions, just for what would need to go in Oninit and either Buy or Sell based on your recent suggestion.
Ah I see so you’d set the maximum tally number needed based on enabled indicators during Initialisation.
I’m not sure how to do that could you provide a code template for your suggestions, just for what would need to go in Oninit and either Buy or Sell based on your recent suggestion.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
No the problem doesn’t correlate with the conditions combined being too rare.
Even if I just modify the original code like below expert stops trading completely.
Just one change at RSI stops it from working completely.
Okay a separate question if you were trying to use 4 indicators and achieve the same desired function as me How would you code it? Maybe that would be a good starting point to figure the issue out
Kind Regards
The simplest way would be to assign a maximum score at the beggining based on how many indicators are on .
Then if an indicator fires you add one to the score . (you set the score to 0 before starting the check).
The simplest way would be to assign a maximum score at the beggining based on how many indicators are on .
Then if an indicator fires you add one to the score . (you set the score to 0 before starting the check).
it would not be hardcoded . The user enables or disables indicators .
Then the initialization counts the enabled indicators . That is the max tally
With Fast and Slow ma ? or price ?
it would not be hardcoded . The user enables or disables indicators .
Then the initialization counts the enabled indicators . That is the max tally
With Fast and Slow ma ? or price ?
Something like this
Something like this
Pass the values of the indicators as parameters into a function or move the arrays with the values in too.
Pass the values of the indicators as parameters into a function or move the arrays with the values in too.
So something like this.
Would void or bool be best? And then keeping the total required conditions in the OnTick with the Order logic for Buy and Sell
Void OnTick(){ if (buyTally==maxTally&&sellTally<maxTally) { // OrderBuy } else if (sellTally==maxTally&&buyTally<maxTally) { // OrderSell }}So something like this.
Would void or bool be best? And then keeping the total required conditions in the OnTick with the Order logic for Buy and Sell
yeah but with buytally and selltally as refererences too
yeah but with buytally and selltally as refererences too