#include <Trade\Trade.mqh> #define NumNodes 10 CTrade trade; CPositionInfo pos;…
- User
#include <Trade\Trade.mqh>
#define NumNodes 10 CTrade trade; CPositionInfo pos; COrderInfo ord;
// Trading Parameters 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"; // Trade comment input int MaxSpread = 100; // Maximum spread allowed (in points) input int Slippage = 50; // Slippage in points input int MaxOrders = 2; // Maximum simultaneous orders
input int BarsN = 5; // Bars to analyze input int ExpirationBars = 100; // Order expiration based on bars input int OrderDistPoints = 100; // Distance in points from price
// Neural Network Parameters input double Coefficient = 0.1; input double BuyTargetOutput = 0.3; input double SellTargetOutput = -0.3; input double LearningRate = 0.1;
double Weight[NumNodes]; double RSIBuffer[NumNodes]; double NormalizedInputs[NumNodes]; double NNOutPut = 0;
//+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { trade.SetExpertMagicNumber(InpMagic); ChartSetInteger(0, CHART_SHOW_GRID, false);
// Initialize Neural Network Weights for (int i = 0; i < NumNodes; i++) Weight[i] = 0.5;
return (INIT_SUCCEEDED); }
//+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { // Run TrailStop logic TrailStop();
// Check if parameters have changed if (CheckForParameterUpdates()) { // Recalculate points of negotiation AdjustPointsOfNegotiation(); }
// Check for new bar and exit if not if (!IsNewBar()) return;
// Check spread double spread = (SymbolInfoDouble(_Symbol, SYMBOL_ASK) - SymbolInfoDouble(_Symbol, SYMBOL_BID)) / _Point; if (spread > MaxSpread) return;
// Count open orders int BuyTotal = 0, SellTotal = 0; for (int i = PositionsTotal() - 1; i >= 0; i--) { pos.SelectByIndex(i); if (pos.Magic() == InpMagic && pos.Symbol() == _Symbol) { if (pos.PositionType() == POSITION_TYPE_BUY) BuyTotal++; if (pos.PositionType() == POSITION_TYPE_SELL) SellTotal++; } }
for (int i = OrdersTotal() - 1; i >= 0; i--) { ord.SelectByIndex(i); if (ord.Magic() == InpMagic && ord.Symbol() == _Symbol) { if (ord.OrderType() == ORDER_TYPE_BUY_STOP) BuyTotal++; if (ord.OrderType() == ORDER_TYPE_SELL_STOP) SellTotal++; } }
- Assistant
- User
corrija e me entregue o codigo completo
- Assistant