Cleanup Backups ...

This commit is contained in:
2025-01-25 03:58:37 +03:30
parent 2734acf02d
commit 86ef1cad32
26 changed files with 0 additions and 44530 deletions
-580
View File
@@ -1,580 +0,0 @@
//////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Indicator
// ---------------------------------------------
// Name: XSTR
// Description: Super Trend Indicator ...
//
//
// 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 "SaherElm X121_XAMA Indicator"
#property strict
//
// START Constants ...
//
#define ShortName "XSTR"
//
// END Constants ...
//
//
// START Inputs ...
//
//
// Market ...
input group "ATR";
input int atrLength = 14; // Length
input double atrMultiplier = 3.0; // Multiplier
input ENUM_APPLIED_PRICE atrAppliedTo = PRICE_MEDIAN; // Applied To
//
// Presentation ...
input group "Presentation";
input bool showTrends = true; // Show Trends
input bool fillTrends = true; // Fill Trends
//
// END Inputs ...
//
//
// Includes Common Library ...
#include "../Libraries/x-saherelm.common.lib.mq5"
//
// START Buffers ...
//
//
#property indicator_chart_window
//
#property indicator_buffers 9
#property indicator_plots 2
//
#define fillUpBufferIndex 0
double fillUpBuffer[];
#define fillDownBufferIndex 1
double fillDownBuffer[];
//
#define fillingPlotBufferIndex 0
//
#property indicator_label1 "XSTR Filling"
#property indicator_type1 DRAW_FILLING
#property indicator_color1 clrBisque, clrPaleGreen
//
#define mainBufferIndex 2
#define mainPlotBufferIndex 1
double mainBuffer[];
//
#define mainColorBufferIndex 3
double mainColorBuffer[];
//
#property indicator_label2 "XSTR"
#property indicator_type2 DRAW_COLOR_LINE
#property indicator_color2 CLR_NONE, clrGreen, clrDarkRed
#property indicator_style2 STYLE_DOT
//
// DATA Buffers ...
//
#define atrBufferIndex 4
double atrBuffer[];
//
#define trendBufferIndex 5
double trendBuffer[];
//
#define upBufferIndex 6
double upBuffer[];
//
#define downBufferIndex 7
double downBuffer[];
//
#define priceBufferIndex 8
double priceBuffer[];
//
// END Buffers ...
//
//
// START Global Definitions: Variables, Properties and etc ...
//
//
int maxLength;
//
int atrHandler = INVALID_HANDLE;
//
int changeOfTrend;
int startBearishTrend;
int startBullishTrend;
//
// END Global Definitions: Variables, Properties and etc ...
//
//
// START Event Handlers ...
//
//
// Initialization ...
int OnInit()
{
//
// Validate Inputs ...
if (!ValidateInputs())
{
return INIT_PARAMETERS_INCORRECT;
}
//
// because in some cases we may have more than one input for
// calculation and we must prevent any calculation
// untill we pass the biggest input length, here we get max Input length
// and then wait until pass it ...
maxLength = ExtractMaxLengthOfInputs();
//
atrHandler = iATR(
_Symbol,
_Period,
atrLength);
if (atrHandler == INVALID_HANDLE)
{
return INIT_FAILED;
}
//
// Define Index Buffers ...
DefineBuffers();
//
// Set Indicator ShortName ...
SetIndicatorName();
//
// Init Succeed ...
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
//
// Here we can handle De Initialization Reasons ...
IndicatorRelease(atrHandler);
}
//
// Calculating what we want ...
int OnCalculate(
//
// total Candles on chart ...
const int rates_total,
//
// total calculated Candles on charts ...
const int prev_calculated,
//
// history of Candles Open Time ...
const datetime &time[],
//
// history of Candles Open Price ...
const double &open[],
//
// history of Candles High Price ...
const double &high[],
//
// history of Candles Low Price ...
const double &low[],
//
// history of Candles Close Price ...
const double &close[],
//
// history of Tick Volumes on Candle ...
const long &tick_volume[],
//
// history of Trade Volumes ...
const long &volume[],
//
// history of Candles Spread Price ...
const int &spread[])
{
//
int numOfRequiredAtrs;
if (prev_calculated > rates_total || prev_calculated < 0)
{
numOfRequiredAtrs = rates_total;
}
else
{
//
numOfRequiredAtrs = rates_total - prev_calculated;
if (prev_calculated > 0)
{
numOfRequiredAtrs++;
}
}
//
// Checking for stop ...
if (IsStopped())
{
return 0;
}
//
// Check Number of items Copy or not ...
int copiedATRs = CopyBuffer(atrHandler, 0, 0, numOfRequiredAtrs, atrBuffer);
if (copiedATRs <= 0)
{
return 0;
}
//
int limit;
//
// checking for the limit start of calculation of an indicator ...
if (prev_calculated > rates_total || prev_calculated <= 0)
{
//
// starting index for calculation of all bars ...
limit = maxLength;
}
else
{
//
// starting number for calculation of new bars
limit = prev_calculated - 1;
}
//
// Main Loop ...
for (int i = limit; i < rates_total && !IsStopped(); i++)
{
//
// Calculated Price ...
double price = getPrice(
atrAppliedTo,
open,
high,
low,
close,
i);
// price = (high[i] + low[i]) / 2;
priceBuffer[i] = price;
//
double atr = atrBuffer[i];
//
// Up ...
upBuffer[i] = price + (atrMultiplier * atr);
//
// Down ...
downBuffer[i] = price - (atrMultiplier * atr);
//
if (close[i] > upBuffer[i - 1])
{
//
trendBuffer[i] = 1;
if (trendBuffer[i - 1] == -1)
{
changeOfTrend = 1;
}
}
else if (close[i] < downBuffer[i - 1])
{
//
trendBuffer[i] = -1;
if (trendBuffer[i - 1] == 1)
{
changeOfTrend = 1;
}
}
else if (trendBuffer[i - 1] == 1)
{
//
trendBuffer[i] = 1;
changeOfTrend = 0;
}
else if (trendBuffer[i - 1] == -1)
{
//
trendBuffer[i] = -1;
changeOfTrend = 0;
}
//
// Down Trend Starting ...
if (trendBuffer[i] < 0 && trendBuffer[i - 1] > 0)
{
startBearishTrend = 1;
}
else
{
startBearishTrend = 0;
}
//
// Up Trend Starting ...
if (trendBuffer[i] > 0 && trendBuffer[i - 1] < 0)
{
startBullishTrend = 1;
}
else
{
startBullishTrend = 0;
}
//
if (trendBuffer[i] > 0 && downBuffer[i] < downBuffer[i - 1])
{
downBuffer[i] = downBuffer[i - 1];
}
//
if (trendBuffer[i] < 0 && upBuffer[i] > upBuffer[i - 1])
{
upBuffer[i] = upBuffer[i - 1];
}
//
if (startBearishTrend == 1)
{
upBuffer[i] = priceBuffer[i] + (atrMultiplier * atr);
}
//
if (startBullishTrend == 1)
{
downBuffer[i] = priceBuffer[i] - (atrMultiplier * atr);
}
//
// Draw the indicator ...
//
double colorIDX = 0;
mainColorBuffer[i] = colorIDX;
//
if (trendBuffer[i] == 1)
{
//
mainBuffer[i] = downBuffer[i];
if (changeOfTrend == 1)
{
mainBuffer[i - 1] = mainBuffer[i - 2];
changeOfTrend = 0;
}
//
colorIDX = 1;
}
else if (trendBuffer[i] == -1)
{
//
mainBuffer[i] = upBuffer[i];
if (changeOfTrend == 1)
{
//
mainBuffer[i - 1] = mainBuffer[i - 2];
changeOfTrend = 0;
}
//
colorIDX = 2;
}
//
if (showTrends)
{
mainColorBuffer[i] = colorIDX;
}
//
// Filling ...
if (fillTrends)
{
//
fillUpBuffer[i] = mainBuffer[i];
fillDownBuffer[i] = close[i];
}
else
{
//
fillUpBuffer[i] = EMPTY_VALUE;
fillDownBuffer[i] = EMPTY_VALUE;
}
}
//
return rates_total;
}
//
// END Event Handlers ...
//
//
// START Functions ...
//
//
// Validate Input Args for Initialization ...
bool ValidateInputs()
{
//
bool result = false;
//
// Validate Args ...
result =
//
atrLength >= 2
//
;
//
return result;
}
//
// Retrieve all Exists Input Max Length ...
// use for Start Of Drawing ...
int ExtractMaxLengthOfInputs()
{
//
int result = 0;
//
result = atrLength;
//
return result;
}
//
// Set Indicator Short Name and also we can define Buffers Labels ...
void SetIndicatorName()
{
IndicatorSetString(INDICATOR_SHORTNAME, ShortName);
}
//
// Define Indexes and Styles ...
void DefineBuffers()
{
//
// PLOT Buffers ...
//
// FILLINGS ...
SetIndexBuffer(fillUpBufferIndex, fillUpBuffer, INDICATOR_DATA);
SetIndexBuffer(fillDownBufferIndex, fillDownBuffer, INDICATOR_DATA);
PlotIndexSetInteger(fillingPlotBufferIndex, PLOT_SHOW_DATA, false);
//
// MAIN ...
SetIndexBuffer(mainBufferIndex, mainBuffer, INDICATOR_DATA);
PlotIndexSetInteger(mainPlotBufferIndex, PLOT_SHOW_DATA, showTrends);
SetIndexBuffer(mainColorBufferIndex, mainColorBuffer, INDICATOR_COLOR_INDEX);
//
// DATA Buffers ...
//
// ATR ...
SetIndexBuffer(atrBufferIndex, atrBuffer, INDICATOR_CALCULATIONS);
//
// TREND ...
SetIndexBuffer(trendBufferIndex, trendBuffer, INDICATOR_CALCULATIONS);
//
// UP ...
SetIndexBuffer(upBufferIndex, upBuffer, INDICATOR_CALCULATIONS);
//
// DOWN ...
SetIndexBuffer(downBufferIndex, downBuffer, INDICATOR_CALCULATIONS);
//
// PRICE ...
SetIndexBuffer(priceBufferIndex, priceBuffer, INDICATOR_CALCULATIONS);
}
//
// END Functions ...
//
//
// TEMPLATE Function ...
template <typename T>
double getPrice(ENUM_APPLIED_PRICE tprice, T &open[], T &high[], T &low[], T &close[], int i)
{
switch (tprice)
{
case PRICE_CLOSE:
return (close[i]);
case PRICE_OPEN:
return (open[i]);
case PRICE_HIGH:
return (high[i]);
case PRICE_LOW:
return (low[i]);
case PRICE_MEDIAN:
return ((high[i] + low[i]) / 2.0);
case PRICE_TYPICAL:
return ((high[i] + low[i] + close[i]) / 3.0);
case PRICE_WEIGHTED:
return ((high[i] + low[i] + close[i] + close[i]) / 4.0);
}
return (0);
}
-195
View File
@@ -1,195 +0,0 @@
//+------------------------------------------------------------------+
//| SuperTrend.mq5 |
//| Copyright 2011, FxGeek |
//| http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2011, FxGeek"
#property link " http://www.mql5.com"
#property version "1.00"
#property indicator_chart_window
#property indicator_buffers 9
#property indicator_plots 2
#property indicator_label1 "Filling"
#property indicator_type1 DRAW_FILLING
#property indicator_color1 clrBisque, clrPaleGreen
#property indicator_label2 "SuperTrend"
#property indicator_type2 DRAW_COLOR_LINE
#property indicator_color2 clrGreen, clrRed
input int Periode=10;
input double Multiplier=3;
input bool Show_Filling=true; // Show as DRAW_FILLING
double Filled_a[];
double Filled_b[];
double SuperTrend[];
double ColorBuffer[];
double Atr[];
double Up[];
double Down[];
double Middle[];
double trend[];
int atrHandle;
int changeOfTrend;
int flag;
int flagh;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
SetIndexBuffer(0,Filled_a,INDICATOR_DATA);
SetIndexBuffer(1,Filled_b,INDICATOR_DATA);
SetIndexBuffer(2,SuperTrend,INDICATOR_DATA);
SetIndexBuffer(3,ColorBuffer,INDICATOR_COLOR_INDEX);
SetIndexBuffer(4,Atr,INDICATOR_CALCULATIONS);
SetIndexBuffer(5,Up,INDICATOR_CALCULATIONS);
SetIndexBuffer(6,Down,INDICATOR_CALCULATIONS);
SetIndexBuffer(7,Middle,INDICATOR_CALCULATIONS);
SetIndexBuffer(8,trend,INDICATOR_CALCULATIONS);
atrHandle=iATR(_Symbol,_Period,Periode);
//---
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//---
int to_copy;
if(prev_calculated>rates_total || prev_calculated<0) to_copy=rates_total;
else
{
to_copy=rates_total-prev_calculated;
if(prev_calculated>0) to_copy++;
}
if(IsStopped()) return(0); //Checking for stop flag
if(CopyBuffer(atrHandle,0,0,to_copy,Atr)<=0)
{
Print("Getting Atr is failed! Error",GetLastError());
return(0);
}
int first;
if(prev_calculated>rates_total || prev_calculated<=0) // checking for the first start of calculation of an indicator
{
first=Periode; // starting index for calculation of all bars
}
else
{
first=prev_calculated-1; // starting number for calculation of new bars
}
for(int i=first; i<rates_total && !IsStopped(); i++)
{
Middle[i]=(high[i]+low[i])/2;
Up[i] = Middle[i] +(Multiplier*Atr[i]);
Down[i]= Middle[i] -(Multiplier*Atr[i]);
if(close[i]>Up[i-1])
{
trend[i]=1;
if(trend[i-1]==-1) changeOfTrend=1;
}
else if(close[i]<Down[i-1])
{
trend[i]=-1;
if(trend[i-1]==1) changeOfTrend=1;
}
else if(trend[i-1]==1)
{
trend[i]=1;
changeOfTrend=0;
}
else if(trend[i-1]==-1)
{
trend[i]=-1;
changeOfTrend=0;
}
if(trend[i]<0 && trend[i-1]>0)
{
flag=1;
}
else
{
flag=0;
}
if(trend[i]>0 && trend[i-1]<0)
{
flagh=1;
}
else
{
flagh=0;
}
if(trend[i]>0 && Down[i]<Down[i-1])
Down[i]=Down[i-1];
if(trend[i]<0 && Up[i]>Up[i-1])
Up[i]=Up[i-1];
if(flag==1)
Up[i]=Middle[i]+(Multiplier*Atr[i]);
if(flagh==1)
Down[i]=Middle[i]-(Multiplier*Atr[i]);
//-- Draw the indicator
if(trend[i]==1)
{
SuperTrend[i]=Down[i];
if(changeOfTrend==1)
{
SuperTrend[i-1]=SuperTrend[i-2];
changeOfTrend=0;
}
ColorBuffer[i]=0.0;
}
else if(trend[i]==-1)
{
SuperTrend[i]=Up[i];
if(changeOfTrend==1)
{
SuperTrend[i-1]= SuperTrend[i-2];
changeOfTrend = 0;
}
ColorBuffer[i]=1.0;
}
if(Show_Filling)
{
Filled_a[i]= SuperTrend[i];
Filled_b[i]= close[i];
}else{
Filled_a[i]= EMPTY_VALUE;
Filled_b[i]= EMPTY_VALUE;
}
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
-319
View File
@@ -1,319 +0,0 @@
//
// Reading Previous Conditions ...
ENUM_XPOI_EVENTS consolidationPoiEventsPrev[];
ENUM_X_CYCLE_EVENTS consolidationCycleEventsPrev[];
X121SMCCycleConditions consolidationConditionsPrev;
result = consolidationCycleHelper.GetConditions(
consolidationCycleEventsPrev,
consolidationPoiEventsPrev,
consolidationConditionsPrev,
cIndex,
loopback //
);
if (!result)
{
return result;
}
//
X121SMCCycleConditions conditionState = consolidationConditions;
X121SMCCycleConditions conditionStatePrev = consolidationConditionsPrev;
//
XOHCL cCBar;
result = cCBar.Init(
conditionState.symbol,
conditionState.period,
cIndex //
);
if (!result)
{
return result;
}
//
XOHCL cPBar;
result = cCBar.GetPreviousBar(cPBar);
if (!result)
{
return result;
}
//
// Engulf ...
ENUM_X_DIRECTION cCBarEngulfDir;
bool isCCBarEngulfed = consolidationCycleHelper
.mBarAnalyser
.IsEngulfBar(
cCBar,
cCBarEngulfDir,
0 // Extended ...
);
bool isCCBarBullishEngulfed =
isCCBarEngulfed &&
IsBullish(cCBarEngulfDir);
bool isCCBarBearishEngulfed =
isCCBarEngulfed &&
IsBearish(cCBarEngulfDir);
//
// Momentum ...
ENUM_X_DIRECTION cCBarMomentumDir;
bool isCCBarMomentum = consolidationCycleHelper
.mBarAnalyser
.IsMomentumBar(
cCBar,
cCBarMomentumDir,
1 // Extended ...
);
bool isCCBarBullishMomentum =
isCCBarMomentum &&
IsBullish(cCBarMomentumDir);
bool isCCBarBearishMomentum =
isCCBarMomentum &&
IsBearish(cCBarMomentumDir);
//
// Reject ...
ENUM_X_DIRECTION cCBarRejectDir;
bool isCCBarRejected = consolidationCycleHelper
.mBarAnalyser
.IsRejectionBar(
cCBar,
cCBarRejectDir,
1 // Extended ...
);
bool isCCBarBullishRejected =
isCCBarRejected &&
IsBullish(cCBarRejectDir);
bool isCCBarBearishRejected =
isCCBarRejected &&
IsBearish(cCBarRejectDir);
//
// Bar Checking Summary ...
//
// Bullish ...
bool isCCBarPassedBullish =
//
isCCBarBullishEngulfed ||
isCCBarBullishMomentum ||
isCCBarBullishRejected
//
;
//
// Bearish ...
bool isCCBarPassedBearish =
//
isCCBarBearishEngulfed ||
isCCBarBearishMomentum ||
isCCBarBearishRejected
//
;
//
double cPeakPrev = conditionStatePrev.x121Conditions.peaksBuffer[0];
double cValePrev = conditionStatePrev.x121Conditions.valesBuffer[0];
//
double cPeak = conditionState.x121Conditions.peaksBuffer[1];
double cVale = conditionState.x121Conditions.valesBuffer[1];
//
bool isCPeakSame = cPeak == cPeakPrev;
bool isCValeSame = cVale == cValePrev;
//
bool isCNewPeakPrev = conditionStatePrev.x121Conditions.isNewPeak;
bool isCNewPeakOverLastPrev = conditionStatePrev.x121Conditions.isNewPeakOverLast;
bool isCNewPeakUnderLastPrev = conditionStatePrev.x121Conditions.isNewPeakUnderLast;
//
bool isCNewValePrev = conditionStatePrev.x121Conditions.isNewVale;
bool isCNewValeOverLastPrev = conditionStatePrev.x121Conditions.isNewValeOverLast;
bool isCNewValeUnderLastPrev = conditionStatePrev.x121Conditions.isNewValeUnderLast;
//
bool isCRSIOverSold = conditionState.x121Conditions.isRSIOverSold;
bool isCRSICrossedOverOverSold = conditionState.x121Conditions.isRSICrossedOverOverSold;
bool isCRSICrossedUnderOverSold = conditionState.x121Conditions.isRSICrossedUnderOverSold;
//
bool isCRSIOverBought = conditionState.x121Conditions.isRSIOverBought;
bool isCRSICrossedOverOverBought = conditionState.x121Conditions.isRSICrossedOverOverBought;
bool isCRSICrossedUnderOverBought = conditionState.x121Conditions.isRSICrossedUnderOverBought;
//
bool isCRSIOverSoldPrev = conditionStatePrev.x121Conditions.isRSIOverSold;
bool isCRSICrossedOverOverSoldPrev = conditionStatePrev.x121Conditions.isRSICrossedOverOverSold;
bool isCRSICrossedUnderOverSoldPrev = conditionStatePrev.x121Conditions.isRSICrossedUnderOverSold;
//
bool isCRSIOverBoughtPrev = conditionStatePrev.x121Conditions.isRSIOverBought;
bool isCRSICrossedOverOverBoughtPrev = conditionStatePrev.x121Conditions.isRSICrossedOverOverBought;
bool isCRSICrossedUnderOverBoughtPrev = conditionStatePrev.x121Conditions.isRSICrossedUnderOverBought;
//
isBullish =
//
isCNewValePrev &&
isCCBarPassedBullish
//
;
//
isBearish =
//
isCNewPeakPrev &&
isCCBarPassedBearish
//
;
//
result = isBullish ||
isBearish;
if (!result)
{
return result;
}
//
conditions.pivot =
isBullish
? conditionState.x121Conditions.valesBuffer[1]
: conditionState.x121Conditions.peaksBuffer[1];
//
double peak = analyseConditions.x121Conditions.peaksBuffer[1];
double vale = analyseConditions.x121Conditions.valesBuffer[1];
//
double strUpper = analyseConditions.x121Conditions.strUpBuffer[1];
double strLower = analyseConditions.x121Conditions.strDownBuffer[1];
//
bool isStrSwitchedToBullish = analyseConditions.x121Conditions.isStrSwitchedToBullish;
bool isStrSwitchedToBearish = analyseConditions.x121Conditions.isStrSwitchedToBearish;
//
isBullish = isStrSwitchedToBullish;
isBearish = isStrSwitchedToBearish;
//
result = isBullish ||
isBearish;
if (!result)
{
return result;
}
//
conditions.pivot =
isBullish
? peak
: vale;
//
// Looking For Sar Change ...
//
double sar = analyseConditions.x121Conditions.sarBuffer[1];
//
double peak = analyseConditions.x121Conditions.peaksBuffer[1];
double vale = analyseConditions.x121Conditions.valesBuffer[1];
//
bool isSarEqualsToPeak = analyseConditions.x121Conditions.isSarEqualsToPeak;
bool isSarEqualsToVale = analyseConditions.x121Conditions.isSarEqualsToVale;
//
bool isSarSwitchedToBullish = analyseConditions.x121Conditions.isSarSwitchedToBullish;
bool isSarSwitchedToBearish = analyseConditions.x121Conditions.isSarSwitchedToBearish;
//
isBullish =
isBullish &&
isSarEqualsToPeak &&
isSarSwitchedToBullish;
//
isBearish =
isBearish &&
isSarEqualsToVale &&
isSarSwitchedToBearish;
//
result = isBullish ||
isBearish;
if (!result)
{
return result;
}
//
Print("Sar Switched ...");
//
// Detect a Zone Arround Price Zone ...
int supplyZonesCount = consolidationState.CountSupplyZones();
if (IsValidSize(supplyZonesCount)) {
//
for (int i = 0; i < supplyZonesCount; i++) {
//
XCSupplyZone *iZone = consolidationState.supplyZones[i];
//
bool isOver = iZone.Lower() > pzUpper;
bool isUnder = iZone.Upper() < pzLower;
//
bool isValid =
isOver ||
isUnder;
if (isValid) {
}
}
}
//
// Method 1 ...
// VWap Switch Start ...
//
bool bullishMethod1 =
//
isSarBullish &&
isStrBullish &&
isSlopesBullish &&
hasBullishTrend &&
cBar.IsBullish() &&
isAtrBullishSlope &&
isPVBullishFormed &&
isRsiBullishFormed &&
isVWapBullishFormed
//
;
//
bool bearishMethod1 =
//
isSarBearish &&
isStrBearish &&
isSlopesBearish &&
hasBearishTrend &&
cBar.IsBearish() &&
isAtrBearishSlope &&
isPVBearishFormed &&
isRsiBearishFormed &&
isVWapBearishFormed
//
;
-530
View File
@@ -1,530 +0,0 @@
//////////////////////////////////////////////////////////////////////////////////
////// Detect Price Zones :
/////////////////////////////////////////////////////////////////////////////////
//
XPriceZones priceZone;
bool isPriceZoneValidForPeak;
bool isPriceZoneValidForVale;
//
priceZone.Clean();
isPriceZoneValidForPeak = false;
isPriceZoneValidForVale = false;
//
// Detect Price Zone ...
//
double pzPeak = decisionXConditions.peaksBuffer[1];
double pzVale = decisionXConditions.valesBuffer[1];
//
// Detecting Decision Price ones ...
XPriceZones decisionPriceZone;
bool hasDecisionPriceZone = CalculatePriceInsideZones(
decisionPriceZone,
decisionState,
cBar //
);
double decisionPriceZoneUpper = 0;
double decisionPriceZoneLower = 0;
bool isDecisionPriceZoneValidForPeak = false;
bool isDecisionPriceZoneValidForVale = false;
if (hasDecisionPriceZone)
{
//
bool hasBoundary = decisionPriceZone.GetBoundary(
X_DIRECTION_ALL,
decisionPriceZoneUpper,
decisionPriceZoneLower //
);
//
isDecisionPriceZoneValidForPeak =
hasBoundary &&
pzPeak <= decisionPriceZoneUpper &&
pzPeak >= decisionPriceZoneLower;
//
isDecisionPriceZoneValidForVale =
hasBoundary &&
pzVale <= decisionPriceZoneUpper &&
pzVale >= decisionPriceZoneLower;
}
//
// Detecting Analyse Price ones ...
XPriceZones analysePriceZone;
bool hasAnalysePriceZone = CalculatePriceInsideZones(
analysePriceZone,
analyseState,
cBar //
);
double analysePriceZoneUpper = 0;
double analysePriceZoneLower = 0;
bool isAnalysePriceZoneValidForPeak = false;
bool isAnalysePriceZoneValidForVale = false;
if (hasAnalysePriceZone)
{
//
bool hasBoundary = analysePriceZone.GetBoundary(
X_DIRECTION_ALL,
analysePriceZoneUpper,
analysePriceZoneLower //
);
//
isAnalysePriceZoneValidForPeak =
hasBoundary &&
pzPeak <= analysePriceZoneUpper &&
pzPeak >= analysePriceZoneLower;
//
isAnalysePriceZoneValidForVale =
hasBoundary &&
pzVale <= analysePriceZoneUpper &&
pzVale >= analysePriceZoneLower;
}
//
// Detecting Verification Price ones ...
XPriceZones verificationPriceZone;
bool hasVerificationPriceZone = CalculatePriceInsideZones(
verificationPriceZone,
verificationState,
cBar //
);
double verificationPriceZoneUpper = 0;
double verificationPriceZoneLower = 0;
bool isVerificationPriceZoneValidForPeak = false;
bool isVerificationPriceZoneValidForVale = false;
if (hasVerificationPriceZone)
{
//
bool hasBoundary = verificationPriceZone.GetBoundary(
X_DIRECTION_ALL,
verificationPriceZoneUpper,
verificationPriceZoneLower //
);
//
isVerificationPriceZoneValidForPeak =
hasBoundary &&
pzPeak <= verificationPriceZoneUpper &&
pzPeak >= verificationPriceZoneLower;
//
isVerificationPriceZoneValidForVale =
hasBoundary &&
pzVale <= verificationPriceZoneUpper &&
pzVale >= verificationPriceZoneLower;
}
//////////////////////////////////////////////////////////////////////////////////
////// Detect Pivot Zones :
/////////////////////////////////////////////////////////////////////////////////
//
double X121SMCXPivotPeak;
double X121SMCXPivotVale;
datetime X121SMCXPivotEnd;
datetime X121SMCXPivotStart;
ENUM_XPV_PIVOTS X121SMCXPivotType = XPV_NONE;
//
// Detect PV Pivot ...
//
bool isPivotPeakZoneRejected = false;
bool isPivotPeakZoneBreakedUp = false;
bool isPivotPeakZoneBreakedDown = false;
bool isPivotValeZoneRejected = false;
bool isPivotValeZoneBreakedUp = false;
bool isPivotValeZoneBreakedDown = false;
bool hasPivot = conditions.pivotZone.IsValid();
if (!hasPivot)
{
//
hasPivot = IsValid(X121SMCXPivotStart);
if (!hasPivot)
{
//
bool isNewVale = decisionXConditions.isNewVale;
bool isNewValeOverLast = decisionXConditions.isNewValeOverLast;
bool isNewValeUnderLast = decisionXConditions.isNewValeUnderLast;
bool isSameVales = decisionXConditions.valesBuffer[1] ==
decisionXConditions.valesBuffer[2] &&
decisionXConditions.valesBuffer[2] ==
decisionXConditions.valesBuffer[3];
bool isSameCycleVales = decisionXConditions.valesBuffer[1] ==
analyseXConditions.valesBuffer[1] &&
analyseXConditions.valesBuffer[1] ==
verificationXConditions.valesBuffer[1];
//
bool isNewPeak = decisionXConditions.isNewPeak;
bool isNewPeakOverLast = decisionXConditions.isNewPeakOverLast;
bool isNewPeakUnderLast = decisionXConditions.isNewPeakUnderLast;
bool isSamePeaks = decisionXConditions.peaksBuffer[1] ==
decisionXConditions.peaksBuffer[2] &&
decisionXConditions.peaksBuffer[2] ==
decisionXConditions.peaksBuffer[3];
bool isSameCyclePeaks = decisionXConditions.peaksBuffer[1] ==
analyseXConditions.peaksBuffer[1] &&
analyseXConditions.peaksBuffer[1] ==
verificationXConditions.peaksBuffer[1];
//
bool isValeStart =
isSameVales &&
isSameCycleVales;
bool isPeakStart =
isSamePeaks &&
isSameCyclePeaks;
//
bool isStart = isPeakStart ||
isValeStart;
if (isStart)
{
//
X121SMCXPivotStart = cTime;
X121SMCXPivotType =
isPeakStart
? XPV_PEAK
: XPV_VALE;
//
X121SMCXPivotPeak = decisionXConditions.peaksBuffer[1];
X121SMCXPivotVale = decisionXConditions.valesBuffer[1];
}
//
hasPivot = IsValid(X121SMCXPivotStart);
//
// Create XPVPivot instance ...
if (hasPivot)
{
//
conditions.pivotZone.symbol = symbol;
conditions.pivotZone.period = period;
//
conditions.pivotZone.to = cTime;
conditions.pivotZone.repetition = 3;
//
conditions.pivotZone.upper = X121SMCXPivotPeak;
conditions.pivotZone.lower = X121SMCXPivotVale;
//
conditions.pivotZone.type = X121SMCXPivotType;
conditions.pivotZone.from = X121SMCXPivotStart;
}
}
}
//
if (hasPivot)
{
//
bool isBreaked = X121SMCXPivotType == XPV_PEAK
? decisionXConditions.isBreakedUpPrevPeak
: decisionXConditions.isBreakedDownPrevVale;
//
if (!isBreaked)
{
//
X121SMCXPivotPeak = decisionXConditions.peaksBuffer[1];
X121SMCXPivotVale = decisionXConditions.valesBuffer[1];
//
conditions.pivotZone.to = cTime;
conditions.pivotZone.repetition++;
conditions.pivotZone.upper = X121SMCXPivotPeak;
conditions.pivotZone.lower = X121SMCXPivotVale;
}
else
{
//
X121SMCXPivotEnd = cTime;
conditions.pivotZone.to = cTime;
}
//
// Fill Pivot State ...
//
XPOIState analysePivotState;
DetectPivotPOIs(
conditions.pivotZone,
analyseState,
analysePivotState //
);
//
XPOIState decisionPivotState;
DetectPivotPOIs(
conditions.pivotZone,
decisionState,
decisionPivotState //
);
//
// Combine two State ...
XPOIState combinedPivotState;
XPOIState iStates[];
AddRef(
analysePivotState,
iStates //
);
AddRef(
decisionPivotState,
iStates //
);
CombineStates(
combinedPivotState,
iStates //
);
combinedPivotState = decisionPivotState;
//
ArrayFree(iStates);
//
combinedPivotState.time = decisionPivotState.time;
combinedPivotState.symbol = decisionPivotState.symbol;
combinedPivotState.period = decisionPivotState.period;
//
// Hold Only Areas Which on Upper or Lower bondary of Pivot Zone ...
FilterPivotState(
conditions.pivotZone,
combinedPivotState //
);
//
conditions.pivotZone.state = combinedPivotState;
//
double peakUpper = 0;
double peakLower = 0;
double valeUpper = 0;
double valeLower = 0;
//
datetime peakTo = NULL;
datetime valeTo = NULL;
datetime peakFrom = NULL;
datetime valeFrom = NULL;
//
bool hasBoxData = DetectPivotStateBoxData(
conditions.pivotZone,
peakUpper,
peakLower,
peakFrom,
peakTo,
valeUpper,
valeLower,
valeFrom,
valeTo //
);
//
// Calculate Pivot Tick Zones ...
//
int ticksLevels = decisionCycleHelper
.mPOIDetector
.TicksRangeZoneLevel();
int ticksRange = decisionCycleHelper
.mPOIDetector
.TicksRangeZoneRange();
//
CalculatePivotTickZone(
conditions.pivotZone,
ticksLevels,
ticksRange //
);
//
isPivotPeakZoneRejected =
hasBoxData &&
(
//
IsBarReject(
peakLower,
X_DIRECTION_BEARISH,
cBar //
)
//
||
//
IsBarReject(
peakUpper,
X_DIRECTION_BEARISH,
cBar //
)
//
);
isPivotPeakZoneBreakedUp =
hasBoxData &&
IsBarBreak(
peakUpper,
X_DIRECTION_BULLISH,
cBar //
);
isPivotPeakZoneBreakedDown =
hasBoxData &&
IsBarBreak(
peakLower,
X_DIRECTION_BEARISH,
cBar //
);
//
isPivotValeZoneRejected =
hasBoxData &&
(
//
IsBarReject(
valeLower,
X_DIRECTION_BULLISH,
cBar //
)
//
||
//
IsBarReject(
valeUpper,
X_DIRECTION_BULLISH,
cBar //
)
//
);
isPivotValeZoneBreakedUp =
hasBoxData &&
IsBarBreak(
valeUpper,
X_DIRECTION_BULLISH,
cBar //
);
isPivotValeZoneBreakedDown =
hasBoxData &&
IsBarBreak(
valeLower,
X_DIRECTION_BEARISH,
cBar //
);
}
//
bool isPivotEnded = IsValid(X121SMCXPivotEnd);
if (isPivotEnded)
{
//
X121SMCXPivotPeak = 0;
X121SMCXPivotVale = 0;
X121SMCXPivotEnd = NULL;
X121SMCXPivotStart = NULL;
X121SMCXPivotType = XPV_NONE;
//
conditions.pivotZone.Clean();
}
//////////////////////////////////////////////////////////////////////////////////
////// Detect Pivot Zones :
/////////////////////////////////////////////////////////////////////////////////
//
bool isCondition1Bullish =
//
hasPivot &&
//
isCBarBullishFormed &&
isCBarBullishPullbacked &&
//
hasAnalyseBullishTrend &&
hasDecisionBullishTrend &&
hasVerificationBullishTrend &&
//
decisionXConditions.isSarBullish &&
analyseXConditions.isSarBullish &&
verificationXConditions.isSarBullish &&
//
false
//
;
//
bool isCondition1Bearish =
//
hasPivot &&
//
isCBarBearishFormed &&
isCBarBearishPullbacked &&
//
hasAnalyseBearishTrend &&
hasDecisionBearishTrend &&
hasVerificationBearishTrend &&
//
decisionXConditions.isSarBearish &&
analyseXConditions.isSarBearish &&
verificationXConditions.isSarBearish &&
//
false
//
;
//
bool hasCondition1 = isCondition1Bullish ||
isCondition1Bearish;
if (hasCondition1)
{
//
ENUM_X_DIRECTION pzDir =
isCondition1Bullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
conditions.priceZone = analysePriceZone;
conditions.isPriceZoneValidForPeak = isAnalysePriceZoneValidForPeak;
conditions.isPriceZoneValidForVale = isAnalysePriceZoneValidForVale;
//
pzPeak = analysePriceZoneUpper;
pzVale = analysePriceZoneLower;
//
double point = GetEntry(
conditions.symbol,
pzDir //
);
//
// Manipulate Conditions Point ...
//
// point =
// isCondition1Bullish ? pzPeak
// : pzVale;
conditions.point = point;
//
// Manipulate Conditions Pivot ...
//
conditions.pivot =
isCondition1Bullish
? pzVale
: pzPeak;
}
-729
View File
@@ -1,729 +0,0 @@
//
double cPZoneUpper = 0;
double cPZoneLower = 0;
datetime cPZoneFrom = NULL;
datetime cPZoneTo = NULL;
result = consolidationPriceZone.GetBoxData(
X_DIRECTION_ALL,
cPZoneUpper,
cPZoneLower,
cPZoneFrom,
cPZoneTo //
);
if (!result)
{
return result;
}
//
double aPZoneUpper = 0;
double aPZoneLower = 0;
datetime aPZoneFrom = NULL;
datetime aPZoneTo = NULL;
result = analysePriceZone.GetBoxData(
X_DIRECTION_ALL,
aPZoneUpper,
aPZoneLower,
aPZoneFrom,
aPZoneTo //
);
if (!result)
{
return result;
}
//
// RSI ...
double rsi = decisionConditions.x121Conditions.rsiBuffer[1];
//
bool isRSIOverBought = decisionConditions.x121Conditions.isRSIOverBought;
bool isRSICrossedOverOverBought = decisionConditions.x121Conditions.isRSICrossedOverOverBought;
bool isRSICrossedUnderOverBought = decisionConditions.x121Conditions.isRSICrossedUnderOverBought;
//
bool isRSIOverSold = decisionConditions.x121Conditions.isRSIOverSold;
bool isRSICrossedOverOverSold = decisionConditions.x121Conditions.isRSICrossedOverOverSold;
bool isRSICrossedUnderOverSold = decisionConditions.x121Conditions.isRSICrossedUnderOverSold;
//
// PV ...
double peak = decisionConditions.x121Conditions.peaksBuffer[1];
double vale = decisionConditions.x121Conditions.valesBuffer[1];
//
bool isNewPeak = decisionConditions.x121Conditions.isNewPeak;
bool isNewPeakOverLast = decisionConditions.x121Conditions.isNewPeakOverLast;
bool isNewPeakUnderLast = decisionConditions.x121Conditions.isNewPeakUnderLast;
//
bool isNewVale = decisionConditions.x121Conditions.isNewVale;
bool isNewValeOverLast = decisionConditions.x121Conditions.isNewValeOverLast;
bool isNewValeUnderLast = decisionConditions.x121Conditions.isNewValeUnderLast;
//
// STR ...
double str = decisionConditions.x121Conditions.strBuffer[1];
//
bool isStrBullish = decisionConditions.x121Conditions.isStrBullish;
bool isStrBearish = decisionConditions.x121Conditions.isStrBearish;
//
bool isStrSwitchedToBullish = decisionConditions.x121Conditions.isStrSwitchedToBullish;
bool isStrSwitchedToBearish = decisionConditions.x121Conditions.isStrSwitchedToBearish;
//
// ATR ...
double atr = decisionConditions.x121Conditions.atrBuffer[1];
double atrUpper = decisionConditions.x121Conditions.atrUpperBuffer[1];
double atrLower = decisionConditions.x121Conditions.atrLowerBuffer[1];
//
bool isCloseOverATRUpper = decisionConditions.x121Conditions.isCloseOverATRUpper;
bool isCloseOverATRLower = decisionConditions.x121Conditions.isCloseOverATRLower;
//
bool isCloseUnderATRUpper = decisionConditions.x121Conditions.isCloseUnderATRUpper;
bool isCloseUnderATRLower = decisionConditions.x121Conditions.isCloseUnderATRLower;
//
bool isRejectUpATRUpper = decisionConditions.x121Conditions.isRejectUpATRUpper;
bool isRejectDownATRUpper = decisionConditions.x121Conditions.isRejectDownATRUpper;
//
bool isRejectUpATRLower = decisionConditions.x121Conditions.isRejectUpATRLower;
bool isRejectDownATRLower = decisionConditions.x121Conditions.isRejectDownATRLower;
//
bool isBreakUpATRUpper = decisionConditions.x121Conditions.isBreakUpATRUpper;
bool isBreakDownATRUpper = decisionConditions.x121Conditions.isBreakDownATRUpper;
//
bool isBreakUpATRLower = decisionConditions.x121Conditions.isBreakUpATRLower;
bool isBreakDownATRLower = decisionConditions.x121Conditions.isBreakDownATRLower;
//
// SAR ...
double sar = decisionConditions.x121Conditions.sarBuffer[1];
//
bool isSarBullish = decisionConditions.x121Conditions.isSarBullish;
bool isSarBearish = decisionConditions.x121Conditions.isSarBearish;
//
bool isSarSwitchedToBullish = decisionConditions.x121Conditions.isSarSwitchedToBullish;
bool isSarSwitchedToBearish = decisionConditions.x121Conditions.isSarSwitchedToBearish;
//
// DON ...
//
double donOpenUpper = decisionConditions.x121Conditions.donOpenUpperBuffer[1];
double donOpenLower = decisionConditions.x121Conditions.donOpenLowerBuffer[1];
double donHighUpper = decisionConditions.x121Conditions.donHighUpperBuffer[1];
double donHighLower = decisionConditions.x121Conditions.donHighLowerBuffer[1];
double donLowUpper = decisionConditions.x121Conditions.donLowUpperBuffer[1];
double donLowLower = decisionConditions.x121Conditions.donLowLowerBuffer[1];
double donCloseUpper = decisionConditions.x121Conditions.donCloseUpperBuffer[1];
double donCloseLower = decisionConditions.x121Conditions.donCloseLowerBuffer[1];
//
bool isRejectDonOpenUpper = decisionConditions.x121Conditions.isRejectDonOpenUpper;
bool isRejectDonHighUpper = decisionConditions.x121Conditions.isRejectDonHighUpper;
bool isRejectDonLowUpper = decisionConditions.x121Conditions.isRejectDonLowUpper;
bool isRejectDonCloseUpper = decisionConditions.x121Conditions.isRejectDonCloseUpper;
//
bool isRejectDonOpenLower = decisionConditions.x121Conditions.isRejectDonOpenLower;
bool isRejectDonHighLower = decisionConditions.x121Conditions.isRejectDonHighLower;
bool isRejectDonLowLower = decisionConditions.x121Conditions.isRejectDonLowLower;
bool isRejectDonCloseLower = decisionConditions.x121Conditions.isRejectDonCloseLower;
//
bool isBreakDonOpenUpper = decisionConditions.x121Conditions.isBreakDonOpenUpper;
bool isBreakDonHighUpper = decisionConditions.x121Conditions.isBreakDonHighUpper;
bool isBreakDonLowUpper = decisionConditions.x121Conditions.isBreakDonLowUpper;
bool isBreakDonCloseUpper = decisionConditions.x121Conditions.isBreakDonCloseUpper;
//
bool isBreakDonOpenLower = decisionConditions.x121Conditions.isBreakDonOpenLower;
bool isBreakDonHighLower = decisionConditions.x121Conditions.isBreakDonHighLower;
bool isBreakDonLowLower = decisionConditions.x121Conditions.isBreakDonLowLower;
bool isBreakDonCloseLower = decisionConditions.x121Conditions.isBreakDonCloseLower;
//
// VWAP ...
//
// COMPLEX ...
// Complex Conditions ...
//
bool isNewPeakOverATRUpper =
isNewPeak &&
peak > atrUpper;
//
bool isNewValeUnderATRLower =
isNewVale &&
vale < atrLower;
//
bool isDonHighUpperEqualsToPeak =
donHighUpper == peak;
//
bool isDonLowLowerEqualsToVale =
donLowLower == vale;
//
bool isBullishSign = (
//
triggerConditions.x121Conditions.isBreakUpATRLower ||
triggerConditions.x121Conditions.isRejectUpATRLower ||
triggerConditions.x121Conditions.isBreakDonHighLower ||
triggerConditions.x121Conditions.isRejectDonHighLower ||
triggerConditions.x121Conditions.isBreakDonCloseLower ||
triggerConditions.x121Conditions.isRejectDonCloseLower
//
);
bool isBearishSign = (
//
triggerConditions.x121Conditions.isBreakDownATRUpper ||
triggerConditions.x121Conditions.isRejectDownATRUpper ||
triggerConditions.x121Conditions.isBreakDonLowUpper ||
triggerConditions.x121Conditions.isRejectDonLowUpper ||
triggerConditions.x121Conditions.isBreakDonCloseUpper ||
triggerConditions.x121Conditions.isRejectDonCloseUpper
//
);
//
// Check RSI in Over Bought or Over Sold ...
//
bool isRSICrossedOverOverSold = consolidationConditions.x121Conditions.isRSICrossedOverOverSold;
bool isRSICrossedUnderOverBought = consolidationConditions.x121Conditions.isRSICrossedUnderOverBought;
//
result = isRSICrossedOverOverSold ||
isRSICrossedUnderOverBought;
if (!result)
{
return result;
}
///////////////////////////////////////////////
/**
* Draw X121 SMC Conditions ...
*
* @param conditions: X121SMCStrategyConditions instance Reference ...
* @param drawMarketStructure: Boolean ...
* @param drawPriceZones: Boolean ...
* @param drawDecisionZones: Boolean ...
*
* @return ( int )
*/
int DrawX121SMCStrategyConditions(
X121SMCStrategyConditions &conditions,
XCBaseObject *&drawnObjects[],
XCPOIDrawer *drawer,
bool drawMarketStructure = true,
bool drawPriceZones = true,
bool drawDecisionZones = true,
bool drawOnlyPriceZonesBoundary = true //
)
{
//
int result = 0;
//
Clean(drawnObjects);
//
if (drawer == NULL ||
!conditions.IsValid() ||
!HasDirection(conditions.signalDir))
{
return result;
}
//
bool isBullish = IsBullish(conditions.signalDir);
// //
// bool hasPriceZones = conditions.priceZones.IsValid();
// if (hasPriceZones &&
// drawPriceZones)
// {
// //
// XCBaseObject *objects[];
// int objectsCount = drawer.DrawPriceZone(
// conditions.priceZones,
// objects,
// conditions.signalDir,
// drawOnlyPriceZonesBoundary //
// );
// if (IsValidSize(objectsCount))
// {
// //
// Copy(
// objects,
// drawnObjects,
// false //
// );
// }
// }
// //
// bool hasDecisionZones = conditions.decisionZones.IsValid();
// if (hasDecisionZones &&
// drawDecisionZones)
// {
// //
// XCBaseObject *objects[];
// int objectsCount = drawer.DrawPriceZone(
// conditions.decisionZones,
// objects,
// conditions.signalDir,
// drawOnlyPriceZonesBoundary //
// );
// if (IsValidSize(objectsCount))
// {
// //
// Copy(
// objects,
// drawnObjects,
// false //
// );
// }
// }
// //
// bool hasMarketStructure = conditions.marketStructure.IsValid();
// if (hasMarketStructure &&
// drawMarketStructure)
// {
// //
// XCBaseObject *objects[];
// int objectsCount = drawer.DrawMarketStructure(
// conditions.marketStructure,
// objects //
// );
// if (IsValidSize(objectsCount))
// {
// //
// Copy(
// objects,
// drawnObjects,
// false //
// );
// }
// }
//
result = ArraySize(drawnObjects);
//
return result;
}
////////////////////////////////////////////////
// //
// isCBarBearishFormed &&
// (isPivotToDownRejected ||
// isPivotToDownBreaked) &&
// conditions.pivotZone.IsVale() &&
// //
// // SAR ...
// isSarBearishFormed &&
// // //
// // // STR ...
// // !(decisionXConditions.isStrBullish) &&
// // //
// // // VWAP ...
// // !(decisionXConditions.isVWapBullishState ||
// // decisionXConditions.isVWapBullishOrdered) &&
// //
// //
// isCBarBullishFormed &&
// (isPivotToUpRejected ||
// isPivotToUpBreaked) &&
// conditions.pivotZone.IsPeak() &&
// //
// // SAR ...
// isSarBullishFormed &&
// // //
// // // STR ...
// // !(decisionXConditions.isStrBearish) &&
// // //
// // // VWAP ...
// // !(decisionXConditions.isVWapBearishState ||
// // decisionXConditions.isVWapBearishOrdered) &&
// //
/////////////////////////////////////////////////////////////////////
visionXConditions.isBreakedUpPrevCheMax &&
visionXConditions.isCheSwitchedToBullish
visionXConditions.isCheSwitchedToBearish &&
visionXConditions.isBreakedDownPrevCheMin
//////////////////////////////////////////////////////////////////////
//
bool hasOrderBlock = hasBullishOrderBlocks ||
hasBearishOrderBlocks;
if (hasOrderBlock)
{
//
Print("Detect Order Block ...");
//
XCBaseObject *drawnObjects[];
//
if (hasBullishOrderBlocks)
{
//
for (int i = 0; i < bullishOrderBlocksCount; i++)
{
//
XCOrderBlock *iOb = bullishOBs[i];
//
XCBullishOrderBlockObject *iObObj;
bool isCreated = triggerCycleHelper
.mPOIDetector
.mDrawer
.CreateBullishOrderBlock(
iOb,
iObObj //
);
if (isCreated)
{
//
Add(
(XCBaseObject *)iObObj,
drawnObjects //
);
}
}
}
//
if (hasBearishOrderBlocks)
{
//
for (int i = 0; i < bearishOrderBlocksCount; i++)
{
//
XCOrderBlock *iOb = bearishOBs[i];
//
XCBearishOrderBlockObject *iObObj;
bool isCreated = triggerCycleHelper
.mPOIDetector
.mDrawer
.CreateBearishOrderBlock(
iOb,
iObObj //
);
if (isCreated)
{
//
Add(
(XCBaseObject *)iObObj,
drawnObjects //
);
}
}
}
//
int drawnCount = ArraySize(drawnObjects);
if (IsValidSize(drawnCount))
{
Print("");
}
}
//////////////////////////////////////////////////////////////////////
//
// Summarize Conditions ...
//
bool isCondition1Bullish =
//
// Vision ...
(
//
false
//
)
//
&&
//
// Consolidation ...
(
//
true
//
)
//
&&
//
// Verification ...
(
//
true
//
)
//
&&
//
// Analyse ...
(
//
true
//
)
//
&&
//
// Decision ...
(
//
true
//
)
//
;
//
bool isCondition1Bearish =
//
// Vision ...
(
//
false
//
)
//
&&
//
// Consolidation ...
(
//
true
//
)
//
&&
//
// Verification ...
(
//
true
//
)
//
&&
//
// Analyse ...
(
//
true
//
)
//
&&
//
// Decision ...
(
//
true
//
)
//
;
//
bool hasCondition1 = isCondition1Bullish ||
isCondition1Bearish;
if (hasCondition1)
{
//
ENUM_X_DIRECTION pzDir =
isCondition1Bullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
double point = GetEntry(
conditions.symbol,
pzDir //
);
//
// Manipulate Conditions Point ...
//
conditions.point = point;
//
// Manipulate Conditions Pivot ...
//
// conditions.pivot =
// isCondition1Bullish
// ? conditions.pivotZone.upper
// : conditions.pivotZone.lower;
}
/////////////////////////////////////////////////////////////////////////
//
// DRAW ...
//
//
XCBaseObject *drawnObjects[];
//
if (hasBullishOrderBlocks)
{
//
for (int i = 0; i < bullishOrderBlocksCount; i++)
{
//
XCOrderBlock *iOb = conditions.bullishOBs[i];
//
XCBullishOrderBlockObject *iObObj;
bool isCreated = visionCycleHelper
.mPOIDrawer
.CreateBullishOrderBlock(
iOb,
iObObj //
);
if (isCreated)
{
//
Add(
(XCBaseObject *)iObObj,
drawnObjects //
);
}
}
}
//
if (hasBearishOrderBlocks)
{
//
for (int i = 0; i < bearishOrderBlocksCount; i++)
{
//
XCOrderBlock *iOb = conditions.bearishOBs[i];
//
XCBearishOrderBlockObject *iObObj;
bool isCreated = visionCycleHelper
.mPOIDrawer
.CreateBearishOrderBlock(
iOb,
iObObj //
);
if (isCreated)
{
//
Add(
(XCBaseObject *)iObObj,
drawnObjects //
);
}
}
}
//
// if (hasOldestBullishOB)
// {
// //
// XCBullishOrderBlockObject *iObj;
// bool isCreated = visionCycleHelper
// .mPOIDrawer
// .CreateBullishOrderBlock(
// oldestBullishOB,
// iObj //
// );
// if (isCreated)
// {
// }
// }
// //
// if (hasYoungestBullishOB)
// {
// //
// XCBullishOrderBlockObject *iObj;
// bool isCreated = visionCycleHelper
// .mPOIDrawer
// .CreateBullishOrderBlock(
// youngestBullishOB,
// iObj //
// );
// if (isCreated)
// {
// }
// }
// //
// if (hasOldestBearishOB)
// {
// //
// XCBearishOrderBlockObject *iObj;
// bool isCreated = visionCycleHelper
// .mPOIDrawer
// .CreateBearishOrderBlock(
// oldestBearishOB,
// iObj //
// );
// if (isCreated)
// {
// }
// }
// //
// if (hasYoungestBearishOB)
// {
// //
// XCBearishOrderBlockObject *iObj;
// bool isCreated = visionCycleHelper
// .mPOIDrawer
// .CreateBearishOrderBlock(
// youngestBearishOB,
// iObj //
// );
// if (isCreated)
// {
// }
// }
/////////////////////////////////////////////////////////////////////////
File diff suppressed because it is too large Load Diff
@@ -1,137 +0,0 @@
//
// OPEN ...
double triggerDonOpenUpper = triggerConditions.x121Conditions.donOpenUpperBuffer[1];
double triggerDonOpenLower = triggerConditions.x121Conditions.donOpenLowerBuffer[1];
double triggerDonOpenUpperPrev = triggerConditions.x121Conditions.donOpenUpperBuffer[2];
double triggerDonOpenLowerPrev = triggerConditions.x121Conditions.donOpenLowerBuffer[2];
//
// HIGH ...
double triggerDonHighUpper = triggerConditions.x121Conditions.donHighUpperBuffer[1];
double triggerDonHighLower = triggerConditions.x121Conditions.donHighLowerBuffer[1];
double triggerDonHighUpperPrev = triggerConditions.x121Conditions.donHighUpperBuffer[2];
double triggerDonHighLowerPrev = triggerConditions.x121Conditions.donHighLowerBuffer[2];
//
// CLOSE ...
double triggerDonCloseUpper = triggerConditions.x121Conditions.donCloseUpperBuffer[1];
double triggerDonCloseLower = triggerConditions.x121Conditions.donCloseLowerBuffer[1];
double triggerDonCloseUpperPrev = triggerConditions.x121Conditions.donCloseUpperBuffer[2];
double triggerDonCloseLowerPrev = triggerConditions.x121Conditions.donCloseLowerBuffer[2];
//
// LOW ...
double triggerDonLowUpper = triggerConditions.x121Conditions.donLowUpperBuffer[1];
double triggerDonLowLower = triggerConditions.x121Conditions.donLowLowerBuffer[1];
double triggerDonLowUpperPrev = triggerConditions.x121Conditions.donLowUpperBuffer[2];
double triggerDonLowLowerPrev = triggerConditions.x121Conditions.donLowLowerBuffer[2];
//
// Calculate PBar Rejected Don Upper and Lower ...
//
bool isPBarRejectDonLowUpper = pBar.high > triggerDonLowUpperPrev;
bool isPBarRejectDonOpenUpper = pBar.high > triggerDonOpenUpperPrev;
bool isPBarRejectDonCloseUpper = pBar.high > triggerDonCloseUpperPrev;
bool isPBarRejectedDonUpper = isPBarRejectDonLowUpper ||
isPBarRejectDonOpenUpper ||
isPBarRejectDonCloseUpper;
//
bool isPBarRejectDonHighLower = pBar.low < triggerDonHighLowerPrev;
bool isPBarRejectDonOpenLower = pBar.low < triggerDonOpenLowerPrev;
bool isPBarRejectDonCloseLower = pBar.low < triggerDonCloseLowerPrev;
bool isPBarRejectedDonLower = isPBarRejectDonHighLower ||
isPBarRejectDonOpenLower ||
isPBarRejectDonCloseLower;
//
// Calculate PBar Breaked Don Upper and Lower ...
//
bool isPBarBreakdDonLowUpper = pBar.GetUp() > triggerDonLowUpperPrev &&
pBar.GetDown() < triggerDonLowUpperPrev;
bool isPBarBreakdDonOpenUpper = pBar.GetUp() > triggerDonOpenUpperPrev &&
pBar.GetDown() < triggerDonOpenUpperPrev;
bool isPBarBreakdDonCloseUpper = pBar.GetUp() > triggerDonCloseUpperPrev &&
pBar.GetDown() < triggerDonCloseUpperPrev;
bool isPBarBreakedDonUpper = isPBarBreakdDonLowUpper ||
isPBarBreakdDonOpenUpper ||
isPBarBreakdDonCloseUpper;
//
bool isPBarBreakdDonHighLower = pBar.GetUp() > triggerDonHighLowerPrev &&
pBar.GetDown() < triggerDonHighLowerPrev;
bool isPBarBreakdDonOpenLower = pBar.GetUp() > triggerDonOpenLowerPrev &&
pBar.GetDown() < triggerDonOpenLowerPrev;
bool isPBarBreakdDonCloseLower = pBar.GetUp() > triggerDonCloseLowerPrev &&
pBar.GetDown() < triggerDonCloseLowerPrev;
bool isPBarBreakedDonLower = isPBarBreakdDonHighLower ||
isPBarBreakdDonOpenLower ||
isPBarBreakdDonCloseLower;
//
bool isRejectTriggerDonUpper =
//
// PBar ...
isPBarBearishRejected &&
isPBarRejectedDonUpper &&
//
// CBar ...
isCBarBearishMomentumBar &&
cBar.close < triggerDonLowUpper &&
//
triggerPeak == triggerDonHighUpper
//
;
//
bool isRejectTriggerDonLower =
//
// PBar ...
isPBarBullishRejected &&
isPBarRejectedDonLower &&
//
// CBar ...
isCBarBullishMomentumBar &&
cBar.close > triggerDonHighLower &&
//
triggerVale == triggerDonLowLower
//
;
//
if (isRejectTriggerDonUpper ||
isRejectTriggerDonLower)
{
Print("Don Rejected ...");
}
//
bool isBreakedDonUpper =
//
false
//
;
//
bool isBreakedDonLower =
//
false
//
;
//
bool isEngulfedDonUpper =
//
false
//
;
//
bool isEngulfedDonLower =
//
false
//
;
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -1,957 +0,0 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 X121 SMC Signal Class
// -------------------------------------------------
// Name:
// Description: provide all Signalling functions ...
//
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////
//
// Global Properties ...
#property library
#property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://www.saherelm.ir"
#property version "1.00"
#property strict
//
// Imports ...
#include "../Classes/x-121.smc.market.cycle.helper.class.mq5"
#include "../Libraries/x-121.smc.lib.mq5"
//
// Definitions ...
struct X121SMCStrategyXTWPVSignalConditions
{
//
// Props ...
//
string symbol;
ENUM_TIMEFRAMES period;
//
double sl;
double target;
ENUM_X_DIRECTION dir;
ENUM_X_POSITION_TYPES type;
//
// Setup Props ...
//
datetime setupTime;
datetime triggerTime;
//
datetime newPeakOverATRUpperAt;
datetime newValeUnderATRLowerAt;
//
datetime donHighUpperEqualsToPeakAt;
datetime donLowLowerEqualsToValeAt;
//
datetime closeOverATRUpperAt;
datetime closeUnderATRLowerAt;
//
datetime rsiOverSoldAt;
datetime rsiOverBoughtAt;
//
datetime newPeakOverLastAt;
datetime newValeUnderLastAt;
//
datetime bullishBarSignAt;
datetime bearishBarSignAt;
//
XPriceZones priceZone;
//
// Constructor ...
X121SMCStrategyXTWPVSignalConditions()
{
Clean();
}
//
// Tools ...
/**
* Cleaning Up ...
*/
void Clean()
{
//
sl = 0;
target = 0;
//
dir = X_DIRECTION_NONE;
type = X_POSITION_TYPE_NONE;
//
symbol = NULL;
period = NULL;
setupTime = NULL;
triggerTime = NULL;
//
ExtensionClean();
}
/**
* Check Condition is Setting Up ...
*
* @param dir: ENUM_X_DIRECTION member, Setting Up Direction ...
*
* @return ( bool )
*/
bool IsSetuped()
{
//
bool result = false;
//
result = IsValid(setupTime) &&
HasDirection(dir);
if (!result)
{
return result;
}
//
return result;
}
/**
* Calculate Setup Age ...
*
* @return ( int )
*/
int GetSetupAge()
{
//
int result = 0;
//
if (!IsSetuped())
{
return result;
}
//
result = (int)(TimeCurrent() - setupTime) / PeriodSeconds(period);
//
return result;
}
/**
* Detect How we Can Trigger Signal ...
*
* @return ( bool )
*/
bool CanTrigger()
{
//
bool result = false;
//
result =
//
sl > 0 &&
IsValid(symbol) &&
IsValid(period) &&
IsValid(triggerTime) &&
type != X_POSITION_TYPE_ALL &&
type != X_POSITION_TYPE_NONE
//
;
//
return result;
}
//
// Extensions ...
/**
* Clean Additional Properties ...
*/
void ExtensionClean()
{
//
priceZone.Clean();
//
newPeakOverATRUpperAt = NULL;
newValeUnderATRLowerAt = NULL;
//
donHighUpperEqualsToPeakAt = NULL;
donLowLowerEqualsToValeAt = NULL;
//
closeOverATRUpperAt = NULL;
closeUnderATRLowerAt = NULL;
//
rsiOverSoldAt = NULL;
rsiOverBoughtAt = NULL;
//
newPeakOverLastAt = NULL;
newValeUnderLastAt = NULL;
//
bullishBarSignAt = NULL;
bearishBarSignAt = NULL;
}
/**
* Check if Conditions Filled ...
*
* @return ( bool )
*/
bool IsFilled(ENUM_X_DIRECTION &fillDir)
{
//
bool result = false;
//
fillDir = X_DIRECTION_NONE;
//
bool hasNewPeakOverATRUpper = IsValid(newPeakOverATRUpperAt);
bool hasNewValeUnderATRLower = IsValid(newValeUnderATRLowerAt);
//
bool hasDonHighUpperEqualsToPeak = IsValid(donHighUpperEqualsToPeakAt);
bool hasDonLowLowerEqualsToVale = IsValid(donLowLowerEqualsToValeAt);
//
bool hasCloseOverATRUpper = IsValid(closeOverATRUpperAt);
bool hasCloseUnderATRLower = IsValid(closeUnderATRLowerAt);
//
bool hasRsiOverSold = IsValid(rsiOverSoldAt);
bool hasRsiOverBought = IsValid(rsiOverBoughtAt);
//
bool hasNewPeakOverLast = IsValid(newPeakOverLastAt);
bool hasNewValeUnderLast = IsValid(newValeUnderLastAt);
//
bool hasBullishBarSign = IsValid(bullishBarSignAt);
bool hasBearishBarSign = IsValid(bearishBarSignAt);
//
bool isBullish =
(
//
hasRsiOverSold &&
hasBullishBarSign &&
hasNewValeUnderLast &&
hasCloseUnderATRLower &&
hasNewValeUnderATRLower &&
hasDonLowLowerEqualsToVale
//
);
//
bool isBearish =
(
//
hasRsiOverBought &&
hasBearishBarSign &&
hasNewPeakOverLast &&
hasCloseOverATRUpper &&
hasNewPeakOverATRUpper &&
hasDonHighUpperEqualsToPeak
//
);
//
result =
(isBullish || isBearish) &&
!(isBullish && isBearish);
if (result)
{
//
fillDir =
isBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
}
//
return result;
}
bool HasPriceZone()
{
return priceZone.IsValid();
}
//
};
//
// Extension Functions ...
//
// Detect Setup Conditions ...
bool DetectX121SMCXTWPVSiganlSetup(
string _symbol,
ENUM_TIMEFRAMES _period,
//
X121SMCStrategyXTWPVSignalConditions &conditions,
//
XC121SMCCycleHelper *triggerCycleHelper,
XC121SMCCycleHelper *decisionCycleHelper,
XC121SMCCycleHelper *analyseCycleHelper,
XC121SMCCycleHelper *verificationCycleHelper,
XC121SMCCycleHelper *consolidationCycleHelper,
XC121SMCCycleHelper *visionCycleHelper
//
)
{
//
bool result = false;
//
bool isBullish = false;
bool isBearish = false;
//
int zIndex = 0;
int cIndex = zIndex + 1;
int pIndex = cIndex + 1;
int ppIndex = pIndex + 1;
//
int loopback = 10;
//
string symbol = _symbol;
ENUM_TIMEFRAMES period = _period;
//
conditions.symbol = symbol;
conditions.period = period;
//
XOHCL zBar;
result = zBar.Init(
symbol,
period,
zIndex //
);
if (!result)
{
return result;
}
//
XOHCL cBar;
result = cBar.Init(
symbol,
period,
cIndex //
);
if (!result)
{
return result;
}
//
XOHCL pBar;
result = pBar.Init(
symbol,
period,
pIndex //
);
if (!result)
{
return result;
}
//
double ask = GetAsk(symbol);
double bid = GetBid(symbol);
datetime cTime = TimeCurrent();
double points = GetPoints(symbol);
//
int swingLoopback = 9;
double ll = cBar.FindLowest(swingLoopback, MODE_LOW);
double hh = cBar.FindHighest(swingLoopback, MODE_HIGH);
double llDown = cBar.FindLowesttDown(swingLoopback);
double hhUp = cBar.FindHighestUp(swingLoopback);
//
// Cycles Conditions ...
//
// Trigger ...
ENUM_XPOI_EVENTS triggerPoiEvents[];
ENUM_X_CYCLE_EVENTS triggerCycleEvents[];
X121SMCCycleConditions triggerConditions;
result = triggerCycleHelper.GetConditions(
triggerCycleEvents,
triggerPoiEvents,
triggerConditions,
zIndex,
loopback //
);
if (!result)
{
return result;
}
//
// Decision ...
ENUM_XPOI_EVENTS decisionPoiEvents[];
ENUM_X_CYCLE_EVENTS decisionCycleEvents[];
X121SMCCycleConditions decisionConditions;
result = decisionCycleHelper.GetConditions(
decisionCycleEvents,
decisionPoiEvents,
decisionConditions,
zIndex,
loopback //
);
if (!result)
{
return result;
}
//
// Analyse ...
ENUM_XPOI_EVENTS analysePoiEvents[];
ENUM_X_CYCLE_EVENTS analyseCycleEvents[];
X121SMCCycleConditions analyseConditions;
result = analyseCycleHelper.GetConditions(
analyseCycleEvents,
analysePoiEvents,
analyseConditions,
zIndex,
loopback //
);
if (!result)
{
return result;
}
//
// Verification ...
ENUM_XPOI_EVENTS verificationPoiEvents[];
ENUM_X_CYCLE_EVENTS verificationCycleEvents[];
X121SMCCycleConditions verificationConditions;
result = verificationCycleHelper.GetConditions(
verificationCycleEvents,
verificationPoiEvents,
verificationConditions,
zIndex,
loopback //
);
if (!result)
{
return result;
}
//
// Consolidation ...
ENUM_XPOI_EVENTS consolidationPoiEvents[];
ENUM_X_CYCLE_EVENTS consolidationCycleEvents[];
X121SMCCycleConditions consolidationConditions;
result = consolidationCycleHelper.GetConditions(
consolidationCycleEvents,
consolidationPoiEvents,
consolidationConditions,
zIndex,
loopback //
);
if (!result)
{
return result;
}
//
// Vision ...
ENUM_XPOI_EVENTS visionPoiEvents[];
ENUM_X_CYCLE_EVENTS visionCycleEvents[];
X121SMCCycleConditions visionConditions;
result = visionCycleHelper.GetConditions(
visionCycleEvents,
visionPoiEvents,
visionConditions,
zIndex,
loopback //
);
if (!result)
{
return result;
}
//
// Cycles POI States ...
XPOIState triggerState = triggerConditions.state;
XPOIState decisionState = decisionConditions.state;
XPOIState analyseState = analyseConditions.state;
XPOIState verificationState = verificationConditions.state;
XPOIState consolidationState = consolidationConditions.state;
XPOIState visionState = visionConditions.state;
//
// Setup Conditions ...
//
result = analyseConditions.x121Conditions.isStrSwitchedToBullish ||
analyseConditions.x121Conditions.isStrSwitchedToBearish;
if (!result)
{
return result;
}
//
result = isBullish ||
isBearish;
if (!result)
{
return result;
}
//
conditions.setupTime = cTime;
conditions.dir =
isBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
return result;
}
//
// Detect Trigger Conditions ...
bool DetectX121SMCXTWPVSiganlTrigger(
//
X121SMCStrategyXTWPVSignalConditions &conditions,
//
string _symbol,
ENUM_TIMEFRAMES _period,
//
XC121SMCCycleHelper *triggerCycleHelper,
XC121SMCCycleHelper *decisionCycleHelper,
XC121SMCCycleHelper *analyseCycleHelper,
XC121SMCCycleHelper *verificationCycleHelper,
XC121SMCCycleHelper *consolidationCycleHelper,
XC121SMCCycleHelper *visionCycleHelper,
//
int maxAllowedSetupAge = 60 //
//
)
{
//
bool result = false;
//
result = conditions.IsSetuped();
if (!result)
{
return result;
}
//
datetime setupTime = conditions.setupTime;
ENUM_X_DIRECTION setupDir = conditions.dir;
//
bool isBullish = IsBullish(setupDir);
bool isBearish = IsBearish(setupDir);
//
int zIndex = 0;
int cIndex = zIndex + 1;
int pIndex = cIndex + 1;
int ppIndex = pIndex + 1;
//
int loopback = 10;
//
string symbol = _symbol;
ENUM_TIMEFRAMES period = _period;
//
XOHCL zBar;
result = zBar.Init(
symbol,
period,
zIndex //
);
if (!result)
{
return result;
}
//
XOHCL cBar;
result = cBar.Init(
symbol,
period,
cIndex //
);
if (!result)
{
return result;
}
//
XOHCL pBar;
result = pBar.Init(
symbol,
period,
pIndex //
);
if (!result)
{
return result;
}
//
double ask = GetAsk(symbol);
double bid = GetBid(symbol);
datetime cTime = TimeCurrent();
double points = GetPoints(symbol);
//
int swingLoopback = 9;
double ll = cBar.FindLowest(swingLoopback, MODE_LOW);
double hh = cBar.FindHighest(swingLoopback, MODE_HIGH);
double llDown = cBar.FindLowesttDown(swingLoopback);
double hhUp = cBar.FindHighestUp(swingLoopback);
//
// Cycles Conditions ...
//
// Trigger ...
ENUM_XPOI_EVENTS triggerPoiEvents[];
ENUM_X_CYCLE_EVENTS triggerCycleEvents[];
X121SMCCycleConditions triggerConditions;
result = triggerCycleHelper.GetConditions(
triggerCycleEvents,
triggerPoiEvents,
triggerConditions,
zIndex,
loopback //
);
if (!result)
{
return result;
}
//
// Decision ...
ENUM_XPOI_EVENTS decisionPoiEvents[];
ENUM_X_CYCLE_EVENTS decisionCycleEvents[];
X121SMCCycleConditions decisionConditions;
result = decisionCycleHelper.GetConditions(
decisionCycleEvents,
decisionPoiEvents,
decisionConditions,
zIndex,
loopback //
);
if (!result)
{
return result;
}
//
// Analyse ...
ENUM_XPOI_EVENTS analysePoiEvents[];
ENUM_X_CYCLE_EVENTS analyseCycleEvents[];
X121SMCCycleConditions analyseConditions;
result = analyseCycleHelper.GetConditions(
analyseCycleEvents,
analysePoiEvents,
analyseConditions,
zIndex,
loopback //
);
if (!result)
{
return result;
}
//
// Verification ...
ENUM_XPOI_EVENTS verificationPoiEvents[];
ENUM_X_CYCLE_EVENTS verificationCycleEvents[];
X121SMCCycleConditions verificationConditions;
result = verificationCycleHelper.GetConditions(
verificationCycleEvents,
verificationPoiEvents,
verificationConditions,
zIndex,
loopback //
);
if (!result)
{
return result;
}
//
// Consolidation ...
ENUM_XPOI_EVENTS consolidationPoiEvents[];
ENUM_X_CYCLE_EVENTS consolidationCycleEvents[];
X121SMCCycleConditions consolidationConditions;
result = consolidationCycleHelper.GetConditions(
consolidationCycleEvents,
consolidationPoiEvents,
consolidationConditions,
zIndex,
loopback //
);
if (!result)
{
return result;
}
//
// Vision ...
ENUM_XPOI_EVENTS visionPoiEvents[];
ENUM_X_CYCLE_EVENTS visionCycleEvents[];
X121SMCCycleConditions visionConditions;
result = visionCycleHelper.GetConditions(
visionCycleEvents,
visionPoiEvents,
visionConditions,
zIndex,
loopback //
);
if (!result)
{
return result;
}
//
// Cycles POI States ...
XPOIState triggerState = triggerConditions.state;
XPOIState decisionState = decisionConditions.state;
XPOIState analyseState = analyseConditions.state;
XPOIState verificationState = verificationConditions.state;
XPOIState consolidationState = consolidationConditions.state;
XPOIState visionState = visionConditions.state;
//
// Trigger Conditions ...
//
// Detect Bullish Conditions ...
isBullish =
isBullish &&
cBar.IsBullish();
//
// Detect Bearish Conditions ...
isBearish =
isBearish &&
cBar.IsBearish();
//
result = isBullish ||
isBearish;
if (!result)
{
//
// Cleanup Setup Conditions ...
int setupAge = conditions.GetSetupAge();
if (IsValidSize(setupAge) &&
IsValidSize(maxAllowedSetupAge) &&
setupAge >= maxAllowedSetupAge)
{
conditions.Clean();
}
//
return result;
}
//
// Detect Nearest Pivot Point ...
//
// Detect Target ...
double target = CalculateTarget(
cBar,
analyseState,
setupDir //
);
if (target == 0)
{
//
target = CalculateTarget(
cBar,
verificationState,
setupDir //
);
}
//
double oppositTarget = CalculateTarget(
cBar,
analyseState,
Opposit(setupDir) //
);
//
double entry = GetEntry(
conditions.symbol,
setupDir //
);
//
// Filling SL Candidates ...
//
double sls[];
//
double atr = triggerConditions.x121Conditions.atrBuffer[1];
double peak = triggerConditions.x121Conditions.peaksBuffer[1];
double vale = triggerConditions.x121Conditions.valesBuffer[1];
//
if (isBullish)
{
//
double lowerVale = triggerCycleHelper.mX121Helper.xpvHelper.GetLowerVale(vale);
if (lowerVale > 0)
{
//
Add(
lowerVale,
sls //
);
}
}
else if (isBearish)
{
//
double higherPeak = triggerCycleHelper.mX121Helper.xpvHelper.GetHigherPeak(peak);
if (higherPeak > 0)
{
//
Add(
higherPeak,
sls //
);
}
}
//
if (ArraySize(sls) == 0)
{
}
//
double slsMin = GetMin(sls);
double slsMax = GetMax(sls);
//
double sl = isBullish
? slsMin - atr
: slsMax + atr;
double risk = MathAbs(entry - sl);
double targetDelta = 2 * (risk / 3);
if (target == 0)
{
//
int minTargetPint = 50;
double minTargetPointValue = minTargetPint * points;
if (targetDelta < minTargetPointValue)
{
targetDelta = minTargetPointValue;
}
//
// Force Target On Half Risk ...
target =
isBullish
? entry + targetDelta
: entry - targetDelta;
//
target = 0;
//
}
//
// Ignore Target ...
target = 0;
//
// Filling Conditions Props ...
conditions.sl = sl;
conditions.target = target;
conditions.triggerTime = cTime;
conditions.type = isBullish
? X_POSITION_TYPE_LONG
: X_POSITION_TYPE_SHORT;
//
return result;
}
//
// Draw Signal ...
int DrawX121SMCXTWPVSiganl(
X121SMCStrategyXTWPVSignalConditions &conditions,
XCBaseObject *&drawnObjects[],
XCPOIDrawer *drawer //
)
{
//
int result = 0;
//
Clean(drawnObjects);
//
if (drawer == NULL)
{
return result;
}
//
bool isSetuped = conditions.IsSetuped();
if (!isSetuped)
{
return result;
}
//
bool isBullish = IsBullish(conditions.dir);
//
result = ArraySize(drawnObjects);
//
return result;
}
//
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-325
View File
@@ -1,325 +0,0 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Indicator
// -------------------------------------------------
// Name: X121 ???
// Description: ??? ...
//
//
// 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 "SaherElm X121 ??? Indicator"
#property strict
//
// Definitions ...
//
#define ShortName "X121 ???"
//
// Includes Common Library ...
#include "../Libraries/x-saherelm.common.lib.mq5"
//
// Inputs ...
//
// Market ...
input group "Market";
//
// Presentation ...
input group "Presentation";
//
input int startCalculationForLastBars = 1000; // Calculate Last n Bars
//
// Buffers ...
//
#define hideColorIDX 0
#define bullishColorIDX 1
#define bearishColorIDX 2
#define neuturalColorIDX 3
//
#property indicator_chart_window
//
#property indicator_buffers 0
#property indicator_plots 0
//
// Plot Buffers ...
//
// Data Buffers ...
//
int mLastBufferIndex = 20;
//
// Variables, Properties and etc ...
//
// this counts Available Bars ...
int limit;
//
int maxLength;
//
// Event Handlers ...
/**
* Initialize Indicator ...
*
* @return ( int )
*/
int OnInit()
{
//
// Validate Inputs ...
if (!ValidateInputs())
{
return INIT_PARAMETERS_INCORRECT;
}
//
// Initialize Indicator Handlers ...
//
// because in some cases we may have more than one input for
// calculation and we must prevent any calculation
// untill we pass the biggest input length, here we get max Input length
// and then wait until pass it ...
maxLength = ExtractMaxLengthOfInputs();
//
// Define Index Buffers ...
DefineBuffers();
//
// Set Indicator ShortName ...
SetIndicatorName();
//
// Init Succeed ...
return INIT_SUCCEEDED;
}
/**
* De Initialize Indicator ...
*
* @param reason: Integer, De Initialization Reason ...
*/
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
}
/**
* Calculate Bars ...
*
* @param rates_total: Integer, Total Bars on Chart ...
* @param prev_calculated: Integer, Total Calculated Bars on Charts ...
* @param time: DateTime Array, History of Open Time ...
* @param open: Double Array, History of Open Prices ...
* @param high: Double Array, History of High Prices ...
* @param low: Double Array, History of Low Prices ...
* @param close: Double Array, History of Close Prices ...
* @param tick_volume: Long, History of Tick Volumes on Bar ...
* @param volume: Long, History of Trade Volumes ...
* @param spread: Double, History of Spread Price ...
*
* @return ( int )
*/
int OnCalculate(
const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[] //
)
{
//
// Prepare Buffers ...
ArraySetAsSeries(time, true);
ArraySetAsSeries(open, true);
ArraySetAsSeries(high, true);
ArraySetAsSeries(low, true);
ArraySetAsSeries(close, true);
ArraySetAsSeries(tick_volume, true);
ArraySetAsSeries(volume, true);
ArraySetAsSeries(spread, true);
//
// Validate Calculated Bars ...
//
limit = (prev_calculated > rates_total || prev_calculated <= 0)
? rates_total
: (rates_total - prev_calculated) + 1;
//
// Buffers Copy ...
//
// Main Loop ...
for (int i = limit - 1; i >= 0 && !IsStopped(); i--)
{
//
CalculateBuffers(
i,
prev_calculated,
rates_total,
//
open,
high,
close,
low,
tick_volume //
);
}
//
return rates_total;
}
//
// Functions ...
/**
* Validate Input Args for Initialization ...
*
* @return ( bool )
*/
bool ValidateInputs()
{
//
bool result = false;
//
result =
//
false
//
;
//
return result;
}
/**
* Extract Max Length of Inputs ...
*
* @return ( int )
*/
int ExtractMaxLengthOfInputs()
{
//
int result = 0;
//
return result;
}
/**
* Define Required Buffers ...
*/
void DefineBuffers()
{
//
// Plot Buffers ...
//
// Data Buffers ...
}
/**
* Set Indicator Short Name and also we can define Buffers Labels ...
*/
void SetIndicatorName()
{
IndicatorSetString(INDICATOR_SHORTNAME, ShortName);
}
/**
* Calculate Custom Buffers ...
*
* @param bar_index: Integer, Represent Current Bar ...
* @param prevCalculated: Integer, Represent Previous Calculated Bars ...
* @param ratesTotal: Integer, Represents All Available Bars ...
* @param open: Double Array, History of Open Prices ...
* @param high: Double Array, History of High Prices ...
* @param close: Double Array, History of Close Prices ...
* @param low: Double Array, History of Low Prices ...
* @param tickVolume: Long, History of Tick Volumes on Bar ...
*/
void CalculateBuffers(
int bar_index, // Selected Bar Index
const int prevCalculated,
const int ratesTotal,
const double &open[],
const double &high[],
const double &close[],
const double &low[],
const long &tickVolume[] //
)
{
//
int barsLimit = startCalculationForLastBars > 0
? startCalculationForLastBars
: 0;
//
// bool canCalculate = true;
bool canCalculate =
barsLimit == 0 ||
bar_index <= barsLimit;
if (canCalculate)
{
}
else
{
FillBuffersZero(bar_index);
}
}
//
// Custom ...
/**
* Fill All Bufers to Zero Vlue for Specified Bar Index ...
*
* @param barIndex: Integer ...
*/
void FillBuffersZero(int barIndex)
{
}
//
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff