Attached File(s)
super-stochastic-indicator.ex4
18 KB
|
196 downloads
I will code your pivot EAs for no charge 23 replies
I will code your scalping EAs for no charge 163 replies
Oanda MT4 - Indicators and EAs not showing 2 replies
EAs and indicators relating to moutaki... 22 replies
InterbankFX has loaded its MT4 platform with custom EAs, indicators and scripts 1 reply
DislikedHello Does anyone know what code to add in front of buy or sell code order, so the EA will take one trade per bar only, mt4 Thannks,Ignored
DislikedHello Does anyone know what code to add in front of buy or sell code order, so the EA will take one trade per bar only, mt4 Thannks,Ignored
Disliked{quote} Put in IsNewCandle section (see below) Take-out the Order part from Start and make it a void CheckForTrade() section Insert IsNewCandle() CheckForTrade() function in Start //+------------------------------------------------------------------+ //| Insuring Its a New Candle Function | //+------------------------------------------------------------------+ bool IsNewCandle() { static int BarsOnChart = 0; if(Bars == BarsOnChart) return(false); BarsOnChart = Bars; return(true); }Ignored
Disliked{quote} - using number of bars is not reliable in checking if a new bar has been made, use candle time instead. Bar count can increase/decrease with no change in the current bar time ie no new bar - your current setup only checks for a trading signal on the first tick of a new bar, and is not usable for live signals, but the issue is not completed/live signals, but just to check that a trade has not been made at the current live candle, so a static long time_last_trade should not equal the current bar time to ensure that completed/live signals both...Ignored
Disliked{quote} The first thing to note is that this is a passive income strategy, meaning that it is designed to make small, consistent profits over time rather than trying to hit big, risky trades. The strategy is based on the idea of trading against the trend. That means that if the price of EURUSD is going up, the strategy will look for opportunities to sell (go short), and if the price is going down, it will look for opportunities to buy (go long). To do this, the strategy compares the current price to the closing price of the previous day. If the...Ignored
[color=Black][font=Century Gothic][highlight=White]This is a MetaTrader 4 Expert Advisor script that appears to be a simple trend-following strategy with some additional features. The main function of the script is to open and modify orders based on moving average crossovers and supply and demand levels.[/highlight][/font][/color] [color=#d1d5db][font=Söhne][color=Black][font=Century Gothic][highlight=White]The script starts by defining the input parameters such as the period for the moving average, the period for the RSI, and the take profit and stop loss levels. It also defines variables for lot size, magic number, and a list of allowed symbols.[/highlight][/font][/color][/font][/color] [color=#d1d5db][font=Söhne][color=Black][font=Century Gothic][highlight=White]The script then defines the init(), deinit(), and OnTick() functions. The init() and deinit() functions are empty, and the OnTick() function is where most of the logic takes place.[/highlight][/font][/color][/font][/color] [color=#d1d5db][font=Söhne][color=Black][font=Century Gothic][highlight=White]In the OnTick() function, the script first determines the total number of symbols available and then loops through each symbol. For each symbol, it checks whether it is in the list of allowed symbols. If not, it moves on to the next symbol.[/highlight][/font][/color][/font][/color] [color=#d1d5db][font=Söhne][color=Black][font=Century Gothic][highlight=White]If the symbol is allowed, the script then calculates the moving average high, low, and close for the specified period and determines whether the trend is up or down based on the close price being greater than or less than the high and low prices. It then finds the nearest order block and supply and demand levels for the symbol.[/highlight][/font][/color][/font][/color] [color=#d1d5db][font=Söhne][color=Black][font=Century Gothic][highlight=White]Next, the script calculates the lot size based on the risk percent and the available margin. It then finds the appropriate take profit level based on the trend, supply and demand levels, and partial close levels.[/highlight][/font][/color][/font][/color] [color=#d1d5db][font=Söhne][color=Black][font=Century Gothic][highlight=White]Finally, the script places or modifies an order based on whether there is an existing order block for the symbol. If there is no order block, the script opens a new order for either a buy or sell depending on the trend. If there is an order block, the script updates the existing order.[/highlight][/font][/color][/font][/color] [color=Black][font=Century Gothic][highlight=White]Overall, this script appears to be a simple trend-following strategy with some additional features for calculating lot size, determining take profit levels, and finding supply and demand levels. However, as with any trading strategy, it is important to thoroughly test and optimize the script on historical data before using it for live trading.[/highlight][/font][highlight=White][/highlight][/color]
[color=Black][font=Söhne][highlight=White]//+------------------------------------------------------------------+[/highlight][/font][/color] [color=Black][font=Söhne][highlight=White]//| ASESOR EXPERTO PSG | //| Desarrollado por el equipo de PSGGOLD| //| Marzo de 2023 | //+------------------------------------------------------------------+ //--- parámetros de entrada extern int MA_Period = 50; extern int RSI_Period = 14; extern double TakeProfit = 100.0; extern double StopLoss = 50.0; extern double RiskPercent = 1.0; extern double PartialClose1 = 50.0; extern double PartialClose2 = 75.0; extern double PartialClose3 = 100.0; //--- variables globales int sl, tp; double lotSize; int MagicNumber = 2023; //--- lista de pares de divisas permitidos string allowed_symbols[] = {"XAUUSD", "USDJPY", "USDCHF", "USDCAD", "GBPUSD", "GBPJPY", "GBPCHF", "EURUSD", "EURGBP", "EURCAD", "EURNZD", "AUDCAD", "AUDUSD", "NZDUSD", "NZDJPY"}; //--- función de inicialización del asesor experto int init() { return(0); } //--- función de finalización del asesor experto int deinit() { return(0); } //--- función de tick del asesor experto void OnTick() { //--- determinar el número total de símbolos disponibles int symbols_total = SymbolsTotal(false); //--- recorrer todos los símbolos for(int i = 0; i < symbols_total; i++) { //--- obtener el nombre del símbolo string symbol = SymbolName(i, false); //--- verificar si el símbolo se encuentra en la lista de pares de divisas permitidos int index = ArrayFindIndex(allowed_symbols, symbol); if(index == -1) { continue; } //--- obtener los precios de alta, baja y cierre para el período MA_Period en el marco de tiempo actual double ma_high = iHigh(symbol, 0, MA_Period); double ma_low = iLow(symbol, 0, MA_Period); double ma_close = iClose(symbol, 0, MA_Period); //--- determinar si la tendencia es alcista o bajista bool is_trend_up = ma_close > ma_high && ma_close > ma_low; //--- encontrar el bloque de orden más cercano int order_block = FindOrderBlock(symbol); //--- encontrar los niveles de oferta y demanda más cercanos double supply_level = 0, demand_level = 0; FindSupplyDemand(symbol, supply_level, demand_level); //--- calcular el tamaño del lote en base al riesgo y al margen disponible double margin = AccountFreeMargin() * RiskPercent / 100; lotSize = CalculateLotSize(symbol, margin, StopLoss); //--- encontrar los niveles de toma de ganancia más adecuados double take_profit_level = 0; FindTakeProfit(symbol, is_trend_up, supply_level, demand_level, TakeProfit, PartialClose1, PartialClose2, PartialClose3, take_profit_level); //--- colocar la orden if(order_block == -1) { //--- no se ha encontrado ningún bloque de órdenes, abrir una nueva orden if(is_trend_up) { //--- tendencia alcista, abrir una orden de compra int ticket = OrderSend(symbol, OP_BUY, lotSize, Ask, Slippage, 0, take_profit_level, 0, 0, 0, Blue); if(ticket > 0) { OrderModify(ticket, 0, 0, StopLoss, 0, Green); } } else { //--- tendencia bajista, abrir una orden de venta int ticket = OrderSend(symbol, OP_SELL, lotSize, Bid, Slippage, 0, take_profit_level, 0, 0, 0, Red); if(ticket > 0) { OrderModify(ticket, 0, 0, StopLoss, 0, Green); } else { Print("Error al abrir la orden: ", GetLastError()); } } } else { //--- se ha encontrado un bloque de órdenes, actualizar la orden existente int total_orders = OrdersTotal(); for(int j = order_block; j < total_orders; j++) { if(OrderSymbol(j) == symbol && OrderMagicNumber(j) == MagicNumber) { if(OrderType(j) == OP_BUY) { //--- tendencia alcista, actualizar la orden de compra OrderModify(OrderTicket(j), 0, take_profit_level, 0, 0, Green); } else { //--- tendencia bajista, actualizar la orden de venta OrderModify(OrderTicket(j), 0, take_profit_level, 0, 0, Red); } } } } //--- función para encontrar el bloque de orden más cercano int FindOrderBlock(string symbol) { int total_orders = OrdersTotal(); for(int i = 0; i < total_orders; i++) { if(OrderSymbol(i) == symbol && OrderMagicNumber(i) == MagicNumber) { return(i); } } return(-1); } def findorderblock(high, low, volume): # Definir los puntos extremos max_high = max(high) min_low = min(low) # Definir los puntos decisionales max_volume = max(volume) mean_volume = sum(volume) / len(volume) # Encontrar el rango de precios en el que se produjo el mayor volumen volume_range = [i for i, v in enumerate(volume) if v >= max_volume * 0.9] price_range = (min_low, max_high) if high.index(max_high) < low.index(min_low) else (max_high, min_low) # Identificar el Order Block order_block = [i for i in volume_range if i in range(low.index(price_range[0]), high.index(price_range[1]))] return order_block //--- función para encontrar los niveles de oferta y demanda más cercanos void FindSupplyDemand(string symbol, double &supply_level, double &demand_level) { //--- obtener los precios de cierre para el período RSI_Period en el marco de tiempo actual double rsi_close = iClose(symbol, 0, RSI_Period); //--- calcular los niveles de oferta y demanda double atr = iATR(symbol, 0, RSI_Period); supply_level = NormalizeDouble(iHigh(symbol, 0, RSI_Period) + atr * 3, Digits); demand_level = NormalizeDouble(iLow(symbol, 0, RSI_Period) - atr * 3, Digits); } //--- función para calcular el tamaño del lote en base al riesgo y al margen disponible double CalculateLotSize(string symbol, double margin, double stop_loss) { double tick_value = MarketInfo(symbol, MODE_TICKVALUE); double tick_size = MarketInfo(symbol, MODE_TICKSIZE); double min_lot = MarketInfo(symbol, MODE_MINLOT); double lot_step = MarketInfo(symbol, MODE_LOTSTEP); double max_lot = MarketInfo(symbol, MODE); bool is_bullish_candle(double open, double close) { return (close > open); } bool is_bearish_candle(double open, double close) { return (close < open); } // Parámetros de entrada extern int lookback_bars = 20; // Número de barras hacia atrás para buscar el Order Block extern double deviation = 0.001; // Margen de desviación para definir el Order Block // Variables globales double ob_low, ob_high; // Niveles de soporte/resistencia del Order Block // Función para buscar el Order Block bool find_order_block() { // Obtener los precios máximos y mínimos de las últimas lookback_bars barras double high = High[Highest(NULL, 0, MODE_HIGH, lookback_bars, 0)]; double low = Low[Lowest(NULL, 0, MODE_LOW, lookback_bars, 0)]; // Calcular el rango del Order Block double range = (high - low) * deviation; // Definir los niveles de soporte/resistencia del Order Block ob_low = low + range; ob_high = high - range; // Verificar si el precio ha tocado el nivel de soporte/resistencia del Order Block for (int i = 0; i < lookback_bars; i++) { if (Low[i] <= ob_low || High[i] >= ob_high) { return true; } } return false; } double FindSupplyDemand(int timeframe, double lookback, int max_bars) { double supply = 0, demand = 0; double high, low; for(int i = max_bars; i >= 0; i--) { high = High[i]; low = Low[i]; if(high - low > lookback) { if(high - Close[i] > lookback) supply++; else if(Close[i] - low > lookback) demand++; } } return supply / (supply + demand); } double CalculateLotSize(double riskPct, double stopLossPips) { double accountBalance = AccountBalance(); double riskAmount = accountBalance * (riskPct / 100); double lotSize = (riskAmount / stopLossPips) / 10; // Set default lot size to 0.01 double defaultLotSize = 0.01; double userLotSize = NormalizeDouble(Lots, 2); if(userLotSize == 0.0) { lotSize = NormalizeDouble(defaultLotSize, 2); } else { lotSize = NormalizeDouble(userLotSize, 2); } return lotSize; } double riskPct = 2.0; double stopLossPips = 30.0; double lotSize = CalculateLotSize(riskPct, stopLossPips); // Set custom lot size Lots = 0.02; // Use calculated lot size OrderSend(Symbol(), OP_BUY, lotSize, Ask, 3, Bid - (stopLossPips * Point), 0, "My order", MagicNumber, 0, Green); double FindTakeProfit(double entryPrice, int direction, double decisionZone) { double projectedPrice = 0.0; double takeProfit = 0.0; // Calcular la proyección de precios en función de la dirección del movimiento if (direction == 1) { projectedPrice = decisionZone + (decisionZone - entryPrice); } else if (direction == -1) { projectedPrice = decisionZone - (entryPrice - decisionZone); } else { return 0.0; // Dirección inválida } // Establecer el nivel objetivo de ganancia en función del contexto del mercado double priceRange = MathAbs(decisionZone - entryPrice); if (priceRange <= 50) { takeProfit = 20.0; // Objetivo de ganancia conservador } else if (priceRange > 50 && priceRange <= 100) { takeProfit = 30.0; // Objetivo de ganancia moderado } else if (priceRange > 100 && priceRange <= 200) { takeProfit = 50.0; // Objetivo de ganancia agresivo } else { takeProfit = 100.0; // Objetivo de ganancia muy agresivo } // Calcular el nivel de take profit basado en la proyección de precios y el objetivo de ganancia if (direction == 1) { takeProfit = projectedPrice + (takeProfit * Point); } else if (direction == -1) { takeProfit = projectedPrice - (takeProfit * Point); } return takeProfit; [/highlight][/font][/color] [color=Black][font=Söhne][highlight=White]}[/highlight][/font][/color]
Disliked{quote} Try this Just change the "objname" at the top of the indicator input each time you add the indi {file} {image}Ignored
Disliked{quote} do I put his code in the very bottom? does it work with mt4...it says mq5 and ex5 Thanks,Ignored