CapitalRoyal
- Experts
- Mr Nisit Noijeam
- Version: 1.6
- Mise à jour: 12 février 2024
- Activations: 10
MA trend following 1sd signal
The EA appears to use a combination of moving averages and standard deviation to make trading decisions, with the option to increase lot sizes after consecutive losses, potentially aiming for a martingale-like strategy. It's important to note that while EAs can automate trading, they come with risks, especially when using strategies like lot size increase on loss. Users should thoroughly backtest and understand the EA's strategy and risks before using it in live trading.-
Inputs and Settings:
- MaTypes : Enum for different types of Moving Averages (Simple, Exponential, Smoothed, LinearWeighted).
- Inputs for the moving average type ( MaType ), period ( MaPeriod ), standard deviation period ( SdPeriod ), factor ( SdFactor ), initial lot size ( InitialLotSize ), and flags to enable buying/selling ( EnableBuy , EnableSell ) and lot size increase on loss ( EnableLotIncrease ).
- A unique MAGIC_NUMBER to identify orders made by this EA.
-
Initialization Function ( OnInit ): Simply initializes the EA.
-
Trade History Checking ( CheckTradeHistory ): This function checks the trade history to count consecutive losses for buy and sell orders. Depending on these losses and if EnableLotIncrease is true, it adjusts the lot sizes for buying and selling.
-
Main Trading Logic ( OnTick ):
- Calculates the moving average ( ma ) based on the selected type ( MaType ) and standard deviation ( sd ).
- Checks for open orders and determines if there are any existing orders for this EA.
- If there are no open orders, it places new buy or sell orders based on the current price, moving average, and standard deviation. Buy orders are placed if the current price is above ma + sd , and sell orders are placed if below ma - sd .
- If there is an open order, the EA checks whether it should close it based on the current price and moving average.
-
Normalize Lot Size Function ( NormalizeLotSize ): Ensures that the lot size for any trade is within the minimum and maximum lot size limits of the trading instrument.