last ...
This commit is contained in:
@@ -228,7 +228,7 @@ class XCAlert : public XCBase
|
|||||||
//
|
//
|
||||||
// Send an Alert by Handling all Different Specified
|
// Send an Alert by Handling all Different Specified
|
||||||
// type's of Alert's if they are Enabled ...
|
// type's of Alert's if they are Enabled ...
|
||||||
void Alert(string message)
|
void SendAlert(string message)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Handle Log, if Enabled ...
|
// Handle Log, if Enabled ...
|
||||||
@@ -1505,9 +1505,9 @@ class XCBaseAlert : public XCBase
|
|||||||
//
|
//
|
||||||
// Send an Alert by Handling all Different Specified
|
// Send an Alert by Handling all Different Specified
|
||||||
// type's of Alert's if they are Enabled ...
|
// type's of Alert's if they are Enabled ...
|
||||||
void Alert(string message)
|
void SendAlert(string message)
|
||||||
{
|
{
|
||||||
mAlert.Alert(message);
|
mAlert.SendAlert(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -0,0 +1,942 @@
|
|||||||
|
///////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// SaherElm IT Center XCATB MQL5 Expert Advisor
|
||||||
|
// -------------------------------------------------
|
||||||
|
// Name: XCAEA
|
||||||
|
// Description: an Exper Advisor which used XCATB
|
||||||
|
//
|
||||||
|
// Maintainer:
|
||||||
|
// ------------
|
||||||
|
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Global Properties ...
|
||||||
|
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||||
|
#property link "https://saherelm.ir"
|
||||||
|
#property version "1.00"
|
||||||
|
#property description "EA based on X121 XCATB indicator"
|
||||||
|
#property strict
|
||||||
|
|
||||||
|
//
|
||||||
|
// Include Common Library ...
|
||||||
|
#include "../Classes/x-saherelm.x-alert.class.mq5"
|
||||||
|
#include "../Classes/x-saherelm.x-trade.class.mq5"
|
||||||
|
#include "../Classes/x-saherelm.x-volume.class.mq5"
|
||||||
|
#include "../Helpers/x-saherelm.x121.xcatb.helper.mq5"
|
||||||
|
#include "../Libraries/x-saherelm.common.lib.mq5"
|
||||||
|
#include "../Libraries/x-saherelm.x121.xcatb.lib.mq5"
|
||||||
|
#include "../XCAEA/Classes/xcaea.x-trade.manager.class.mq5"
|
||||||
|
|
||||||
|
//
|
||||||
|
#define ShortName "XCATB_EA"
|
||||||
|
|
||||||
|
//
|
||||||
|
// Inputs ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Common ...
|
||||||
|
input group "Common";
|
||||||
|
input long eaMagicNumber = 78692110; // Magic Number
|
||||||
|
input int eaSlippage = 10; // Slippgae
|
||||||
|
input string eaLogSuffix = ""; // Log Suffix
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detector ...
|
||||||
|
input group "Detector";
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validating ...
|
||||||
|
input group "Validations";
|
||||||
|
input bool eaForceHasSwing = false; // Force Blocks to Have Swing
|
||||||
|
input bool eaForceObBarType = false; // Force Block Has Reversal Bar
|
||||||
|
input bool eaForceOBFVGBarType = false; // Force FVG Has Same Bars
|
||||||
|
input bool eaForceHasFLiquidity = false; // Force Blocks to Have Following Liquidity
|
||||||
|
input bool eaForceHasRLiquidity = false; // Force Blocks to Have Reversal Liquidity
|
||||||
|
input bool eaValidateGapSequence = false; // Validate Block's Gap Sequence
|
||||||
|
input bool eaValidateBlockEdgeBreakout = false; // Validate Block's Edge Breakout
|
||||||
|
|
||||||
|
//
|
||||||
|
// Filtering ...
|
||||||
|
input group "Filters";
|
||||||
|
input bool eaFilterBasedOnPV = false; // Filter Based on Peak and Vale
|
||||||
|
input bool eaFilterBasedOnSar = false; // Filter Based on Sar
|
||||||
|
input bool eaFilterBasedOnRSI = false; // Filter Based on RSI
|
||||||
|
input bool eaFilterBasedOnADX = false; // Filter Based on ADX
|
||||||
|
input bool eaFilterBasedOnATR = false; // Filter Based on ATR
|
||||||
|
input bool eaFilterBasedOnTrend = false; // Filter Based on Trend
|
||||||
|
input bool eaFilterBasedOnDelta = false; // Filter Based on Delta
|
||||||
|
input bool eaFilterBasedOnVolume = false; // Filter Based on Volume
|
||||||
|
input bool eaFilterBasedOnSignalBar = false; // Filter Based on Signal Bar
|
||||||
|
input bool eaFilterBasedOnHKSignalBar = false; // Filter Based on Hiken Ashi Signal Bar
|
||||||
|
|
||||||
|
//
|
||||||
|
// Signal ...
|
||||||
|
input group "Signal";
|
||||||
|
input int eaSignalR2R = 3; // Risk Reward Ratio
|
||||||
|
input double eaSLAtrMultiplier = 0.5; // ATR Multiplier for SL
|
||||||
|
|
||||||
|
//
|
||||||
|
// Volume ...
|
||||||
|
input group "Volume";
|
||||||
|
input ENUM_X_VOLUME_SELECT_TYPE eaVolumeSelect = X_VOLUME_EQUITY; // Volume Applying Type
|
||||||
|
input double eaStaticVoluem = 0.0; // Static Volume
|
||||||
|
input double eaDynamicVolumeStepBalance = 0.0; // Step of Balance for Increase Volume
|
||||||
|
input double eaDynamicVolumeStepVolume = X_MIN_VOLUME; // Step of Volume Increasing
|
||||||
|
input double eaConstantRiskBalance = 0.0; // Constant Risk Balance per Trade
|
||||||
|
input double eaConstantPercent = 0.5; // Constant Percent of Balance Per Trade
|
||||||
|
input double eaConstantBalance = 0.0; // Constant Balance for Calculations
|
||||||
|
|
||||||
|
//
|
||||||
|
// Management ...
|
||||||
|
input group "Management";
|
||||||
|
input bool eaAllowTrade = true; // Allow Trade on Signals
|
||||||
|
input bool eaAllowLongs = true; // Allow Long Trades
|
||||||
|
input bool eaAllowShorts = true; // Allow Short Trades
|
||||||
|
input ENUM_XCAEA_TRADE_RESTRICTION_PERIOD eaRestrictionsPeriod = XCAEA_TRADE_RESTRICATION_NONE; // Trade Restrictions Period
|
||||||
|
input int eaMaxAllowedTPs = 0; // Max Allowed TP(s) per Day
|
||||||
|
input int eaMaxAllowedSLs = 0; // Max Allowed SL(s) per Day
|
||||||
|
input int eaMaxAllowedTrades = 0; // Max Allowed Trades per Day
|
||||||
|
input int eaMaxAllowedPositions = 5; // Max Allowed Same Time Trades
|
||||||
|
input double eaMaxAllowedSpread = 25; // Max Allowed Spread For Trade
|
||||||
|
input double eaMaxAllowedDrawdownFactor = 0.3; // Max Allowed DrawDown for Trade
|
||||||
|
input string eaCloseAllOpenTradesAt = ""; // Close All Open Trades per Day At Specified Time
|
||||||
|
|
||||||
|
//
|
||||||
|
// Alert ...
|
||||||
|
// Here we Provider All Requirements for
|
||||||
|
// Configuring Alert Provider ...
|
||||||
|
input group "Alert";
|
||||||
|
input bool eaEnableAlerts = true; // Enable Alerts
|
||||||
|
input bool eaLogAlerts = true; // Log Alerts
|
||||||
|
input bool eaMailAlerts = false; // Mail Alerts
|
||||||
|
input bool eaPushAlerts = true; // Push Alerts
|
||||||
|
input bool eaTerminalAlerts = true; // Terminal Alerts
|
||||||
|
|
||||||
|
//
|
||||||
|
// Time Report ...
|
||||||
|
input group "Reports";
|
||||||
|
input bool eaReportNewMonths = false; // Report New Month
|
||||||
|
input bool eaReportNewWeeks = false; // Report New Weeks
|
||||||
|
input bool eaReportNewDays = true; // Report New Days
|
||||||
|
input bool eaReportNewHours = false; // Report New Hours
|
||||||
|
input bool eaReportTrades = true; // Report Trades
|
||||||
|
input bool eaReportSignals = true; // Report Signals
|
||||||
|
input bool eaReportProtector = true; // Report Protector Actions
|
||||||
|
input bool eaReportAfterTradesBalance = true; // Report Balance after a Trade Finished
|
||||||
|
|
||||||
|
//
|
||||||
|
// Variables ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XCAlert *eaAlert;
|
||||||
|
XCTrade *eaTrade;
|
||||||
|
XSignal eaSignal;
|
||||||
|
XCVolume *eaVolume;
|
||||||
|
X121XCatbInputs eaInputs;
|
||||||
|
XCX121XCatbHelper *eaHelper;
|
||||||
|
XBarTracker eaBarTraker;
|
||||||
|
XTimeTracker eaTimeTracker;
|
||||||
|
XCXCAEATradeManager *eaTradeManager;
|
||||||
|
XCAEAStrategyConditions eaConditions;
|
||||||
|
|
||||||
|
//
|
||||||
|
XTriggerBlock eaTB;
|
||||||
|
|
||||||
|
//
|
||||||
|
CArrayObj *eaObjects;
|
||||||
|
|
||||||
|
//
|
||||||
|
string eaTag = "";
|
||||||
|
|
||||||
|
//
|
||||||
|
// Event Handlers ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialization ...
|
||||||
|
int OnInit()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate Inputs and Required Parameters
|
||||||
|
// for EA to Works fine ...
|
||||||
|
if (!ValidateInputs())
|
||||||
|
{
|
||||||
|
return INIT_PARAMETERS_INCORRECT;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initial Requirements ...
|
||||||
|
InitRequirements();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize Volume Manger ...
|
||||||
|
if (!InitVolume())
|
||||||
|
{
|
||||||
|
return INIT_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return (INIT_SUCCEEDED);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// DeInitialization ...
|
||||||
|
void OnDeinit(const int reason)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function
|
||||||
|
// REASON_REMOVE 1 Program removed from a chart
|
||||||
|
// REASON_RECOMPILE 2 Program recompiled
|
||||||
|
// REASON_CHARTCHANGE 3 A symbol or a chart period is changed
|
||||||
|
// REASON_CHARTCLOSE 4 Chart closed
|
||||||
|
// REASON_PARAMETERS 5 Inputs changed by a user
|
||||||
|
// REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings
|
||||||
|
// REASON_TEMPLATE 7 Another chart template applied
|
||||||
|
// REASON_INITFAILED 8 The OnInit() handler returned a non-zero value
|
||||||
|
// REASON_CLOSE 9 Terminal closed
|
||||||
|
|
||||||
|
//
|
||||||
|
// eaObjects.Clear();
|
||||||
|
|
||||||
|
//
|
||||||
|
delete eaHelper;
|
||||||
|
ZeroMemory(eaHelper);
|
||||||
|
|
||||||
|
//
|
||||||
|
delete eaAlert;
|
||||||
|
ZeroMemory(eaAlert);
|
||||||
|
|
||||||
|
//
|
||||||
|
delete eaTrade;
|
||||||
|
ZeroMemory(eaTrade);
|
||||||
|
|
||||||
|
//
|
||||||
|
delete eaVolume;
|
||||||
|
ZeroMemory(eaVolume);
|
||||||
|
|
||||||
|
//
|
||||||
|
eaSignal.Clean();
|
||||||
|
eaBarTraker.Clean();
|
||||||
|
eaConditions.Clean();
|
||||||
|
eaTimeTracker.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
DestroyTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// On Tick Handler ...
|
||||||
|
void OnTick()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
HandleTimeReport();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Handle Position Management / Protections ...
|
||||||
|
// eaTradeManager.Manage();
|
||||||
|
|
||||||
|
// //
|
||||||
|
// eaSignal.Clean();
|
||||||
|
// eaConditions.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Bar Processing ...
|
||||||
|
if (!eaBarTraker.CanProcessBar())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool has = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Retrieve Bars ...
|
||||||
|
// XOHCL zBar;
|
||||||
|
// XOHCL cBar;
|
||||||
|
// has = zBar.Init(
|
||||||
|
// _Symbol,
|
||||||
|
// _Period,
|
||||||
|
// 0 //
|
||||||
|
// );
|
||||||
|
// has =
|
||||||
|
// has &&
|
||||||
|
// zBar.GetPreviousBar(cBar);
|
||||||
|
// if (!has)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// zBar.Clean();
|
||||||
|
// cBar.Clean();
|
||||||
|
|
||||||
|
// //
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
//
|
||||||
|
// double bid = GetBid(zBar.symbol);
|
||||||
|
|
||||||
|
//
|
||||||
|
// XTriggerBlock iTB;
|
||||||
|
// has = GetNewestX121TriggerBlock(
|
||||||
|
// _Symbol,
|
||||||
|
// _Period,
|
||||||
|
// iTB //
|
||||||
|
// );
|
||||||
|
// if (has)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// // Check Newest TB is Newer Than Exists TB ...
|
||||||
|
// bool canPass =
|
||||||
|
// !eaTB.IsValid()
|
||||||
|
// ? true
|
||||||
|
// : iTB.ToIndex() < eaTB.ToIndex();
|
||||||
|
// if (canPass)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// eaTB = iTB;
|
||||||
|
// eaSignal = iTB.signal;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Prepare eaConditions if Reuqired ...
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
//
|
||||||
|
// has = eaSignal.IsValid();
|
||||||
|
// if (has)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// // Here we ensure which has a New Signal and must
|
||||||
|
// // prepare and Execute it ...
|
||||||
|
// Print("new Signal Detected ...");
|
||||||
|
// }
|
||||||
|
|
||||||
|
//
|
||||||
|
// eaTB.Clean();
|
||||||
|
// zBar.Clean();
|
||||||
|
// cBar.Clean();
|
||||||
|
// eaSignal.Clean();
|
||||||
|
// eaConditions.Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Handle On Trade Event ...
|
||||||
|
void OnTrade()
|
||||||
|
{
|
||||||
|
eaTrade.HandleOnTrade();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// On Timer ...
|
||||||
|
void OnTimer()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Chart Event Handler ...
|
||||||
|
void OnChartEvent(
|
||||||
|
const int id,
|
||||||
|
const long &lparam,
|
||||||
|
const double &dparam,
|
||||||
|
const string &sparam //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Event Listeners ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle StopLoss Triggered Positions ...
|
||||||
|
*
|
||||||
|
* @param deal: XDeal instance ...
|
||||||
|
*/
|
||||||
|
void OnStopLossTriggered(const XDeal &deal)
|
||||||
|
{
|
||||||
|
eaTradeManager.HandleSL(deal);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle Take Profit Triggered Positions ...
|
||||||
|
*
|
||||||
|
* @param deal: XDeal instance ...
|
||||||
|
*/
|
||||||
|
void OnTakeProfitTriggered(const XDeal &deal)
|
||||||
|
{
|
||||||
|
eaTradeManager.HandleTP(deal);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle Force Close a Position ...
|
||||||
|
*
|
||||||
|
* @param ticket: ULONG ...
|
||||||
|
* @param position: XPosition instance ...
|
||||||
|
* @param comment: string ...
|
||||||
|
*/
|
||||||
|
void OnPositionForceClosed(
|
||||||
|
const ulong ticket,
|
||||||
|
const XPosition &position,
|
||||||
|
const string comment //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
eaTradeManager.HandleForceClose(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle Position Partially Closed Event ...
|
||||||
|
*
|
||||||
|
* @param ticket: ULONG ...
|
||||||
|
* @param profit: double ...
|
||||||
|
* @param comment: string ...
|
||||||
|
*/
|
||||||
|
void OnPositionPartiallyClosed(
|
||||||
|
const ulong ticket,
|
||||||
|
const double profit,
|
||||||
|
const string comment //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
eaTradeManager.HandlePartiallyClosed(
|
||||||
|
ticket,
|
||||||
|
profit,
|
||||||
|
comment //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle Deals Changes ...
|
||||||
|
*
|
||||||
|
* @param count: Integer, Number of Changes ...
|
||||||
|
*/
|
||||||
|
void OnDealsChanged(int count)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle Orders Changes ...
|
||||||
|
*
|
||||||
|
* @param count: Integer, Number of Changes ...
|
||||||
|
*/
|
||||||
|
void OnOrdersChanged(int count)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle Positions Changes ...
|
||||||
|
*
|
||||||
|
* @param count: Integer, Number of Changes ...
|
||||||
|
*/
|
||||||
|
void OnPositionsChanged(int count)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Custom Functions ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate all Inputs of Expert Adviser ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool ValidateInputs()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
string errMessage = "";
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isCommonValid = (
|
||||||
|
//
|
||||||
|
eaSlippage > 0 &&
|
||||||
|
eaMagicNumber > 0
|
||||||
|
//
|
||||||
|
);
|
||||||
|
if (!isCommonValid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
errMessage += "common configurations error;" + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
// Common ...
|
||||||
|
isCommonValid &&
|
||||||
|
//
|
||||||
|
// Otere ...
|
||||||
|
true
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Since here Logger not Initiallized, we Use Raw Print Command ...
|
||||||
|
Print(ShortName + " Errors: \n", errMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize Timer ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool InitTimer()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// TODO: Initialize Timer if necessary ...
|
||||||
|
// result = EventSetTimer(1);
|
||||||
|
// result = EventSetMillisecondTimer(100);
|
||||||
|
result = true;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroy Timer ...
|
||||||
|
*/
|
||||||
|
void DestroyTimer()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// TODO: Use This ...
|
||||||
|
// EventKillTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initial Volume Manager Class Based on Given Configuration ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool InitVolume()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
eaVolume = new XCVolume();
|
||||||
|
|
||||||
|
//
|
||||||
|
result = eaVolume.Init(
|
||||||
|
eaVolumeSelect,
|
||||||
|
eaStaticVoluem,
|
||||||
|
eaDynamicVolumeStepBalance,
|
||||||
|
eaDynamicVolumeStepVolume,
|
||||||
|
eaConstantRiskBalance,
|
||||||
|
eaConstantPercent,
|
||||||
|
eaConstantBalance //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initial Requirements of EA ...
|
||||||
|
*/
|
||||||
|
void InitRequirements()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Initial Bar Tracker ...
|
||||||
|
eaBarTraker.Init(
|
||||||
|
_Symbol,
|
||||||
|
_Period //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Preparing Tags ...
|
||||||
|
eaTag =
|
||||||
|
(IsValid(eaLogSuffix)
|
||||||
|
? eaLogSuffix + "_"
|
||||||
|
: "") +
|
||||||
|
ShortName;
|
||||||
|
|
||||||
|
//
|
||||||
|
eaAlert = new XCAlert();
|
||||||
|
eaAlert.SetPrefix(eaLogSuffix);
|
||||||
|
eaAlert.SetLogAlerts(eaLogAlerts);
|
||||||
|
eaAlert.SetMailAlerts(eaMailAlerts);
|
||||||
|
eaAlert.SetPushAlerts(eaPushAlerts);
|
||||||
|
eaAlert.SetEnableAlerts(eaEnableAlerts);
|
||||||
|
eaAlert.SetTerminalAlerts(eaTerminalAlerts);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Objects ...
|
||||||
|
eaObjects = new CArrayObj();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Configure XCA ...
|
||||||
|
eaInputs.Default();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Hide all Visible Buffers ...
|
||||||
|
eaInputs.Hide();
|
||||||
|
|
||||||
|
//
|
||||||
|
// we Can make Show all requirements here ...
|
||||||
|
|
||||||
|
//
|
||||||
|
eaInputs.showATRBand = true;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Signal ...
|
||||||
|
// eaInputs.signalR2R = eaSignalR2R;
|
||||||
|
// eaInputs.slAtrMultiplier = eaSLAtrMultiplier;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Set Validators ...
|
||||||
|
// eaInputs.forceHasSwing = eaForceHasSwing;
|
||||||
|
// eaInputs.forceObBarType = eaForceObBarType;
|
||||||
|
// eaInputs.forceOBFVGBarType = eaForceOBFVGBarType;
|
||||||
|
// eaInputs.forceHasFLiquidity = eaForceHasFLiquidity;
|
||||||
|
// eaInputs.forceHasRLiquidity = eaForceHasRLiquidity;
|
||||||
|
// eaInputs.validateGapSequence = eaValidateGapSequence;
|
||||||
|
// eaInputs.validateBlockEdgeBreakout = eaValidateBlockEdgeBreakout;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Set Filters ...
|
||||||
|
// eaInputs.filterBasedOnPV = eaFilterBasedOnPV;
|
||||||
|
// eaInputs.filterBasedOnSar = eaFilterBasedOnSar;
|
||||||
|
// eaInputs.filterBasedOnRSI = eaFilterBasedOnRSI;
|
||||||
|
// eaInputs.filterBasedOnADX = eaFilterBasedOnADX;
|
||||||
|
// eaInputs.filterBasedOnATR = eaFilterBasedOnATR;
|
||||||
|
// eaInputs.filterBasedOnTrend = eaFilterBasedOnTrend;
|
||||||
|
// eaInputs.filterBasedOnDelta = eaFilterBasedOnDelta;
|
||||||
|
// eaInputs.filterBasedOnVolume = eaFilterBasedOnVolume;
|
||||||
|
// eaInputs.filterBasedOnSignalBar = eaFilterBasedOnSignalBar;
|
||||||
|
// eaInputs.filterBasedOnHKSignalBar = eaFilterBasedOnHKSignalBar;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Alerts ...
|
||||||
|
// // eaInputs.alertPrefix = eaTag;
|
||||||
|
// // eaInputs.logAlerts = eaLogAlerts;
|
||||||
|
// // eaInputs.pushAlerts = eaMailAlerts;
|
||||||
|
// // eaInputs.mailAlerts = eaPushAlerts;
|
||||||
|
// // eaInputs.terminalAlerts = eaTerminalAlerts;
|
||||||
|
|
||||||
|
//
|
||||||
|
// eaHelper = new XCX121XCatbHelper();
|
||||||
|
// bool isInited = eaHelper.Init(
|
||||||
|
// _Symbol,
|
||||||
|
// _Period,
|
||||||
|
// eaInputs //
|
||||||
|
// );
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // EA Trade ...
|
||||||
|
// eaTrade = new XCTrade(
|
||||||
|
// eaSlippage,
|
||||||
|
// eaMagicNumber,
|
||||||
|
// eaMaxAllowedSpread,
|
||||||
|
// eaMaxAllowedPositions,
|
||||||
|
// eaMaxAllowedDrawdownFactor //
|
||||||
|
// );
|
||||||
|
// eaTrade.AddOnStopLossEventHandler(OnStopLossTriggered);
|
||||||
|
// eaTrade.AddOnTakeProfitEventHandler(OnTakeProfitTriggered);
|
||||||
|
// eaTrade.AddOnForceClosePositionEventHandler(OnPositionForceClosed);
|
||||||
|
// eaTrade.AddOnPartialClosePositionEventHandler(OnPositionPartiallyClosed);
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // EA Trae Manager ...
|
||||||
|
// eaTradeManager = new XCXCAEATradeManager(
|
||||||
|
// eaTrade //
|
||||||
|
// );
|
||||||
|
// eaTradeManager.SaveTrades(true);
|
||||||
|
// eaTradeManager.SetAlertEnableAlerts(eaEnableAlerts);
|
||||||
|
// eaTradeManager.SetAlertPrefix(eaTag);
|
||||||
|
// eaTradeManager.SetAlertLogAlerts(eaLogAlerts);
|
||||||
|
// eaTradeManager.SetAlertMailAlerts(eaMailAlerts);
|
||||||
|
// eaTradeManager.SetAlertPushAlerts(eaPushAlerts);
|
||||||
|
// eaTradeManager.SetAlertTerminalAlerts(eaTerminalAlerts);
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Setting Trade Reports ...
|
||||||
|
// eaTradeManager
|
||||||
|
// .SetTradeReports(
|
||||||
|
// eaReportTrades,
|
||||||
|
// eaReportSignals,
|
||||||
|
// eaReportProtector,
|
||||||
|
// eaReportAfterTradesBalance //
|
||||||
|
// );
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Setting Trade Permissions ...
|
||||||
|
// eaTradeManager
|
||||||
|
// .SetTradePermissions(
|
||||||
|
// eaAllowTrade,
|
||||||
|
// eaAllowLongs,
|
||||||
|
// eaAllowShorts //
|
||||||
|
// );
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Setting Trade Restrictions ...
|
||||||
|
// eaTradeManager
|
||||||
|
// .SetTradeRestrictions(
|
||||||
|
// eaRestrictionsPeriod,
|
||||||
|
// eaMaxAllowedTPs,
|
||||||
|
// eaMaxAllowedSLs,
|
||||||
|
// eaMaxAllowedTrades //
|
||||||
|
// );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handling Time Reporting ...
|
||||||
|
*/
|
||||||
|
void HandleTimeReport()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (eaAlert == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Monthly Report ....
|
||||||
|
if (eaReportNewMonths &&
|
||||||
|
eaTimeTracker.IsNewMonth())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
string msg = "New Month ...";
|
||||||
|
|
||||||
|
//
|
||||||
|
eaAlert.Alert(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Weekly Report ....
|
||||||
|
if (eaReportNewWeeks &&
|
||||||
|
eaTimeTracker.IsNewWeek())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
string msg = "New Week ...";
|
||||||
|
|
||||||
|
//
|
||||||
|
eaAlert.Alert(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Daily Report ....
|
||||||
|
if (eaReportNewDays &&
|
||||||
|
eaTimeTracker.IsNewDay())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
string msg = "New Day ...";
|
||||||
|
|
||||||
|
//
|
||||||
|
eaAlert.Alert(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Hourly Report ....
|
||||||
|
if (eaReportNewHours &&
|
||||||
|
eaTimeTracker.IsNewHour())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
string msg = "New Hour ...";
|
||||||
|
|
||||||
|
//
|
||||||
|
eaAlert.Alert(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Apply Signal Targets ...
|
||||||
|
// void ApplySignalTargets(XSignal &signal)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// bool has = signal.IsValid();
|
||||||
|
// if (!has)
|
||||||
|
// {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Clean Signal Targets ...
|
||||||
|
// Clean(signal.targets);
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Calculate Requirements ...
|
||||||
|
// double r2r = 1;
|
||||||
|
// // maxAllowedR2R > 0
|
||||||
|
// // ? maxAllowedR2R
|
||||||
|
// // : 1;
|
||||||
|
// double risk = signal.GetRisk();
|
||||||
|
// double reward = risk * r2r;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// double isLong = IsLong(signal.type);
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Handling Signal TP ...
|
||||||
|
// signal.tp =
|
||||||
|
// isLong
|
||||||
|
// ? signal.entry + reward
|
||||||
|
// : signal.entry - reward;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Try to Apply Money Management ...
|
||||||
|
|
||||||
|
// //
|
||||||
|
// if (r2r <= 1)
|
||||||
|
// {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // XTarget iTarget;
|
||||||
|
|
||||||
|
// // //
|
||||||
|
// // // Partial Close 0.5 of Position on Reward 1 ...
|
||||||
|
// // reward = risk * 1;
|
||||||
|
// // iTarget.target =
|
||||||
|
// // isLong
|
||||||
|
// // ? signal.entry + reward
|
||||||
|
// // : signal.entry - reward;
|
||||||
|
// // iTarget.volumeMultiplier = 0.5;
|
||||||
|
|
||||||
|
// // //
|
||||||
|
// // AddRef(iTarget, signal.targets);
|
||||||
|
// // iTarget.Clean();
|
||||||
|
|
||||||
|
// // //
|
||||||
|
// // if (r2r <= 2)
|
||||||
|
// // {
|
||||||
|
// // return;
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Making Loop ...
|
||||||
|
// // for (int i = 2; i < ((int)r2r - 1); i++)
|
||||||
|
// // {
|
||||||
|
// // //
|
||||||
|
// // iTarget.Clean();
|
||||||
|
|
||||||
|
// // //
|
||||||
|
// // reward = i * risk;
|
||||||
|
// // iTarget.target =
|
||||||
|
// // isLong
|
||||||
|
// // ? signal.entry + reward
|
||||||
|
// // : signal.entry - reward;
|
||||||
|
// // iTarget.volumeMultiplier = 1 / (r2r - 2);
|
||||||
|
|
||||||
|
// // //
|
||||||
|
// // AddRef(iTarget, signal.targets);
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Sort Targets ...
|
||||||
|
// ENUM_X_DIRECTION sortingDir =
|
||||||
|
// isLong
|
||||||
|
// ? X_DIRECTION_BULLISH
|
||||||
|
// : X_DIRECTION_BEARISH;
|
||||||
|
// ApplySortOnTargets(
|
||||||
|
// sortingDir,
|
||||||
|
// signal.targets //
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
static XTriggerBlock mX121TriggerBlocks[];
|
||||||
|
|
||||||
|
//
|
||||||
|
int HasX121TriggerBlocks()
|
||||||
|
{
|
||||||
|
return HasChild(mX121TriggerBlocks);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int CountX121TriggerBlocks()
|
||||||
|
{
|
||||||
|
return ArraySize(mX121TriggerBlocks);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
void CleanX121TriggerBlocks(int maxAllowed = 0)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (maxAllowed <= 0)
|
||||||
|
{
|
||||||
|
Clean(mX121TriggerBlocks);
|
||||||
|
}
|
||||||
|
else if (maxAllowed > 0)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
CleanupArray(
|
||||||
|
mX121TriggerBlocks,
|
||||||
|
maxAllowed //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool GetNewestX121TriggerBlock(
|
||||||
|
string forSymbol,
|
||||||
|
ENUM_TIMEFRAMES forPeriod,
|
||||||
|
XTriggerBlock &tb //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
tb.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
IsValid(forSymbol) &&
|
||||||
|
IsValid(forPeriod) &&
|
||||||
|
HasX121TriggerBlocks();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Loop Through Trigger Blocks to Find Filtered Newest ...
|
||||||
|
int count = CountX121TriggerBlocks();
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool canSet = !tb.IsValid()
|
||||||
|
? true
|
||||||
|
: tb.ToIndex() < mX121TriggerBlocks[i].ToIndex();
|
||||||
|
if (canSet)
|
||||||
|
{
|
||||||
|
tb = mX121TriggerBlocks[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = tb.IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
tb.Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Add Trigger Block to Collection
|
||||||
|
// and Cleanup Unuseds ...
|
||||||
|
AddRef(
|
||||||
|
tb,
|
||||||
|
mX121TriggerBlocks //
|
||||||
|
);
|
||||||
|
CleanX121TriggerBlocks(20);
|
||||||
+184
-83
@@ -21,6 +21,8 @@
|
|||||||
//
|
//
|
||||||
// Include Common Library ...
|
// Include Common Library ...
|
||||||
#include "../Classes/x-saherelm.x-alert.class.mq5"
|
#include "../Classes/x-saherelm.x-alert.class.mq5"
|
||||||
|
#include "../Classes/x-saherelm.x-bar.analyser.class.mq5"
|
||||||
|
#include "../Classes/x-saherelm.x-poi.drawer.class.mq5"
|
||||||
#include "../Classes/x-saherelm.x-trade.class.mq5"
|
#include "../Classes/x-saherelm.x-trade.class.mq5"
|
||||||
#include "../Classes/x-saherelm.x-volume.class.mq5"
|
#include "../Classes/x-saherelm.x-volume.class.mq5"
|
||||||
#include "../Helpers/x-saherelm.x121.xcatb.helper.mq5"
|
#include "../Helpers/x-saherelm.x121.xcatb.helper.mq5"
|
||||||
@@ -107,11 +109,11 @@ input string eaCloseAllOpenTradesAt = "";
|
|||||||
// Here we Provider All Requirements for
|
// Here we Provider All Requirements for
|
||||||
// Configuring Alert Provider ...
|
// Configuring Alert Provider ...
|
||||||
input group "Alert";
|
input group "Alert";
|
||||||
input bool eaEnableAlerts = true; // Enable Alerts
|
input bool eaEnableAlerts = true; // Enable Alerts
|
||||||
input bool eaLogAlerts = true; // Log Alerts
|
input bool eaLogAlerts = true; // Log Alerts
|
||||||
input bool eaMailAlerts = false; // Mail Alerts
|
input bool eaMailAlerts = false; // Mail Alerts
|
||||||
input bool eaPushAlerts = true; // Push Alerts
|
input bool eaPushAlerts = true; // Push Alerts
|
||||||
input bool eaTerminalAlerts = true; // Terminal Alerts
|
input bool eaTerminalAlerts = false; // Terminal Alerts
|
||||||
|
|
||||||
//
|
//
|
||||||
// Time Report ...
|
// Time Report ...
|
||||||
@@ -132,23 +134,18 @@ input bool eaReportAfterTradesBalance = true; // Report Balance after a Trade Fi
|
|||||||
XCAlert *eaAlert;
|
XCAlert *eaAlert;
|
||||||
XCTrade *eaTrade;
|
XCTrade *eaTrade;
|
||||||
XSignal eaSignal;
|
XSignal eaSignal;
|
||||||
|
string eaTag = "";
|
||||||
XCVolume *eaVolume;
|
XCVolume *eaVolume;
|
||||||
X121XCatbInputs eaInputs;
|
CArrayObj *eaObjects;
|
||||||
XCX121XCatbHelper *eaHelper;
|
XCPOIDrawer *eaDrawer;
|
||||||
XBarTracker eaBarTraker;
|
XBarTracker eaBarTraker;
|
||||||
|
X121XCatbInputs eaInputs;
|
||||||
XTimeTracker eaTimeTracker;
|
XTimeTracker eaTimeTracker;
|
||||||
|
XCX121XCatbHelper *eaHelper;
|
||||||
|
XCBarAnalyser *eaBarAnalyser;
|
||||||
XCXCAEATradeManager *eaTradeManager;
|
XCXCAEATradeManager *eaTradeManager;
|
||||||
XCAEAStrategyConditions eaConditions;
|
XCAEAStrategyConditions eaConditions;
|
||||||
|
|
||||||
//
|
|
||||||
XTriggerBlock eaTB;
|
|
||||||
|
|
||||||
//
|
|
||||||
CArrayObj *eaObjects;
|
|
||||||
|
|
||||||
//
|
|
||||||
string eaTag = "";
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Event Handlers ...
|
// Event Handlers ...
|
||||||
|
|
||||||
@@ -210,10 +207,18 @@ void OnDeinit(const int reason)
|
|||||||
delete eaTrade;
|
delete eaTrade;
|
||||||
ZeroMemory(eaTrade);
|
ZeroMemory(eaTrade);
|
||||||
|
|
||||||
|
//
|
||||||
|
delete eaDrawer;
|
||||||
|
ZeroMemory(eaDrawer);
|
||||||
|
|
||||||
//
|
//
|
||||||
delete eaVolume;
|
delete eaVolume;
|
||||||
ZeroMemory(eaVolume);
|
ZeroMemory(eaVolume);
|
||||||
|
|
||||||
|
//
|
||||||
|
delete eaBarAnalyser;
|
||||||
|
ZeroMemory(eaBarAnalyser);
|
||||||
|
|
||||||
//
|
//
|
||||||
eaSignal.Clean();
|
eaSignal.Clean();
|
||||||
eaBarTraker.Clean();
|
eaBarTraker.Clean();
|
||||||
@@ -239,6 +244,11 @@ void OnTick()
|
|||||||
eaSignal.Clean();
|
eaSignal.Clean();
|
||||||
eaConditions.Clean();
|
eaConditions.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
bool has = false;
|
||||||
|
int barIndex = 0;
|
||||||
|
int cBarIndex = 0;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check Bar Processing ...
|
// Check Bar Processing ...
|
||||||
if (!eaBarTraker.CanProcessBar())
|
if (!eaBarTraker.CanProcessBar())
|
||||||
@@ -247,16 +257,13 @@ void OnTick()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
bool has = false;
|
// Reading Required Bars ...
|
||||||
|
|
||||||
//
|
|
||||||
// Retrieve Bars ...
|
|
||||||
XOHCL zBar;
|
XOHCL zBar;
|
||||||
XOHCL cBar;
|
XOHCL cBar;
|
||||||
has = zBar.Init(
|
has = zBar.Init(
|
||||||
_Symbol,
|
_Symbol,
|
||||||
_Period,
|
_Period,
|
||||||
0 //
|
barIndex //
|
||||||
);
|
);
|
||||||
has =
|
has =
|
||||||
has &&
|
has &&
|
||||||
@@ -272,50 +279,131 @@ void OnTick()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
double bid = GetBid(zBar.symbol);
|
cBarIndex = barIndex + 1;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// Update All Required Buffers ...
|
||||||
|
eaHelper.Update(cBarIndex);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Trigger Block Detected or Not ...
|
||||||
XTriggerBlock iTB;
|
XTriggerBlock iTB;
|
||||||
has = GetNewestX121TriggerBlock(
|
has = DetectTriggerBlock(
|
||||||
|
//
|
||||||
_Symbol,
|
_Symbol,
|
||||||
_Period,
|
_Period,
|
||||||
iTB //
|
//
|
||||||
|
iTB,
|
||||||
|
//
|
||||||
|
eaBarAnalyser,
|
||||||
|
//
|
||||||
|
// Required Buffers ...
|
||||||
|
eaHelper.atrBuffer,
|
||||||
|
eaHelper.rsiBuffer,
|
||||||
|
eaHelper.adxBuffer,
|
||||||
|
eaHelper.adxpBuffer,
|
||||||
|
eaHelper.adxnBuffer,
|
||||||
|
eaHelper.peakBuffer,
|
||||||
|
eaHelper.valeBuffer,
|
||||||
|
eaHelper.deltaBuffer,
|
||||||
|
eaHelper.sarBuffer,
|
||||||
|
eaHelper.sarStateBuffer,
|
||||||
|
eaHelper.trendBuffer,
|
||||||
|
eaHelper.trendStateBuffer,
|
||||||
|
eaHelper.atrUpperBuffer,
|
||||||
|
eaHelper.atrLowerBuffer,
|
||||||
|
eaHelper.sBarOpenBuffer,
|
||||||
|
eaHelper.sBarCloseBuffer,
|
||||||
|
eaHelper.hkSBarOpenBuffer,
|
||||||
|
eaHelper.hkSBarCloseBuffer,
|
||||||
|
eaHelper.peakGoldenBuffer,
|
||||||
|
eaHelper.valeGoldenBuffer,
|
||||||
|
eaHelper.deltaSignalBuffer,
|
||||||
|
eaHelper.bullishVolumeSignalBuffer,
|
||||||
|
eaHelper.bearishVolumeSignalBuffer,
|
||||||
|
//
|
||||||
|
cBarIndex,
|
||||||
|
//
|
||||||
|
// Signalling ...
|
||||||
|
eaInputs.signalR2R,
|
||||||
|
eaInputs.slAtrMultiplier,
|
||||||
|
//
|
||||||
|
// Configs ...
|
||||||
|
eaInputs.rsiOBLevel,
|
||||||
|
eaInputs.rsiOSLevel,
|
||||||
|
eaInputs.adxThreshold,
|
||||||
|
//
|
||||||
|
// Validators ...
|
||||||
|
eaInputs.forceObBarType,
|
||||||
|
eaInputs.forceOBFVGBarType,
|
||||||
|
eaInputs.forceHasSwing,
|
||||||
|
eaInputs.forceHasFLiquidity,
|
||||||
|
eaInputs.forceHasRLiquidity,
|
||||||
|
eaInputs.validateGapSequence,
|
||||||
|
eaInputs.validateBlockEdgeBreakout,
|
||||||
|
//
|
||||||
|
// Filters ...
|
||||||
|
eaInputs.filterBasedOnPV,
|
||||||
|
eaInputs.filterBasedOnSar,
|
||||||
|
eaInputs.filterBasedOnRSI,
|
||||||
|
eaInputs.filterBasedOnADX,
|
||||||
|
eaInputs.filterBasedOnATR,
|
||||||
|
eaInputs.filterBasedOnTrend,
|
||||||
|
eaInputs.filterBasedOnDelta,
|
||||||
|
eaInputs.filterBasedOnVolume,
|
||||||
|
eaInputs.filterBasedOnSignalBar,
|
||||||
|
eaInputs.filterBasedOnHKSignalBar //
|
||||||
);
|
);
|
||||||
if (has)
|
if (has)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Check Newest TB is Newer Than Exists TB ...
|
eaBarTraker.Waits();
|
||||||
bool canPass =
|
|
||||||
!eaTB.IsValid()
|
|
||||||
? true
|
|
||||||
: iTB.ToIndex() < eaTB.ToIndex();
|
|
||||||
if (canPass)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
eaTB = iTB;
|
|
||||||
eaSignal = iTB.signal;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Prepare eaConditions if Reuqired ...
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
has = eaSignal.IsValid();
|
|
||||||
if (has)
|
|
||||||
{
|
|
||||||
//
|
//
|
||||||
// Here we ensure which has a New Signal and must
|
eaSignal = iTB.signal;
|
||||||
// prepare and Execute it ...
|
|
||||||
Print("new Signal Detected ...");
|
//
|
||||||
|
// Here we Can Fill eaConditions ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Signal Type ...
|
||||||
|
bool isLong = IsLong(eaSignal.type);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Update Entry ...
|
||||||
|
eaSignal.entry = GetEntry(
|
||||||
|
eaSignal.symbol,
|
||||||
|
eaSignal.type //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Update Signal Targets ...
|
||||||
|
UpdateSignalTargets(eaSignal);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Handle Volume Management ...
|
||||||
|
double iVolume = eaVolume.CalculateVolume(eaSignal);
|
||||||
|
if (iVolume > X_MIN_VOLUME &&
|
||||||
|
iVolume != eaSignal.volume)
|
||||||
|
{
|
||||||
|
eaSignal.volume = iVolume;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Execute Signal ...
|
||||||
|
has = eaTradeManager.Execute(
|
||||||
|
eaSignal,
|
||||||
|
eaConditions //
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// eaTB.Clean();
|
// Cleanup Resources ...
|
||||||
|
|
||||||
|
//
|
||||||
|
iTB.Clean();
|
||||||
zBar.Clean();
|
zBar.Clean();
|
||||||
cBar.Clean();
|
cBar.Clean();
|
||||||
eaSignal.Clean();
|
|
||||||
eaConditions.Clean();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -543,6 +631,13 @@ bool InitVolume()
|
|||||||
*/
|
*/
|
||||||
void InitRequirements()
|
void InitRequirements()
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
// Initial Bar Tracker ...
|
||||||
|
eaBarTraker.Init(
|
||||||
|
_Symbol,
|
||||||
|
_Period //
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Preparing Tags ...
|
// Preparing Tags ...
|
||||||
eaTag =
|
eaTag =
|
||||||
@@ -552,11 +647,13 @@ void InitRequirements()
|
|||||||
ShortName;
|
ShortName;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Initial Bar Tracker ...
|
eaAlert = new XCAlert();
|
||||||
eaBarTraker.Init(
|
eaAlert.SetPrefix(eaLogSuffix);
|
||||||
_Symbol,
|
eaAlert.SetLogAlerts(eaLogAlerts);
|
||||||
_Period //
|
eaAlert.SetMailAlerts(eaMailAlerts);
|
||||||
);
|
eaAlert.SetPushAlerts(eaPushAlerts);
|
||||||
|
eaAlert.SetEnableAlerts(eaEnableAlerts);
|
||||||
|
eaAlert.SetTerminalAlerts(eaTerminalAlerts);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Objects ...
|
// Objects ...
|
||||||
@@ -573,6 +670,9 @@ void InitRequirements()
|
|||||||
//
|
//
|
||||||
// we Can make Show all requirements here ...
|
// we Can make Show all requirements here ...
|
||||||
|
|
||||||
|
//
|
||||||
|
eaInputs.showATRBand = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Signal ...
|
// Signal ...
|
||||||
eaInputs.signalR2R = eaSignalR2R;
|
eaInputs.signalR2R = eaSignalR2R;
|
||||||
@@ -604,10 +704,10 @@ void InitRequirements()
|
|||||||
//
|
//
|
||||||
// Alerts ...
|
// Alerts ...
|
||||||
eaInputs.alertPrefix = eaTag;
|
eaInputs.alertPrefix = eaTag;
|
||||||
eaInputs.logAlerts = eaLogAlerts;
|
eaInputs.logAlerts = false; // eaLogAlerts;
|
||||||
eaInputs.pushAlerts = eaMailAlerts;
|
eaInputs.pushAlerts = false; // eaMailAlerts;
|
||||||
eaInputs.mailAlerts = eaPushAlerts;
|
eaInputs.mailAlerts = false; // eaPushAlerts;
|
||||||
eaInputs.terminalAlerts = eaTerminalAlerts;
|
eaInputs.terminalAlerts = false; // eaTerminalAlerts;
|
||||||
|
|
||||||
//
|
//
|
||||||
eaHelper = new XCX121XCatbHelper();
|
eaHelper = new XCX121XCatbHelper();
|
||||||
@@ -618,15 +718,8 @@ void InitRequirements()
|
|||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// EA Alert ...
|
eaDrawer = new XCPOIDrawer();
|
||||||
eaAlert = new XCAlert(
|
eaBarAnalyser = new XCBarAnalyser();
|
||||||
eaTag,
|
|
||||||
eaEnableAlerts,
|
|
||||||
eaLogAlerts,
|
|
||||||
eaTerminalAlerts,
|
|
||||||
eaMailAlerts,
|
|
||||||
eaPushAlerts //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// EA Trade ...
|
// EA Trade ...
|
||||||
@@ -648,11 +741,11 @@ void InitRequirements()
|
|||||||
eaTrade //
|
eaTrade //
|
||||||
);
|
);
|
||||||
eaTradeManager.SaveTrades(true);
|
eaTradeManager.SaveTrades(true);
|
||||||
eaTradeManager.SetAlertEnableAlerts(eaEnableAlerts);
|
|
||||||
eaTradeManager.SetAlertPrefix(eaTag);
|
eaTradeManager.SetAlertPrefix(eaTag);
|
||||||
eaTradeManager.SetAlertLogAlerts(eaLogAlerts);
|
eaTradeManager.SetAlertLogAlerts(eaLogAlerts);
|
||||||
eaTradeManager.SetAlertMailAlerts(eaMailAlerts);
|
eaTradeManager.SetAlertMailAlerts(eaMailAlerts);
|
||||||
eaTradeManager.SetAlertPushAlerts(eaPushAlerts);
|
eaTradeManager.SetAlertPushAlerts(eaPushAlerts);
|
||||||
|
eaTradeManager.SetAlertEnableAlerts(eaEnableAlerts);
|
||||||
eaTradeManager.SetAlertTerminalAlerts(eaTerminalAlerts);
|
eaTradeManager.SetAlertTerminalAlerts(eaTerminalAlerts);
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -690,6 +783,12 @@ void InitRequirements()
|
|||||||
*/
|
*/
|
||||||
void HandleTimeReport()
|
void HandleTimeReport()
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
if (eaAlert == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Monthly Report ....
|
// Monthly Report ....
|
||||||
if (eaReportNewMonths &&
|
if (eaReportNewMonths &&
|
||||||
@@ -699,7 +798,7 @@ void HandleTimeReport()
|
|||||||
string msg = "New Month ...";
|
string msg = "New Month ...";
|
||||||
|
|
||||||
//
|
//
|
||||||
eaAlert.Alert(msg);
|
eaAlert.SendAlert(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -711,7 +810,7 @@ void HandleTimeReport()
|
|||||||
string msg = "New Week ...";
|
string msg = "New Week ...";
|
||||||
|
|
||||||
//
|
//
|
||||||
eaAlert.Alert(msg);
|
eaAlert.SendAlert(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -723,7 +822,7 @@ void HandleTimeReport()
|
|||||||
string msg = "New Day ...";
|
string msg = "New Day ...";
|
||||||
|
|
||||||
//
|
//
|
||||||
eaAlert.Alert(msg);
|
eaAlert.SendAlert(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -735,13 +834,14 @@ void HandleTimeReport()
|
|||||||
string msg = "New Hour ...";
|
string msg = "New Hour ...";
|
||||||
|
|
||||||
//
|
//
|
||||||
eaAlert.Alert(msg);
|
eaAlert.SendAlert(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
/**
|
||||||
// Apply Signal Targets ...
|
* Update Signal Targets ...
|
||||||
void ApplySignalTargets(XSignal &signal)
|
*/
|
||||||
|
void UpdateSignalTargets(XSignal &signal)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
bool has = signal.IsValid();
|
bool has = signal.IsValid();
|
||||||
@@ -756,10 +856,9 @@ void ApplySignalTargets(XSignal &signal)
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Calculate Requirements ...
|
// Calculate Requirements ...
|
||||||
double r2r = 1;
|
double r2r = eaSignalR2R > 0
|
||||||
// maxAllowedR2R > 0
|
? eaSignalR2R
|
||||||
// ? maxAllowedR2R
|
: 1;
|
||||||
// : 1;
|
|
||||||
double risk = signal.GetRisk();
|
double risk = signal.GetRisk();
|
||||||
double reward = risk * r2r;
|
double reward = risk * r2r;
|
||||||
|
|
||||||
@@ -777,10 +876,10 @@ void ApplySignalTargets(XSignal &signal)
|
|||||||
// Try to Apply Money Management ...
|
// Try to Apply Money Management ...
|
||||||
|
|
||||||
//
|
//
|
||||||
if (r2r <= 1)
|
// if (r2r <= 1)
|
||||||
{
|
// {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
//
|
//
|
||||||
// XTarget iTarget;
|
// XTarget iTarget;
|
||||||
@@ -834,3 +933,5 @@ void ApplySignalTargets(XSignal &signal)
|
|||||||
signal.targets //
|
signal.targets //
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
@@ -140,10 +140,14 @@ struct X121XCatbInputs
|
|||||||
bool showSar; // Show Sar
|
bool showSar; // Show Sar
|
||||||
bool showTrend; // Show Trend
|
bool showTrend; // Show Trend
|
||||||
bool showATRBand; // Show ATR Band
|
bool showATRBand; // Show ATR Band
|
||||||
bool showTrendBars; // Show Trend Bars
|
|
||||||
bool showSignalBars; // Show Signal Bars
|
bool showSignalBars; // Show Signal Bars
|
||||||
bool showHKSignalBars; // Show Hiken Ashi Signal Bars
|
bool showHKSignalBars; // Show Hiken Ashi Signal Bars
|
||||||
|
|
||||||
|
//
|
||||||
|
double rsiOBLevel; // RSI OB Level
|
||||||
|
double rsiOSLevel; // RSI OS Level
|
||||||
|
double adxThreshold; // ADX Threshold
|
||||||
|
|
||||||
//
|
//
|
||||||
int startCalculationForLastBars; // Calculate Last n Bars
|
int startCalculationForLastBars; // Calculate Last n Bars
|
||||||
|
|
||||||
@@ -204,7 +208,7 @@ struct X121XCatbInputs
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Alert ...
|
// Alert ...
|
||||||
alertPrefix = NULL; // Alert Prefix
|
alertPrefix = ""; // Alert Prefix
|
||||||
logAlerts = false; // Log Alerts
|
logAlerts = false; // Log Alerts
|
||||||
pushAlerts = false; // Push Alerts
|
pushAlerts = false; // Push Alerts
|
||||||
mailAlerts = false; // Mail Alerts
|
mailAlerts = false; // Mail Alerts
|
||||||
@@ -218,13 +222,17 @@ struct X121XCatbInputs
|
|||||||
showSar = false; // Show Sar
|
showSar = false; // Show Sar
|
||||||
showTrend = false; // Show Trend
|
showTrend = false; // Show Trend
|
||||||
showATRBand = false; // Show ATR Band
|
showATRBand = false; // Show ATR Band
|
||||||
showTrendBars = false; // Show Trend Bars
|
|
||||||
showSignalBars = false; // Show Signal Bars
|
showSignalBars = false; // Show Signal Bars
|
||||||
showHKSignalBars = false; // Show Hiken Ashi Signal Bars
|
showHKSignalBars = false; // Show Hiken Ashi Signal Bars
|
||||||
|
|
||||||
//
|
//
|
||||||
startCalculationForLastBars = 0; // Calculate Last n Bars
|
startCalculationForLastBars = 0; // Calculate Last n Bars
|
||||||
|
|
||||||
|
//
|
||||||
|
rsiOBLevel = 70.0; // RSI OB Level
|
||||||
|
rsiOSLevel = 30.0; // RSI OS Level
|
||||||
|
adxThreshold = 25.0; // ADX Threshold
|
||||||
|
|
||||||
//
|
//
|
||||||
ZeroMemory(this);
|
ZeroMemory(this);
|
||||||
}
|
}
|
||||||
@@ -276,11 +284,11 @@ struct X121XCatbInputs
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Alert ...
|
// Alert ...
|
||||||
alertPrefix = NULL; // Alert Prefix
|
alertPrefix = ""; // Alert Prefix
|
||||||
logAlerts = true; // Log Alerts
|
logAlerts = false; // Log Alerts
|
||||||
pushAlerts = false; // Push Alerts
|
pushAlerts = false; // Push Alerts
|
||||||
mailAlerts = false; // Mail Alerts
|
mailAlerts = false; // Mail Alerts
|
||||||
terminalAlerts = true; // Terminal Alerts
|
terminalAlerts = false; // Terminal Alerts
|
||||||
|
|
||||||
//
|
//
|
||||||
// Presentation ...
|
// Presentation ...
|
||||||
@@ -290,12 +298,16 @@ struct X121XCatbInputs
|
|||||||
showSar = false; // Show Sar
|
showSar = false; // Show Sar
|
||||||
showTrend = false; // Show Trend
|
showTrend = false; // Show Trend
|
||||||
showATRBand = false; // Show ATR Band
|
showATRBand = false; // Show ATR Band
|
||||||
showTrendBars = false; // Show Trend Bars
|
|
||||||
showSignalBars = false; // Show Signal Bars
|
showSignalBars = false; // Show Signal Bars
|
||||||
showHKSignalBars = false; // Show Hiken Ashi Signal Bars
|
showHKSignalBars = false; // Show Hiken Ashi Signal Bars
|
||||||
|
|
||||||
//
|
//
|
||||||
startCalculationForLastBars = 1500; // Calculate Last n Bars
|
startCalculationForLastBars = 1500; // Calculate Last n Bars
|
||||||
|
|
||||||
|
//
|
||||||
|
rsiOBLevel = 70.0; // RSI OB Level
|
||||||
|
rsiOSLevel = 30.0; // RSI OS Level
|
||||||
|
adxThreshold = 25.0; // ADX Threshold
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -308,7 +320,6 @@ struct X121XCatbInputs
|
|||||||
showSar = false;
|
showSar = false;
|
||||||
showTrend = false;
|
showTrend = false;
|
||||||
showATRBand = false;
|
showATRBand = false;
|
||||||
showTrendBars = false;
|
|
||||||
showSignalBars = false;
|
showSignalBars = false;
|
||||||
showHKSignalBars = false;
|
showHKSignalBars = false;
|
||||||
}
|
}
|
||||||
@@ -843,7 +854,6 @@ class XCX121XCatbHelper : public XCBaseHelper
|
|||||||
mInputs.showSar,
|
mInputs.showSar,
|
||||||
mInputs.showTrend,
|
mInputs.showTrend,
|
||||||
mInputs.showATRBand,
|
mInputs.showATRBand,
|
||||||
mInputs.showTrendBars,
|
|
||||||
mInputs.showSignalBars,
|
mInputs.showSignalBars,
|
||||||
mInputs.showHKSignalBars,
|
mInputs.showHKSignalBars,
|
||||||
mInputs.startCalculationForLastBars
|
mInputs.startCalculationForLastBars
|
||||||
@@ -2842,6 +2852,15 @@ class XCX121XCatbHelper : public XCBaseHelper
|
|||||||
//
|
//
|
||||||
// Tools ...
|
// Tools ...
|
||||||
|
|
||||||
|
//
|
||||||
|
void Update(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Calculate(barIndex);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
void Free() override
|
void Free() override
|
||||||
{
|
{
|
||||||
@@ -2897,7 +2916,7 @@ class XCX121XCatbHelper : public XCBaseHelper
|
|||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
int zIndex = barIndex;
|
int zIndex = barIndex;
|
||||||
|
|
||||||
|
|||||||
@@ -115,11 +115,11 @@ input bool filterBasedOnHKSignalBar = false; // Filter Based on Hiken Ashi Signa
|
|||||||
//
|
//
|
||||||
// Alert ...
|
// Alert ...
|
||||||
input group "Alerts";
|
input group "Alerts";
|
||||||
input string mAlertPrefix = ""; // Alert Prefix
|
input string mAlertPrefix = ""; // Alert Prefix
|
||||||
input bool _logAlerts = true; // Log Alerts
|
input bool _logAlerts = false; // Log Alerts
|
||||||
input bool _pushAlerts = false; // Push Alerts
|
input bool _pushAlerts = false; // Push Alerts
|
||||||
input bool _mailAlerts = false; // Mail Alerts
|
input bool _mailAlerts = false; // Mail Alerts
|
||||||
input bool _terminalAlerts = true; // Terminal Alerts
|
input bool _terminalAlerts = false; // Terminal Alerts
|
||||||
|
|
||||||
//
|
//
|
||||||
// Presentation ...
|
// Presentation ...
|
||||||
@@ -130,7 +130,6 @@ input bool showPVGolden = false; // Show PV Golden
|
|||||||
input bool showSar = false; // Show Sar
|
input bool showSar = false; // Show Sar
|
||||||
input bool showTrend = false; // Show Trend
|
input bool showTrend = false; // Show Trend
|
||||||
input bool showATRBand = false; // Show ATR Band
|
input bool showATRBand = false; // Show ATR Band
|
||||||
input bool showTrendBars = false; // Show Trend Bars
|
|
||||||
input bool showSignalBars = false; // Show Signal Bars
|
input bool showSignalBars = false; // Show Signal Bars
|
||||||
input bool showHKSignalBars = false; // Show Hiken Ashi Signal Bars
|
input bool showHKSignalBars = false; // Show Hiken Ashi Signal Bars
|
||||||
|
|
||||||
@@ -329,7 +328,7 @@ double trendColorBuffer[];
|
|||||||
|
|
||||||
//
|
//
|
||||||
#define sBarOpenBufferIndex 10
|
#define sBarOpenBufferIndex 10
|
||||||
double sBarOpenSBuffer[];
|
double sBarOpenBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
#define sBarHighBufferIndex 11
|
#define sBarHighBufferIndex 11
|
||||||
@@ -1182,8 +1181,8 @@ void DefineBuffers()
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Open ...
|
// Open ...
|
||||||
ArraySetAsSeries(sBarOpenSBuffer, true);
|
ArraySetAsSeries(sBarOpenBuffer, true);
|
||||||
SetIndexBuffer(sBarOpenBufferIndex, sBarOpenSBuffer, INDICATOR_DATA);
|
SetIndexBuffer(sBarOpenBufferIndex, sBarOpenBuffer, INDICATOR_DATA);
|
||||||
|
|
||||||
//
|
//
|
||||||
// High ...
|
// High ...
|
||||||
@@ -1975,7 +1974,7 @@ void CalculateValues(
|
|||||||
trendStateBuffer,
|
trendStateBuffer,
|
||||||
atrUpperBuffer,
|
atrUpperBuffer,
|
||||||
atrLowerBuffer,
|
atrLowerBuffer,
|
||||||
sBarOpenSBuffer,
|
sBarOpenBuffer,
|
||||||
sBarCloseBuffer,
|
sBarCloseBuffer,
|
||||||
hkSBarOpenBuffer,
|
hkSBarOpenBuffer,
|
||||||
hkSBarCloseBuffer,
|
hkSBarCloseBuffer,
|
||||||
@@ -2055,7 +2054,7 @@ void CalculateValues(
|
|||||||
}
|
}
|
||||||
else if (canAlert)
|
else if (canAlert)
|
||||||
{
|
{
|
||||||
mAlert.Alert(message);
|
mAlert.SendAlert(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2286,7 +2285,7 @@ void CalculateSBar(
|
|||||||
barIndex,
|
barIndex,
|
||||||
mAppliedLength,
|
mAppliedLength,
|
||||||
open,
|
open,
|
||||||
sBarOpenSBuffer,
|
sBarOpenBuffer,
|
||||||
barsSignalMethod //
|
barsSignalMethod //
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -2303,8 +2302,8 @@ void CalculateSBar(
|
|||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
double min = MathMin(sBarCloseBuffer[barIndex], sBarOpenSBuffer[barIndex]);
|
double min = MathMin(sBarCloseBuffer[barIndex], sBarOpenBuffer[barIndex]);
|
||||||
double max = MathMin(sBarCloseBuffer[barIndex], sBarOpenSBuffer[barIndex]);
|
double max = MathMin(sBarCloseBuffer[barIndex], sBarOpenBuffer[barIndex]);
|
||||||
|
|
||||||
//
|
//
|
||||||
sBarLowBuffer[barIndex] = min;
|
sBarLowBuffer[barIndex] = min;
|
||||||
@@ -2313,7 +2312,7 @@ void CalculateSBar(
|
|||||||
//
|
//
|
||||||
// Calculate HK Signal Color ...
|
// Calculate HK Signal Color ...
|
||||||
double iSignalColorValue =
|
double iSignalColorValue =
|
||||||
sBarOpenSBuffer[barIndex] < sBarCloseBuffer[barIndex]
|
sBarOpenBuffer[barIndex] < sBarCloseBuffer[barIndex]
|
||||||
? bullishColorIDX
|
? bullishColorIDX
|
||||||
: bearishColorIDX;
|
: bearishColorIDX;
|
||||||
sBarColorBuffer[barIndex] =
|
sBarColorBuffer[barIndex] =
|
||||||
|
|||||||
@@ -132,91 +132,11 @@ struct XTriggerBlock
|
|||||||
//
|
//
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
|
||||||
XTriggerBlock mX121TriggerBlocks[];
|
|
||||||
|
|
||||||
//
|
|
||||||
int HasX121TriggerBlocks()
|
|
||||||
{
|
|
||||||
return HasChild(mX121TriggerBlocks);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
int CountX121TriggerBlocks()
|
|
||||||
{
|
|
||||||
return ArraySize(mX121TriggerBlocks);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
void CleanX121TriggerBlocks(int maxAllowed = 0)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
if (maxAllowed <= 0)
|
|
||||||
{
|
|
||||||
Clean(mX121TriggerBlocks);
|
|
||||||
}
|
|
||||||
else if (maxAllowed > 0)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
CleanupArray(
|
|
||||||
mX121TriggerBlocks,
|
|
||||||
maxAllowed //
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
bool GetNewestX121TriggerBlock(
|
|
||||||
string forSymbol,
|
|
||||||
ENUM_TIMEFRAMES forPeriod,
|
|
||||||
XTriggerBlock &tb //
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
bool result = false;
|
|
||||||
|
|
||||||
//
|
|
||||||
tb.Clean();
|
|
||||||
|
|
||||||
//
|
|
||||||
result =
|
|
||||||
IsValid(forSymbol) &&
|
|
||||||
IsValid(forPeriod) &&
|
|
||||||
HasX121TriggerBlocks();
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Loop Through Trigger Blocks to Find Filtered Newest ...
|
|
||||||
int count = CountX121TriggerBlocks();
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
bool canSet = !tb.IsValid()
|
|
||||||
? true
|
|
||||||
: tb.ToIndex() < mX121TriggerBlocks[i].ToIndex();
|
|
||||||
if (canSet)
|
|
||||||
{
|
|
||||||
tb = mX121TriggerBlocks[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
result = tb.IsValid();
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
tb.Clean();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Extensions ...
|
// Extensions ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detect Trigger Block ...
|
||||||
bool DetectTriggerBlock(
|
bool DetectTriggerBlock(
|
||||||
//
|
//
|
||||||
string symbol,
|
string symbol,
|
||||||
@@ -290,36 +210,36 @@ bool DetectTriggerBlock(
|
|||||||
//
|
//
|
||||||
// Custom Configs ...
|
// Custom Configs ...
|
||||||
|
|
||||||
//
|
// //
|
||||||
_r2r = 2;
|
// _r2r = 2;
|
||||||
_slAtrMultiplier = 1;
|
// _slAtrMultiplier = 1;
|
||||||
|
|
||||||
//
|
// //
|
||||||
// Validators ...
|
// // Validators ...
|
||||||
_forceHasSwing = true;
|
// _forceHasSwing = true;
|
||||||
_forceObBarType = true;
|
// _forceObBarType = true;
|
||||||
_forceFVGBarType = true;
|
// _forceFVGBarType = true;
|
||||||
_validateGapSequence = true;
|
// _validateGapSequence = true;
|
||||||
|
|
||||||
//
|
// //
|
||||||
_forceHasFLiquidity = false;
|
// _forceHasFLiquidity = false;
|
||||||
_forceHasRLiquidity = false;
|
// _forceHasRLiquidity = false;
|
||||||
_validateBlockEdgeBreakout = true;
|
// _validateBlockEdgeBreakout = true;
|
||||||
|
|
||||||
//
|
// //
|
||||||
// Filters ...
|
// // Filters ...
|
||||||
_filterBasedOnPV = true;
|
// _filterBasedOnPV = true;
|
||||||
_filterBasedOnATR = true;
|
// _filterBasedOnATR = true;
|
||||||
_filterBasedOnDelta = true;
|
// _filterBasedOnDelta = true;
|
||||||
_filterBasedOnVolume = true;
|
// _filterBasedOnVolume = true;
|
||||||
|
|
||||||
//
|
// //
|
||||||
_filterBasedOnSar = true;
|
// _filterBasedOnSar = true;
|
||||||
_filterBasedOnRSI = false;
|
// _filterBasedOnRSI = false;
|
||||||
_filterBasedOnADX = false;
|
// _filterBasedOnADX = false;
|
||||||
_filterBasedOnTrend = false;
|
// _filterBasedOnTrend = false;
|
||||||
_filterBasedOnSignalBar = true;
|
// _filterBasedOnSignalBar = true;
|
||||||
_filterBasedOnHKSignalBar = true;
|
// _filterBasedOnHKSignalBar = true;
|
||||||
|
|
||||||
//
|
//
|
||||||
tb.Clean();
|
tb.Clean();
|
||||||
@@ -1098,15 +1018,6 @@ bool DetectTriggerBlock(
|
|||||||
targets,
|
targets,
|
||||||
slAdditional //
|
slAdditional //
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
|
||||||
// Add Trigger Block to Collection
|
|
||||||
// and Cleanup Unuseds ...
|
|
||||||
AddRef(
|
|
||||||
tb,
|
|
||||||
mX121TriggerBlocks //
|
|
||||||
);
|
|
||||||
CleanX121TriggerBlocks(20);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user