Experts: MarketPredictor for MetaTrader 5 - page 2

 

Thanks for the tips, the code has been in progress for 5 days, I have solved the problem with not setting any trades, I just want to make small updates :)

 

You need to make a new iteration

    // Adjust alpha based on volatility (ATR)
    double atr = iATR(_Symbol, PERIOD_CURRENT, period); // Calculate ATR
    if(atr > 0.0)
        alpha = atr * 0.1; // Set alpha proportional to volatility
    else
        alpha = inputAlpha; // Fallback to input value if ATR is unavailable

this code is not going to correctly calculate ATR

https://www.mql5.com/en/docs/indicators/iatr

Return Value

Returns the handle of a specified technical indicator


It returns the handle which is a code, and does not return ATR value

Documentation on MQL5: Technical Indicators / iATR
Documentation on MQL5: Technical Indicators / iATR
  • www.mql5.com
The function returns the handle of the Average True Range indicator. It has only one buffer. Parameters symbol [in] The symbol name of the security...
 
1. bug fixes:
- In FFT: Recursive FFT call for even and odd arrays can lead to infinite recursion if the array size is not a degree of two.
We must make sure that the array size is a degree of two. This is not checked in the current code.
- In the CalculateFractalComponentFFT: function, we use FFT but do not check that N is a degree of two.
Also, after FFT, we only use the first N/2 elements, which is correct, but the FFT code has an error in the indexing when combining.
2. Improvements:
- In ExecuteTrade function: checking for open position using PositionSelect(_Symbol) is not quite correct,
because this function returns true if there is any position on a symbol, but not necessarily that it is open at the moment.
It is better to use a loop through all positions and check magic number and symbol.
- Also, in ExecuteTrade we do not check if there is already an open position, so we can open multiple positions.
We need to limit the opening to only one position (or use magic number to identify our positions).
- In the OptimiseParameters: function, the movingAverage calculation can be replaced by the built-in iMA function.
- In the SimulatePrice function: using MathRand() may not be the best for Monte Carlo, it is better to use normal distribution