last ...
This commit is contained in:
+215
-112
@@ -91,10 +91,12 @@ input double eaConstantBalance = 0.0; // Constant Ba
|
||||
|
||||
//
|
||||
// Management ...
|
||||
// eaSessions => (SYDNEY_02:00_14:00),(NY_19:00_23:00)
|
||||
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 string eaSessions = ""; // Active Sessions
|
||||
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
|
||||
@@ -233,6 +235,11 @@ void OnDeinit(const int reason)
|
||||
// On Tick Handler ...
|
||||
void OnTick()
|
||||
{
|
||||
//
|
||||
// Handle Tradings ...
|
||||
bool tradeUsingTriggerBlock = true;
|
||||
bool tradeUsingMarketConditions1 = true;
|
||||
|
||||
//
|
||||
HandleTimeReport();
|
||||
|
||||
@@ -290,136 +297,164 @@ void OnTick()
|
||||
|
||||
//
|
||||
// Check Trigger Block Detected or Not ...
|
||||
XTriggerBlock iTB;
|
||||
X121XCatbConditions iConditions;
|
||||
|
||||
//
|
||||
// has = DetectTriggerBlock(
|
||||
// //
|
||||
// _Symbol,
|
||||
// _Period,
|
||||
// //
|
||||
// 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 //
|
||||
// );
|
||||
|
||||
//
|
||||
has = DetectTriggerBlock(
|
||||
eaDrawer,
|
||||
eaHelper,
|
||||
iConditions,
|
||||
iTB,
|
||||
barIndex,
|
||||
10 //
|
||||
);
|
||||
|
||||
//
|
||||
if (has)
|
||||
if (tradeUsingTriggerBlock)
|
||||
{
|
||||
//
|
||||
eaBarTraker.Waits();
|
||||
|
||||
//
|
||||
eaSignal = iTB.signal;
|
||||
|
||||
//
|
||||
// Here we Can Fill eaConditions ...
|
||||
|
||||
//
|
||||
// Check Signal Type ...
|
||||
bool isLong = IsLong(eaSignal.type);
|
||||
|
||||
//
|
||||
// Update Entry ...
|
||||
eaSignal.entry = GetEntry(
|
||||
eaSignal.symbol,
|
||||
eaSignal.type //
|
||||
XTriggerBlock iTB;
|
||||
X121XCatbConditions iConditions;
|
||||
has = DetectTriggerBlock(
|
||||
//
|
||||
_Symbol,
|
||||
_Period,
|
||||
//
|
||||
iTB,
|
||||
//
|
||||
eaDrawer,
|
||||
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 //
|
||||
);
|
||||
|
||||
//
|
||||
// Update Signal Targets ...
|
||||
UpdateSignalTargets(eaSignal);
|
||||
// has = DetectTriggerBlock(
|
||||
// eaDrawer,
|
||||
// eaHelper,
|
||||
// eaBarAnalyser,
|
||||
// iConditions,
|
||||
// iTB,
|
||||
// barIndex,
|
||||
// 10 //
|
||||
// );
|
||||
|
||||
//
|
||||
// Handle Volume Management ...
|
||||
double iVolume = eaVolume.CalculateVolume(eaSignal);
|
||||
if (iVolume > X_MIN_VOLUME &&
|
||||
iVolume != eaSignal.volume)
|
||||
if (has)
|
||||
{
|
||||
eaSignal.volume = iVolume;
|
||||
//
|
||||
eaBarTraker.Waits();
|
||||
|
||||
//
|
||||
eaSignal = iTB.signal;
|
||||
|
||||
//
|
||||
// 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 //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Execute Signal ...
|
||||
has = eaTradeManager.Execute(
|
||||
eaSignal,
|
||||
eaConditions //
|
||||
iTB.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Trade Using Market Conditions ...
|
||||
if (tradeUsingMarketConditions1)
|
||||
{
|
||||
//
|
||||
XBoxZone signalZone;
|
||||
X121XCatbConditions conditions;
|
||||
has = DetectSignalZone1(
|
||||
eaDrawer,
|
||||
eaHelper,
|
||||
eaBarAnalyser,
|
||||
signalZone,
|
||||
conditions,
|
||||
barIndex //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
// Convert Box to Signal ...
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
|
||||
//
|
||||
iTB.Clean();
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
}
|
||||
@@ -799,6 +834,74 @@ void InitRequirements()
|
||||
eaMaxAllowedSLs,
|
||||
eaMaxAllowedTrades //
|
||||
);
|
||||
|
||||
//
|
||||
// Initializing Sessions ...
|
||||
string sessions[];
|
||||
int sessionsCount = 0;
|
||||
bool hasSession = IsValid(eaSessions);
|
||||
if (hasSession)
|
||||
{
|
||||
//
|
||||
// Extract Per Symbol Sessions ...
|
||||
sessionsCount = SplitContent(
|
||||
sessions,
|
||||
eaSessions,
|
||||
"," //
|
||||
);
|
||||
|
||||
//
|
||||
// Try to Extract Start and End Times Series ...
|
||||
hasSession = IsValidSize(sessionsCount);
|
||||
if (hasSession)
|
||||
{
|
||||
//
|
||||
// Iterate Sessions ...
|
||||
for (int i = 0; i < sessionsCount; i++)
|
||||
{
|
||||
//
|
||||
// Ignore unused Cases and Extracts only Content ...
|
||||
string iSessionDescriptorStr = ExtractString(sessions[i]);
|
||||
isInited = IsValid(iSessionDescriptorStr);
|
||||
if (isInited)
|
||||
{
|
||||
//
|
||||
// Extract Session Descriptor Data ...
|
||||
string parts[];
|
||||
int partsCount = SplitContent(
|
||||
parts,
|
||||
iSessionDescriptorStr,
|
||||
"_" //
|
||||
);
|
||||
isInited = IsValidSize(partsCount) && partsCount == 3;
|
||||
if (isInited)
|
||||
{
|
||||
//
|
||||
string iName = parts[0];
|
||||
string iStart = parts[1];
|
||||
string iEnd = parts[2];
|
||||
isInited = IsValid(iName) &&
|
||||
IsValid(iStart) &&
|
||||
IsValid(iEnd);
|
||||
if (isInited)
|
||||
{
|
||||
//
|
||||
// Set Active Session ...
|
||||
eaTradeManager
|
||||
.SetTradeSession(
|
||||
_Symbol,
|
||||
iStart,
|
||||
iEnd,
|
||||
iName //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user