//+------------------------------------------------------------------+ //| 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" // // Variables ... XCAEAInputs eaInputs; XCXCAEAHelper *eaHelper; XBarTracker eaBarTraker; CArrayObj eaObjects; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { // // Initial Bar Tracker ... eaBarTraker.Init( _Symbol, _Period // ); // // Configure XCA ... eaInputs.Default(); // // Hide all Visible Buffers ... eaInputs.Hide(); // // we Can make Show all requirements here ... // 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; } // // Here Do What we Want ... XOHCL swingBar; XBoxZone ob; XBoxZone fvg; XBoxZone trigger; XBoxZone liquidity; has = eaHelper .barAnalyser .IsTrigger( cBar, trigger, ob, fvg, liquidity, swingBar, 10 // ); if (has) { // bool isBullish = trigger.IsBullish(); // // ob.to = zBar.time; // fvg.to = zBar.time; trigger.to = zBar.time; liquidity.to = zBar.time; // // Draw OB ... XCBoxObject *iOBObj; has = eaHelper.poiDrawer.DrawBox( ob, iOBObj // ); if (has) { eaObjects.Add(iOBObj); } ZeroMemory(iOBObj); // // Draw FVG ... XCBoxObject *iFVGObj; has = eaHelper.poiDrawer.DrawBox( fvg, iFVGObj // ); if (has) { // // Style Object ... color clr = isBullish ? clrAqua : clrMagenta; iFVGObj.BoxWidth(2); iFVGObj.BoxColor(clr); iFVGObj.BoxStyle(STYLE_SOLID); // // Store Object ... eaObjects.Add(iFVGObj); } ZeroMemory(iFVGObj); // // Draw Trigger ... XCBoxObject *iTriggerObj; has = eaHelper.poiDrawer.DrawBox( trigger, iTriggerObj // ); if (has) { eaObjects.Add(iTriggerObj); } ZeroMemory(iTriggerObj); // // Draw Liquidity ... XCBoxObject *iLiqObj; has = eaHelper.poiDrawer.DrawBox( liquidity, iLiqObj // ); if (has) { eaObjects.Add(iLiqObj); } ZeroMemory(iLiqObj); // // Draw Swing Bar ... color swingColor = isBullish ? clrAqua : clrMagenta; ENUM_X_PRICE swingPType = isBullish ? X_PRICE_LOW : X_PRICE_HIGH; // XCBarArrowObject *swingObj; has = eaHelper.poiDrawer.CreateBarArrow( swingBar, swingObj, swingPType, 159, swingColor // ); if (has) { eaObjects.Add(swingObj); } // Print("Trigger Box Detected ..."); } // // Do What we Want ... // When we Need Waits Until Next Bar ... eaBarTraker.Waits(); // // Cleanup Resources ... // ob.Clean(); fvg.Clean(); zBar.Clean(); cBar.Clean(); trigger.Clean(); swingBar.Clean(); liquidity.Clean(); }