//+------------------------------------------------------------------+ //| X121_Strategy_EA.mq5 | //| Copyright 2023, SaherElm IT | //| https://saherelm.ir/ | //+------------------------------------------------------------------+ #property copyright "Copyright 2023, SaherElm IT Center" #property link "https://saherelm.ir" #property version "1.00" #property description "EA based on X121 XCA and X3MA indicators" #property strict // // Include Common Library ... #include "../Libraries/x-saherelm.common.lib.mq5" #include "../XCAEA/Helpers/xcaea.helper.mq5" #include "../XCAEA/Libraries/xcaea.trigger.block.lib.mq5" // // Inputs ... input group "Signals"; input double eaSLAdditionalPoint = 0.0; // Additional SL in Point input double eaSLATRMultiplier = 0.0; // Additional SL using ATR Multiplier // // Variables ... XCAEAInputs eaInputs; XCXCAEAHelper *eaHelper; XBarTracker eaBarTraker; // CArrayObj *eaObjects; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { // // Initial Bar Tracker ... eaBarTraker.Init( _Symbol, _Period // ); // // Objects ... eaObjects = new CArrayObj(); // // Configure XCA ... eaInputs.Default(); // // Hide all Visible Buffers ... eaInputs.Hide(); // // we Can make Show all requirements here ... eaInputs.caInputs.showSar = false; // eaHelper = new XCXCAEAHelper(); bool isInited = eaHelper.Init( _Symbol, _Period, eaInputs // ); if (!isInited) { return (INIT_FAILED); } // return (INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { // // eaObjects.Clear(); // eaBarTraker.Clean(); // delete eaHelper; ZeroMemory(eaHelper); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { // // Check Bar Processing ... if (!eaBarTraker.CanProcessBar()) { return; } // bool has = false; // // Required Chart Identification ... ulong chartId = eaHelper.poiDrawer.ChartIdentification(); int subWindow = eaHelper.poiDrawer.SubWindowIdentification(); // // Retrieve Bars ... XOHCL zBar; XOHCL cBar; has = zBar.Init( _Symbol, _Period, 0 // ); has = has && zBar.GetPreviousBar(cBar); if (!has) { // zBar.Clean(); cBar.Clean(); // return; } // // Define Trigger Block ... XTriggerBlock tb; XCAEATriggerBlockConfiguration tbConfig; // // Configure Detector ... // // Validation ... tbConfig.maxAllowedRange = 0.0; tbConfig.minAllowedBlockEdgeLength = 7; // // Validation ... tbConfig.forceFVGBarType = true; tbConfig.forceHasSwingBar = true; tbConfig.forceOBOppositBar = true; tbConfig.forceHasLiquidity = false; tbConfig.forceGapBarBreakout = true; tbConfig.forceHasReversalLiquidity = true; // // Filters ... tbConfig.filterBasedOnSar = true; tbConfig.filterBasedOnADX = true; tbConfig.filterBasedOnRSI = true; tbConfig.filterBasedOnTrend = true; tbConfig.filterBasedOnScores = true; tbConfig.filterBasedOnVolumes = true; // // Targets ... double targets[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, }; Copy( targets, tbConfig.targets // ); // // Do Detection ... has = DetectTriggerBlock( tb, eaHelper, tbConfig, zBar.Index(), 10, eaSLAdditionalPoint, eaSLATRMultiplier // ); if (has) { // CArrayObj *tObjects; tObjects = new CArrayObj(); // has = DrawTriggerBlock( tb, tObjects, eaHelper, zBar.time // ); if (has) { AddObjects(tObjects, eaObjects); } // string message = tb.signal.GetMessage("Provided"); Print(message); } tb.Clean(); // // Do What we Want ... // When we Need Waits Until Next Bar ... eaBarTraker.Waits(); // // Cleanup Resources ... // tb.Clean(); zBar.Clean(); cBar.Clean(); tbConfig.Clean(); }