//+------------------------------------------------------------------+ // Scalping Robot…
- User
//+------------------------------------------------------------------+ //| Scalping Robot | //+------------------------------------------------------------------+ #property copyright "Copyright 2024, MetaQuotes Ltd." #property link "https://www.mql5.com" #property version "1.00"
#include <Trade/Trade.mqh>
CTrade trade; CPositionInfo pos; COrderInfo ord;
//+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+
input group "*** Trading Inputs ***" input double LotSize = 0.01; // Lot size for trading input int Tppoints = 800; // Take Profit (10 points = 1 pip) input int Slpoints = 800; // Stoploss Points (10 points = 1 pip) input int TslTriggerPoints = 35; // Points in profit before Trailing SL is activated (10 points = 1 pip) input int TslPoints = 10; // Trailing Stoploss (10 points = 1 pip) input ENUM_TIMEFRAMES Timeframe = PERIOD_CURRENT; // Time frame to run input int InpMagic = 891245; // EA identification no input string TradeComment = "Wendel Cassiano"; input int MaxSpread = 100; // Maximum spread allowed (in points) input int Slippage = 50; // Slippage in points input int MaxOrders = 2; // Máximo de ordens permitidas simultaneamente
enum StarHour { Inactive=0, _0100=1, _0200=2, _0300=3, _0400=4, _0500=5, _0600=6, _0700=7, _0800=8, _0900=9, _1000=10, _1100=11, _1200=12, _1300=13, _1400=14, _1500=15, _1600=16, _1700=17, _1800=18, _1900=19, _2000=20, _2100=21, _2200=22, _2300=23 }; input StarHour SHInput = 0; // Start Hour
enum EndHour { Inactive=0, _0100=1, _0200=2, _0300=3, _0400=4, _0500=5, _0600=6, _0700=7, _0800=8, _0900=9, _1000=10, _1100=11, _1200=12, _1300=13, _1400=14, _1500=15, _1600=16, _1700=17, _1800=18, _1900=19, _2000=20, _2100=21, _2200=22, _2300=23 }; input EndHour EHInput = 0; // End Hour
int SHChoice; int EHChoice;
int BarsN = 5; int ExpirationBars = 100; int OrderDistPoints = 100;
int OnInit() { //--- trade.SetExpertMagicNumber(InpMagic); ChartSetInteger(0, CHART_SHOW_GRID, false);
return (INIT_SUCCEEDED);}
//+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //---
TrailStop(); if (!IsNewBar()) return; MqlDateTime time; TimeToStruct(TimeCurrent(), time); int Hournow = time.hour; SHChoice = SHInput; EHChoice = EHInput; if (Hournow < SHChoice) { CloseAllOrders(); return; } if (Hournow >= EHChoice && EHChoice != 0) { CloseAllOrders(); return; } double spread = (SymbolInfoDouble(_Symbol, SYMBOL_ASK) - SymbolInfoDouble(_Symbol, SYMBOL_BID)) / _Point; if (spread > MaxSpread) return; int BuyTotal = 0; int SellTotal = 0; for (int i = PositionsTotal() - 1; i >= 0; i--) { pos.SelectByIndex(i); if (pos.PositionType() == POSITION_TYPE_BUY && pos.Symbol() == _Symbol && pos.Magic() == InpMagic) BuyTotal++; if (pos.PositionType() == POSITION_TYPE_SELL && pos.Symbol() == _Symbol && pos.Magic() == InpMagic) SellTotal++; } for (int i = OrdersTotal() - 1; i >= 0; i--) { ord.SelectByIndex(i); if (ord.OrderType() == ORDER_TYPE_BUY_STOP && ord.Symbol() == _Symbol && ord.Magic() == InpMagic) BuyTotal++; if (ord.OrderType() == ORDER_TYPE_SELL_STOP && ord.Symbol() == _Symbol && ord.Magic() == InpMagic) SellTotal++; } int TotalOrders = BuyTotal + SellTotal; if (TotalOrders >= MaxOrders) return; if (BuyTotal <= 0) { double high = findHigh(); if (high > 0) { SendBuyOrder(high); } } if (SellTotal <= 0) { double low = findLow(); if (low > 0) { SendSellOrder(low); } } - Assistant
- User
me entregue o codigo completo com a atualização
- Assistant
- User
variable 'tp' not used Scalping_GOLD__005_.mq5 211 28
corrija e me entregue corrigido completo
- Assistant