add xche to supports list ...
This commit is contained in:
@@ -58,23 +58,23 @@ input int eaMinRequiredVerificationForSpreadPass = 20; // Minimum Spread Ve
|
||||
// Trade ...
|
||||
input group "Trade";
|
||||
input bool eaAllowTrade = true; // Allow Open Trade On Signals
|
||||
input string eaStartTradeAt = ""; // Enable Trade on Signals on Time
|
||||
input string eaStopTradeAt = ""; // Enable Trade on Signals on Time
|
||||
input string eaCloseAllTradesAt = ""; // Enable Close All Trades on Signals on Time
|
||||
input string eaStartTradeAt = "2:00"; // Enable Trade on Signals on Time
|
||||
input string eaStopTradeAt = "21:00"; // Enable Trade on Signals on Time
|
||||
input string eaCloseAllTradesAt = "23:55"; // Enable Close All Trades on Signals on Time
|
||||
|
||||
//
|
||||
// Risk Management ...
|
||||
input group "Risk Management";
|
||||
input double eaR2R = 3; // Signallers Risk to Reward Ratio
|
||||
input double eaVolume = 0.05; // Static Volume
|
||||
input double eaRiskPercentPerBalance = 0.1; // Risk Percent Per Balance in Each Trade
|
||||
input bool eaDynamicRiskManagement = false; // Dynamic Risk Management
|
||||
input bool eaUseDynamicVolume = false; // Use Dynamic Volume
|
||||
input double eaDynamicVolumeStep = 0.01; // Increase Volume Step
|
||||
input double eaDynamicVolumeBalanceFactor = 200; // Balance Factor for Generate Dynamic Volume
|
||||
input double eaMaxAllowedDrawdownToOpenTrades = 3; // Max Allowed Drawdown for Open Trades
|
||||
input int eaMaxAllowedSLToPauseSignallingPerSymbol = 0; // Max Allowed SL for Pause Signalling Per Symbol
|
||||
input int eaPauseSignallingAfterReachesMaxAllowedSLInSecconds = 14400; // Pause Signalling Per Symbol afte Max Allowed SL Reached In Seconds
|
||||
input double eaR2R = 3; // Signallers Risk to Reward Ratio
|
||||
input double eaVolume = 0.05; // Static Volume
|
||||
input double eaRiskPercentPerBalance = 1.0; // Risk Percent Per Balance in Each Trade
|
||||
input bool eaDynamicRiskManagement = false; // Dynamic Risk Management
|
||||
input bool eaUseDynamicVolume = false; // Use Dynamic Volume
|
||||
input double eaDynamicVolumeStep = 0.01; // Increase Volume Step
|
||||
input double eaDynamicVolumeBalanceFactor = 200; // Balance Factor for Generate Dynamic Volume
|
||||
input double eaMaxAllowedDrawdownToOpenTrades = 3; // Max Allowed Drawdown for Open Trades
|
||||
input int eaMaxAllowedSLToPauseSignallingPerSymbol = 2; // Max Allowed SL for Pause Signalling Per Symbol
|
||||
input int eaPauseSignallingAfterReachesMaxAllowedSLInSecconds = 7200; // Pause Signalling Per Symbol afte Max Allowed SL Reached In Seconds
|
||||
|
||||
//
|
||||
// Protection ...
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -521,7 +521,7 @@ class XCX121XPVHelper : public XCBaseHelper
|
||||
bool Init(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Period
|
||||
X121XPVInputs &inputs // Inputs
|
||||
X121XPVInputs &inputs // Inputs
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -811,6 +811,7 @@ class XCX121XPVHelper : public XCBaseHelper
|
||||
|
||||
//
|
||||
double GetHigherPeak(
|
||||
int &index, // Bar Index
|
||||
double peak, // Peak Source
|
||||
int barIndex = 0, // Bar Index
|
||||
int loopback = 576 // Max Allowed Loopback
|
||||
@@ -819,6 +820,9 @@ class XCX121XPVHelper : public XCBaseHelper
|
||||
//
|
||||
double result = 0;
|
||||
|
||||
//
|
||||
index = -1;
|
||||
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
@@ -839,22 +843,23 @@ class XCX121XPVHelper : public XCBaseHelper
|
||||
|
||||
//
|
||||
double iValue = 0;
|
||||
int index = barIndex;
|
||||
int sIndex = barIndex;
|
||||
bool canContinue = true;
|
||||
while (canContinue)
|
||||
{
|
||||
//
|
||||
iValue = GetPeak(index);
|
||||
iValue = GetPeak(sIndex);
|
||||
if (iValue > peak)
|
||||
{
|
||||
//
|
||||
index = sIndex;
|
||||
result = iValue;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
canContinue = index < barIndex + loopback;
|
||||
index++;
|
||||
canContinue = sIndex < barIndex + loopback;
|
||||
sIndex++;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -863,6 +868,7 @@ class XCX121XPVHelper : public XCBaseHelper
|
||||
|
||||
//
|
||||
double GetLowerPeak(
|
||||
int &index, // Bar Index
|
||||
double peak, // Peak Source
|
||||
int barIndex = 0, // Bar Index
|
||||
int loopback = 576 // Max Allowed Loopback
|
||||
@@ -871,6 +877,9 @@ class XCX121XPVHelper : public XCBaseHelper
|
||||
//
|
||||
double result = 0;
|
||||
|
||||
//
|
||||
index = -1;
|
||||
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
@@ -891,22 +900,23 @@ class XCX121XPVHelper : public XCBaseHelper
|
||||
|
||||
//
|
||||
double iValue = 0;
|
||||
int index = barIndex;
|
||||
int sIndex = barIndex;
|
||||
bool canContinue = true;
|
||||
while (canContinue)
|
||||
{
|
||||
//
|
||||
iValue = GetPeak(index);
|
||||
iValue = GetPeak(sIndex);
|
||||
if (iValue < peak)
|
||||
{
|
||||
//
|
||||
index = sIndex;
|
||||
result = iValue;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
canContinue = index < barIndex + loopback;
|
||||
index++;
|
||||
canContinue = sIndex < barIndex + loopback;
|
||||
sIndex++;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -915,6 +925,7 @@ class XCX121XPVHelper : public XCBaseHelper
|
||||
|
||||
//
|
||||
double GetHigherVale(
|
||||
int &index, // Bar Index
|
||||
double vale, // Vale Source
|
||||
int barIndex = 0, // Bar Index
|
||||
int loopback = 576 // Max Allowed Loopback
|
||||
@@ -923,6 +934,9 @@ class XCX121XPVHelper : public XCBaseHelper
|
||||
//
|
||||
double result = 0;
|
||||
|
||||
//
|
||||
index = -1;
|
||||
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
@@ -943,22 +957,23 @@ class XCX121XPVHelper : public XCBaseHelper
|
||||
|
||||
//
|
||||
double iValue = 0;
|
||||
int index = barIndex;
|
||||
int sIndex = barIndex;
|
||||
bool canContinue = true;
|
||||
while (canContinue)
|
||||
{
|
||||
//
|
||||
iValue = GetVale(index);
|
||||
iValue = GetVale(sIndex);
|
||||
if (iValue > vale)
|
||||
{
|
||||
//
|
||||
index = sIndex;
|
||||
result = iValue;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
canContinue = index < barIndex + loopback;
|
||||
index++;
|
||||
canContinue = sIndex < barIndex + loopback;
|
||||
sIndex++;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -967,6 +982,7 @@ class XCX121XPVHelper : public XCBaseHelper
|
||||
|
||||
//
|
||||
double GetLowerVale(
|
||||
int &index, // Bar Index
|
||||
double vale, // Vale Source
|
||||
int barIndex = 0, // Bar Index
|
||||
int loopback = 576 // Max Allowed Loopback
|
||||
@@ -975,6 +991,9 @@ class XCX121XPVHelper : public XCBaseHelper
|
||||
//
|
||||
double result = 0;
|
||||
|
||||
//
|
||||
index = -1;
|
||||
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
@@ -995,22 +1014,23 @@ class XCX121XPVHelper : public XCBaseHelper
|
||||
|
||||
//
|
||||
double iValue = 0;
|
||||
int index = barIndex;
|
||||
int sIndex = barIndex;
|
||||
bool canContinue = true;
|
||||
while (canContinue)
|
||||
{
|
||||
//
|
||||
iValue = GetVale(index);
|
||||
iValue = GetVale(sIndex);
|
||||
if (iValue < vale)
|
||||
{
|
||||
//
|
||||
index = sIndex;
|
||||
result = iValue;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
canContinue = index < barIndex + loopback;
|
||||
index++;
|
||||
canContinue = sIndex < barIndex + loopback;
|
||||
sIndex++;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1778,8 +1798,8 @@ class XCX121XPVHelper : public XCBaseHelper
|
||||
//
|
||||
bool GetConditions(
|
||||
X121XPVConditions &conditions, //
|
||||
int barIndex = 0, //
|
||||
int loopback = 5 //
|
||||
int barIndex = 0, //
|
||||
int loopback = 5 //
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -1949,7 +1969,6 @@ class XCX121XPVHelper : public XCBaseHelper
|
||||
bool isSarBullish = conditions.sarBuffer[cIDX] < cBar.low;
|
||||
bool isSarBullishPrev = conditions.sarBuffer[pIDX] < pBar.low;
|
||||
|
||||
|
||||
//
|
||||
bool isSarBearish = conditions.sarBuffer[cIDX] > cBar.high;
|
||||
bool isSarBearishPrev = conditions.sarBuffer[pIDX] > pBar.high;
|
||||
@@ -2028,7 +2047,7 @@ class XCX121XPVHelper : public XCBaseHelper
|
||||
{
|
||||
totalBars = 1000;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
|
||||
@@ -27,8 +27,6 @@
|
||||
|
||||
//
|
||||
// Includes Common Library ...
|
||||
#include "../Classes/x-saherelm.x-poi.class.mq5"
|
||||
#include "../Classes/x-saherelm.x-poi.drawer.class.mq5"
|
||||
#include "../Libraries/x-saherelm.common.lib.mq5"
|
||||
|
||||
//
|
||||
|
||||
@@ -0,0 +1,624 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Indicator
|
||||
// -------------------------------------------------
|
||||
// Name: X121 XCHE
|
||||
// Description: XCHE ...
|
||||
//
|
||||
//
|
||||
// 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 XCHE Indicator"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
#define ShortName "X121 XCHE"
|
||||
|
||||
//
|
||||
// Includes Common Library ...
|
||||
#include "../Libraries/x-saherelm.common.lib.mq5"
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
//
|
||||
// Market ...
|
||||
input group "Market";
|
||||
input int cheLength = 35; // Length
|
||||
input int cheLoopback = 26; // Loopback
|
||||
input double cheMultiplier1 = 3.0; // 1st Multiplier
|
||||
input double cheMultiplier2 = 3.5; // 2nd Multiplier
|
||||
input ENUM_APPLIED_PRICE cheUpperAppliedTo = PRICE_HIGH; // Upper Zone Applied to
|
||||
input ENUM_APPLIED_PRICE cheLowerAppliedTo = PRICE_LOW; // Lower Zone Applied to
|
||||
|
||||
//
|
||||
input group "Presentation";
|
||||
|
||||
//
|
||||
input int cheArrowCode = 159; // CHE Arrow Code
|
||||
|
||||
//
|
||||
input bool showLE1 = true; // Show 1st Long Exit
|
||||
input bool showSE1 = true; // Show 1st Short Exit
|
||||
input bool showLE2 = true; // Show 2st Long Exit
|
||||
input bool showSE2 = true; // Show 2st Short Exit
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
#define hideColorIDX 0
|
||||
#define bullishColorIDX 1
|
||||
#define bearishColorIDX 2
|
||||
#define neuturalColorIDX 3
|
||||
|
||||
//
|
||||
#property indicator_chart_window
|
||||
|
||||
//
|
||||
#property indicator_buffers 8
|
||||
#property indicator_plots 8
|
||||
|
||||
//
|
||||
// Exit 1 ...
|
||||
|
||||
//
|
||||
// LONG ...
|
||||
|
||||
//
|
||||
#define le1BufferIndex 0
|
||||
double le1Buffer[];
|
||||
|
||||
#property indicator_label1 "X121 LE1"
|
||||
#property indicator_type1 DRAW_LINE
|
||||
#property indicator_color1 clrAqua
|
||||
#property indicator_style1 STYLE_DOT
|
||||
#property indicator_width1 1
|
||||
|
||||
//
|
||||
// SHORT ...
|
||||
|
||||
//
|
||||
#define se1BufferIndex 1
|
||||
double se1Buffer[];
|
||||
|
||||
#property indicator_label2 "X121 SE1"
|
||||
#property indicator_type2 DRAW_LINE
|
||||
#property indicator_color2 clrMagenta
|
||||
#property indicator_style2 STYLE_DOT
|
||||
#property indicator_width2 1
|
||||
|
||||
//
|
||||
// Exit 2 ...
|
||||
|
||||
//
|
||||
// LONG ...
|
||||
|
||||
//
|
||||
#define le2BufferIndex 2
|
||||
double le2Buffer[];
|
||||
|
||||
#property indicator_label3 "X121 LE2"
|
||||
#property indicator_type3 DRAW_LINE
|
||||
#property indicator_color3 clrAqua
|
||||
#property indicator_style3 STYLE_SOLID
|
||||
#property indicator_width3 1
|
||||
|
||||
//
|
||||
// SHORT ...
|
||||
|
||||
//
|
||||
#define se2BufferIndex 3
|
||||
double se2Buffer[];
|
||||
|
||||
#property indicator_label4 "X121 SE2"
|
||||
#property indicator_type4 DRAW_LINE
|
||||
#property indicator_color4 clrMagenta
|
||||
#property indicator_style4 STYLE_SOLID
|
||||
#property indicator_width4 1
|
||||
|
||||
//
|
||||
// Start Buffers ...
|
||||
|
||||
//
|
||||
#define le1StartBufferIndex 4
|
||||
double le1StartBuffer[];
|
||||
|
||||
//
|
||||
#property indicator_label5 "X121 LE1 S"
|
||||
#property indicator_type5 DRAW_ARROW
|
||||
#property indicator_color5 clrLime
|
||||
|
||||
//
|
||||
#define se1StartBufferIndex 5
|
||||
double se1StartBuffer[];
|
||||
|
||||
//
|
||||
#property indicator_label6 "X121 SE1 S"
|
||||
#property indicator_type6 DRAW_ARROW
|
||||
#property indicator_color6 clrRed
|
||||
|
||||
//
|
||||
#define le2StartBufferIndex 6
|
||||
double le2StartBuffer[];
|
||||
|
||||
//
|
||||
#property indicator_label7 "X121 LE2 S"
|
||||
#property indicator_type7 DRAW_ARROW
|
||||
#property indicator_color7 clrLime
|
||||
|
||||
//
|
||||
#define se2StartBufferIndex 7
|
||||
double se2StartBuffer[];
|
||||
|
||||
//
|
||||
#property indicator_label8 "X121 SE2 S"
|
||||
#property indicator_type8 DRAW_ARROW
|
||||
#property indicator_color8 clrRed
|
||||
|
||||
//
|
||||
// Variables, Properties and etc ...
|
||||
|
||||
//
|
||||
// this counts Available Bars ...
|
||||
int limit;
|
||||
|
||||
//
|
||||
int maxLength;
|
||||
|
||||
//
|
||||
// Working Array ...
|
||||
double work[][6];
|
||||
#define hi1Idx 0
|
||||
#define lo1Idx 1
|
||||
#define hi2Idx 2
|
||||
#define lo2Idx 3
|
||||
#define trend1Idx 4
|
||||
#define trend2Idx 5
|
||||
|
||||
//
|
||||
// Event Handlers ...
|
||||
|
||||
/**
|
||||
* Initialize Indicator ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
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 cheLength, here we get max Input cheLength
|
||||
// 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[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
if (Bars(_Symbol, _Period) < rates_total)
|
||||
{
|
||||
return (prev_calculated);
|
||||
}
|
||||
|
||||
//
|
||||
if (ArrayRange(work, 0) != rates_total)
|
||||
{
|
||||
ArrayResize(work, rates_total);
|
||||
}
|
||||
|
||||
//
|
||||
// this counts Available Bars ...
|
||||
|
||||
//
|
||||
limit = prev_calculated - 1;
|
||||
if (limit < 0)
|
||||
{
|
||||
limit = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Main Loop ...
|
||||
for (int i = limit; i < rates_total && !IsStopped(); i++)
|
||||
{
|
||||
CalculateBuffers(
|
||||
i,
|
||||
prev_calculated,
|
||||
rates_total,
|
||||
//
|
||||
open,
|
||||
high,
|
||||
low,
|
||||
close);
|
||||
}
|
||||
|
||||
//
|
||||
return rates_total;
|
||||
}
|
||||
|
||||
//
|
||||
// Functions ...
|
||||
|
||||
/**
|
||||
* Validate Input Args for Initialization ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool ValidateInputs()
|
||||
{
|
||||
//
|
||||
bool result = true;
|
||||
|
||||
//
|
||||
result =
|
||||
cheLength >= 9 &&
|
||||
cheLoopback >= 0;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract Max Length of Inputs ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int ExtractMaxLengthOfInputs()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
result = MathMax(cheLength, cheLoopback);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define Required Buffers ...
|
||||
*/
|
||||
void DefineBuffers()
|
||||
{
|
||||
//
|
||||
// LEVEL 1 ...
|
||||
|
||||
//
|
||||
// Long Exit 1 ...
|
||||
|
||||
//
|
||||
// Draw Type ...
|
||||
ENUM_DRAW_TYPE le1DrawType = showLE1 ? DRAW_LINE : DRAW_NONE;
|
||||
ENUM_DRAW_TYPE le1StartDrawType = showLE1 ? DRAW_ARROW : DRAW_NONE;
|
||||
|
||||
//
|
||||
// Buffer ...
|
||||
SetIndexBuffer(le1BufferIndex, le1Buffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(le1BufferIndex, PLOT_SHOW_DATA, showLE1);
|
||||
PlotIndexSetInteger(le1BufferIndex, PLOT_DRAW_TYPE, le1DrawType);
|
||||
|
||||
//
|
||||
// Start Buffer ...
|
||||
SetIndexBuffer(le1StartBufferIndex, le1StartBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(le1StartBufferIndex, PLOT_SHOW_DATA, false);
|
||||
PlotIndexSetInteger(le1StartBufferIndex, PLOT_DRAW_TYPE, le1StartDrawType);
|
||||
PlotIndexSetInteger(le1StartBufferIndex, PLOT_ARROW, cheArrowCode);
|
||||
|
||||
//
|
||||
// Short Exit 1 ...
|
||||
|
||||
//
|
||||
// Draw Type ...
|
||||
ENUM_DRAW_TYPE se1DrawType = showSE1 ? DRAW_LINE : DRAW_NONE;
|
||||
ENUM_DRAW_TYPE se1StartDrawType = showSE1 ? DRAW_ARROW : DRAW_NONE;
|
||||
|
||||
//
|
||||
// Buffer ...
|
||||
SetIndexBuffer(se1BufferIndex, se1Buffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(se1BufferIndex, PLOT_SHOW_DATA, showSE1);
|
||||
PlotIndexSetInteger(se1BufferIndex, PLOT_DRAW_TYPE, se1DrawType);
|
||||
|
||||
//
|
||||
// Start Buffer ...
|
||||
SetIndexBuffer(se1StartBufferIndex, se1StartBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(se1StartBufferIndex, PLOT_SHOW_DATA, false);
|
||||
PlotIndexSetInteger(se1StartBufferIndex, PLOT_DRAW_TYPE, se1StartDrawType);
|
||||
PlotIndexSetInteger(se1StartBufferIndex, PLOT_ARROW, cheArrowCode);
|
||||
|
||||
//
|
||||
// LEVEL 2 ...
|
||||
|
||||
//
|
||||
// Long Exit 2 ...
|
||||
|
||||
//
|
||||
// Draw Type ...
|
||||
ENUM_DRAW_TYPE le2DrawType = showLE2 ? DRAW_LINE : DRAW_NONE;
|
||||
ENUM_DRAW_TYPE le2StartDrawType = showLE2 ? DRAW_ARROW : DRAW_NONE;
|
||||
|
||||
//
|
||||
// Buffer ...
|
||||
SetIndexBuffer(le2BufferIndex, le2Buffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(le2BufferIndex, PLOT_SHOW_DATA, showLE2);
|
||||
PlotIndexSetInteger(le2BufferIndex, PLOT_DRAW_TYPE, le2DrawType);
|
||||
|
||||
//
|
||||
// Start Buffer ...
|
||||
SetIndexBuffer(le2StartBufferIndex, le2StartBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(le2StartBufferIndex, PLOT_SHOW_DATA, false);
|
||||
PlotIndexSetInteger(le2StartBufferIndex, PLOT_DRAW_TYPE, le2StartDrawType);
|
||||
PlotIndexSetInteger(le2StartBufferIndex, PLOT_ARROW, cheArrowCode);
|
||||
|
||||
//
|
||||
// Short Exit 2 ...
|
||||
|
||||
//
|
||||
// Draw Type ...
|
||||
ENUM_DRAW_TYPE se2DrawType = showSE2 ? DRAW_LINE : DRAW_NONE;
|
||||
ENUM_DRAW_TYPE se2StartDrawType = showSE2 ? DRAW_ARROW : DRAW_NONE;
|
||||
|
||||
//
|
||||
// Buffer ...
|
||||
SetIndexBuffer(se2BufferIndex, se2Buffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(se2BufferIndex, PLOT_SHOW_DATA, showSE2);
|
||||
PlotIndexSetInteger(se2BufferIndex, PLOT_DRAW_TYPE, se2DrawType);
|
||||
|
||||
//
|
||||
// Start Buffer ...
|
||||
SetIndexBuffer(se2StartBufferIndex, se2StartBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(se2StartBufferIndex, PLOT_SHOW_DATA, false);
|
||||
PlotIndexSetInteger(se2StartBufferIndex, PLOT_DRAW_TYPE, se2StartDrawType);
|
||||
PlotIndexSetInteger(se2StartBufferIndex, PLOT_ARROW, cheArrowCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Indicator Short Name and also we can define Buffers Labels ...
|
||||
*/
|
||||
void SetIndicatorName()
|
||||
{
|
||||
IndicatorSetString(INDICATOR_SHORTNAME, ShortName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate Buffers ...
|
||||
*/
|
||||
void CalculateBuffers(
|
||||
int bar_index, // Selected Bar Index
|
||||
int prevCalculated, // Previous Calculated
|
||||
int ratesTotal, // Total Rates
|
||||
const double &open[], // Rates Open ...
|
||||
const double &high[], // Rates High ...
|
||||
const double &low[], // Rates Low ...
|
||||
const double &close[] // Rates Close ...
|
||||
)
|
||||
{
|
||||
//
|
||||
// Cleanup Buffers ...
|
||||
le1Buffer[bar_index] = le1StartBuffer[bar_index] = se1Buffer[bar_index] = se1StartBuffer[bar_index] = EMPTY_VALUE;
|
||||
le2Buffer[bar_index] = le2StartBuffer[bar_index] = se2Buffer[bar_index] = se2StartBuffer[bar_index] = EMPTY_VALUE;
|
||||
|
||||
//
|
||||
int start = MathMax(bar_index - cheLoopback, 0);
|
||||
|
||||
//
|
||||
// Calculate ATR Value ...
|
||||
double atrValue = 0;
|
||||
for (int k = 1; k <= cheLength && (bar_index - k - 1) >= 0; k++)
|
||||
{
|
||||
//
|
||||
atrValue += MathMax(high[bar_index - k], close[MathMax(bar_index - k - 1, 0)]) -
|
||||
MathMin(low[bar_index - k], close[MathMax(bar_index - k - 1, 0)]);
|
||||
}
|
||||
atrValue /= (double)cheLength;
|
||||
|
||||
//
|
||||
// Retrieve Highest High and Lowest Lows ...
|
||||
double cheLoopbackMax = high[ArrayMaximum(high, start, cheLoopback)];
|
||||
double cheLoopbackMin = low[ArrayMinimum(low, start, cheLoopback)];
|
||||
|
||||
//
|
||||
// Fill Multi Dimesional Working Array ...
|
||||
work[bar_index][hi1Idx] = cheLoopbackMax - cheMultiplier1 * atrValue;
|
||||
work[bar_index][lo1Idx] = cheLoopbackMin + cheMultiplier1 * atrValue;
|
||||
work[bar_index][hi2Idx] = cheLoopbackMax - cheMultiplier2 * atrValue;
|
||||
work[bar_index][lo2Idx] = cheLoopbackMin + cheMultiplier2 * atrValue;
|
||||
work[bar_index][trend1Idx] = (bar_index > 0) ? work[bar_index - 1][trend1Idx] : 0;
|
||||
work[bar_index][trend2Idx] = (bar_index > 0) ? work[bar_index - 1][trend2Idx] : 0;
|
||||
|
||||
//
|
||||
if (bar_index > 0)
|
||||
{
|
||||
//
|
||||
// Calculate Trends ...
|
||||
if (close[bar_index] > work[bar_index - 1][lo1Idx])
|
||||
{
|
||||
work[bar_index][trend1Idx] = 1;
|
||||
}
|
||||
|
||||
//
|
||||
if (close[bar_index] < work[bar_index - 1][hi1Idx])
|
||||
{
|
||||
work[bar_index][trend1Idx] = -1;
|
||||
}
|
||||
|
||||
//
|
||||
if (close[bar_index] > work[bar_index - 1][lo2Idx])
|
||||
{
|
||||
work[bar_index][trend2Idx] = 1;
|
||||
}
|
||||
|
||||
//
|
||||
if (close[bar_index] < work[bar_index - 1][hi2Idx])
|
||||
{
|
||||
work[bar_index][trend2Idx] = -1;
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate Exit Values ...
|
||||
|
||||
//
|
||||
// Exit 1 ...
|
||||
|
||||
//
|
||||
// Long ...
|
||||
if (cheMultiplier1 > 0 && work[bar_index][trend1Idx] == 1)
|
||||
{
|
||||
//
|
||||
if (work[bar_index][hi1Idx] < work[bar_index - 1][hi1Idx])
|
||||
{
|
||||
work[bar_index][hi1Idx] = work[bar_index - 1][hi1Idx];
|
||||
}
|
||||
|
||||
//
|
||||
le1Buffer[bar_index] = work[bar_index][hi1Idx];
|
||||
|
||||
//
|
||||
if (le1Buffer[bar_index - 1] == EMPTY_VALUE)
|
||||
{
|
||||
le1StartBuffer[bar_index] = le1Buffer[bar_index];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Short ...
|
||||
if (cheMultiplier1 > 0 && work[bar_index][trend1Idx] == -1)
|
||||
{
|
||||
//
|
||||
if (work[bar_index][lo1Idx] > work[bar_index - 1][lo1Idx])
|
||||
{
|
||||
work[bar_index][lo1Idx] = work[bar_index - 1][lo1Idx];
|
||||
}
|
||||
|
||||
//
|
||||
se1Buffer[bar_index] = work[bar_index][lo1Idx];
|
||||
|
||||
//
|
||||
if (se1Buffer[bar_index - 1] == EMPTY_VALUE)
|
||||
{
|
||||
se1StartBuffer[bar_index] = se1Buffer[bar_index];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Exit 2 ...
|
||||
|
||||
//
|
||||
// Long ...
|
||||
if (cheMultiplier2 > 0 && work[bar_index][trend2Idx] == 1)
|
||||
{
|
||||
if (work[bar_index][hi2Idx] < work[bar_index - 1][hi2Idx])
|
||||
{
|
||||
work[bar_index][hi2Idx] = work[bar_index - 1][hi2Idx];
|
||||
}
|
||||
|
||||
//
|
||||
le2Buffer[bar_index] = work[bar_index][hi2Idx];
|
||||
|
||||
//
|
||||
if (le2Buffer[bar_index - 1] == EMPTY_VALUE)
|
||||
{
|
||||
le2StartBuffer[bar_index] = le2Buffer[bar_index];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Short ...
|
||||
if (cheMultiplier2 > 0 && work[bar_index][trend2Idx] == -1)
|
||||
{
|
||||
//
|
||||
if (work[bar_index][lo2Idx] > work[bar_index - 1][lo2Idx])
|
||||
{
|
||||
work[bar_index][lo2Idx] = work[bar_index - 1][lo2Idx];
|
||||
}
|
||||
|
||||
//
|
||||
se2Buffer[bar_index] = work[bar_index][lo2Idx];
|
||||
|
||||
//
|
||||
if (se2Buffer[bar_index - 1] == EMPTY_VALUE)
|
||||
{
|
||||
se2StartBuffer[bar_index] = se2Buffer[bar_index];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -27,8 +27,6 @@
|
||||
|
||||
//
|
||||
// Includes Common Library ...
|
||||
#include "../Classes/x-saherelm.x-poi.class.mq5"
|
||||
#include "../Classes/x-saherelm.x-poi.drawer.class.mq5"
|
||||
#include "../Libraries/x-saherelm.common.lib.mq5"
|
||||
|
||||
//
|
||||
|
||||
@@ -6139,14 +6139,26 @@ bool IsUnder(
|
||||
//
|
||||
// Check if a Value Increasing in Loopback ...
|
||||
bool IsIncreasing(
|
||||
const int from, // Last Time Index
|
||||
const int to, // Fisrs Tima Index
|
||||
const double &buffer[] // the Buffer which required to search
|
||||
const double &buffer[], // the Buffer which required to search
|
||||
int from = -1, // Last Time Index
|
||||
int to = -1 // Fisrs Tima Index
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (from == -1)
|
||||
{
|
||||
from = ArraySize(buffer) - 1;
|
||||
}
|
||||
|
||||
//
|
||||
if (to == -1)
|
||||
{
|
||||
to = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Args ...
|
||||
if (
|
||||
@@ -6160,7 +6172,7 @@ bool IsIncreasing(
|
||||
// Loop through Items ...
|
||||
double toValue = buffer[to];
|
||||
double fromValue = buffer[from];
|
||||
result = toValue > fromValue;
|
||||
result = toValue >= fromValue;
|
||||
for (int i = to + 1; i <= from - 1; i++)
|
||||
{
|
||||
//
|
||||
@@ -6169,9 +6181,10 @@ bool IsIncreasing(
|
||||
|
||||
//
|
||||
bool isIIncreasing = IsIncreasing(
|
||||
buffer,
|
||||
from,
|
||||
i,
|
||||
buffer);
|
||||
i //
|
||||
);
|
||||
|
||||
//
|
||||
// Check Result ...
|
||||
@@ -6189,14 +6202,26 @@ bool IsIncreasing(
|
||||
//
|
||||
// Check if a Value Decreasing in Loopback ...
|
||||
bool IsDecreasing(
|
||||
const int from, // Last Time Index
|
||||
const int to, // Fisr Tima Index
|
||||
const double &buffer[] // the Buffer which required to search
|
||||
const double &buffer[], // the Buffer which required to search
|
||||
int from = -1, // Last Time Index
|
||||
int to = -1 // Fisrs Tima Index
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (from == -1)
|
||||
{
|
||||
from = ArraySize(buffer) - 1;
|
||||
}
|
||||
|
||||
//
|
||||
if (to == -1)
|
||||
{
|
||||
to = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Args ...
|
||||
if (
|
||||
@@ -6210,7 +6235,7 @@ bool IsDecreasing(
|
||||
// Loop through Items ...
|
||||
double toValue = buffer[to];
|
||||
double fromValue = buffer[from];
|
||||
result = toValue < fromValue;
|
||||
result = toValue <= fromValue;
|
||||
for (int i = to + 1; i <= from - 1; i++)
|
||||
{
|
||||
//
|
||||
@@ -6219,9 +6244,10 @@ bool IsDecreasing(
|
||||
|
||||
//
|
||||
bool isIDecreasing = IsDecreasing(
|
||||
buffer,
|
||||
from,
|
||||
i,
|
||||
buffer);
|
||||
i //
|
||||
);
|
||||
|
||||
//
|
||||
// Check Result ...
|
||||
|
||||
@@ -128,7 +128,8 @@ class XC121SMCCycleHelper : public XCBase
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (requiredPOIS < 10) {
|
||||
if (requiredPOIS < 10)
|
||||
{
|
||||
requiredPOIS = 10;
|
||||
}
|
||||
|
||||
@@ -882,6 +883,199 @@ class XC121SMCCycleHelper : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect Market Structure Method 2 ...
|
||||
*
|
||||
* @param model: XMarketStructure instance Reference ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool DetectMarketStructure(
|
||||
ENUM_X_DIRECTION &dir,
|
||||
int pivotsCount = 3 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
int barIndex = 0;
|
||||
|
||||
//
|
||||
if (pivotsCount < 3)
|
||||
{
|
||||
pivotsCount = 3;
|
||||
}
|
||||
|
||||
//
|
||||
dir = X_DIRECTION_NONE;
|
||||
string symbol = GetSymbol();
|
||||
ENUM_TIMEFRAMES period = GetPeriod();
|
||||
|
||||
//
|
||||
int hpIndex = -1;
|
||||
int hpIndexes[];
|
||||
double hpValues[];
|
||||
|
||||
//
|
||||
int lvIndex = -1;
|
||||
int lvIndexes[];
|
||||
double lvValues[];
|
||||
|
||||
//
|
||||
for (int i = 0; i < pivotsCount; i++)
|
||||
{
|
||||
//
|
||||
hpIndex = barIndex;
|
||||
lvIndex = barIndex;
|
||||
|
||||
//
|
||||
double lastHP = 0;
|
||||
double lastLV = 0;
|
||||
|
||||
//
|
||||
int hpCount = ArraySize(hpIndexes);
|
||||
int lvCount = ArraySize(lvIndexes);
|
||||
|
||||
//
|
||||
if (IsValidSize(hpCount))
|
||||
{
|
||||
//
|
||||
lastHP = hpValues[hpCount - 1];
|
||||
hpIndex = hpIndexes[hpCount - 1];
|
||||
}
|
||||
|
||||
//
|
||||
if (IsValidSize(lvCount))
|
||||
{
|
||||
//
|
||||
lastLV = lvValues[lvCount - 1];
|
||||
lvIndex = lvIndexes[lvCount - 1];
|
||||
}
|
||||
|
||||
//
|
||||
if (lastHP == 0)
|
||||
{
|
||||
//
|
||||
lastHP = mX121Helper
|
||||
.xpvHelper
|
||||
.GetPeak(hpIndex);
|
||||
}
|
||||
|
||||
//
|
||||
if (lastLV == 0)
|
||||
{
|
||||
//
|
||||
lastLV = mX121Helper
|
||||
.xpvHelper
|
||||
.GetVale(lvIndex);
|
||||
}
|
||||
|
||||
//
|
||||
int highestPeakIndex = -1;
|
||||
double highesrPeak =
|
||||
mX121Helper
|
||||
.xpvHelper
|
||||
.GetHigherPeak(
|
||||
highestPeakIndex,
|
||||
lastHP,
|
||||
hpIndex //
|
||||
);
|
||||
if (IsValidIndex(highestPeakIndex))
|
||||
{
|
||||
//
|
||||
Add(
|
||||
highestPeakIndex,
|
||||
hpIndexes //
|
||||
);
|
||||
|
||||
//
|
||||
Add(
|
||||
highesrPeak,
|
||||
hpValues //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
int lowestValeIndex = -1;
|
||||
double lowestVale =
|
||||
mX121Helper
|
||||
.xpvHelper
|
||||
.GetLowerVale(
|
||||
lowestValeIndex,
|
||||
lastLV,
|
||||
lvIndex //
|
||||
);
|
||||
if (IsValidIndex(lowestValeIndex))
|
||||
{
|
||||
//
|
||||
Add(
|
||||
lowestValeIndex,
|
||||
lvIndexes //
|
||||
);
|
||||
|
||||
//
|
||||
Add(
|
||||
lowestVale,
|
||||
lvValues //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
bool canBreak = ArraySize(hpIndexes) >= pivotsCount ||
|
||||
ArraySize(lvIndexes) >= pivotsCount;
|
||||
if (canBreak)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
ArrayReverse(hpValues);
|
||||
ArrayReverse(hpIndexes);
|
||||
int countHPs = ArraySize(hpIndexes);
|
||||
|
||||
//
|
||||
ArrayReverse(lvValues);
|
||||
ArrayReverse(lvIndexes);
|
||||
int countLVs = ArraySize(lvIndexes);
|
||||
|
||||
//
|
||||
bool isValidHPs = countHPs >= pivotsCount;
|
||||
bool isValidLVs = countLVs >= pivotsCount;
|
||||
|
||||
//
|
||||
result = isValidHPs ||
|
||||
isValidLVs;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
if (isValidHPs && isValidLVs)
|
||||
{
|
||||
//
|
||||
hpIndex = hpIndexes[countHPs - 1];
|
||||
lvIndex = lvIndexes[countLVs - 1];
|
||||
}
|
||||
|
||||
//
|
||||
dir =
|
||||
!isValidHPs && isValidLVs
|
||||
? X_DIRECTION_BULLISH
|
||||
: !isValidLVs && isValidHPs
|
||||
? X_DIRECTION_BEARISH
|
||||
: hpIndex < lvIndex
|
||||
? X_DIRECTION_BEARISH
|
||||
: lvIndex < hpIndex
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_ALL;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ const string X121SMCStrategyToken = "X121SMC";
|
||||
const string X121SMCXTestToken = "X121XTest";
|
||||
const string X121SMCXOBGPVToken = "X121XOBGPV";
|
||||
const string X121SMCXOBSPVToken = "X121XOBSPV";
|
||||
const string X121SMCXSTRPVToken = "X121XSTRPV";
|
||||
|
||||
//
|
||||
// X121 SMC Providers ...
|
||||
@@ -48,6 +49,7 @@ enum ENUM_X_121_SMC_PROVIDERS
|
||||
X_121_SMC_PROVIDER_XTEST,
|
||||
X_121_SMC_PROVIDER_XOBGPV,
|
||||
X_121_SMC_PROVIDER_XOBSPV,
|
||||
X_121_SMC_PROVIDER_XSTRPV,
|
||||
};
|
||||
|
||||
//
|
||||
@@ -684,6 +686,11 @@ string ToString(ENUM_X_121_SMC_PROVIDERS value)
|
||||
case X_121_SMC_PROVIDER_XOBSPV:
|
||||
result = X121SMCXOBSPVToken;
|
||||
break;
|
||||
|
||||
//
|
||||
case X_121_SMC_PROVIDER_XSTRPV:
|
||||
result = X121SMCXSTRPVToken;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -721,6 +728,10 @@ ENUM_X_121_SMC_PROVIDERS ParseProvider(string value)
|
||||
{
|
||||
result = X_121_SMC_PROVIDER_XOBSPV;
|
||||
}
|
||||
else if (Contains(X121SMCXSTRPVToken, value))
|
||||
{
|
||||
result = X_121_SMC_PROVIDER_XSTRPV;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
|
||||
@@ -816,7 +816,11 @@ bool DetectX121SMCXOBGPVSiganlTrigger(
|
||||
if (isBullish)
|
||||
{
|
||||
//
|
||||
double lowerVale = triggerCycleHelper.mX121Helper.xpvHelper.GetLowerVale(vale);
|
||||
int idx = -1;
|
||||
double lowerVale = triggerCycleHelper.mX121Helper.xpvHelper.GetLowerVale(
|
||||
idx,
|
||||
vale //
|
||||
);
|
||||
if (lowerVale > 0)
|
||||
{
|
||||
//
|
||||
@@ -835,7 +839,11 @@ bool DetectX121SMCXOBGPVSiganlTrigger(
|
||||
else if (isBearish)
|
||||
{
|
||||
//
|
||||
double higherPeak = triggerCycleHelper.mX121Helper.xpvHelper.GetHigherPeak(peak);
|
||||
int idx = -1;
|
||||
double higherPeak = triggerCycleHelper.mX121Helper.xpvHelper.GetHigherPeak(
|
||||
idx,
|
||||
peak //
|
||||
);
|
||||
if (higherPeak > 0)
|
||||
{
|
||||
//
|
||||
|
||||
@@ -881,6 +881,7 @@ bool DetectX121SMCXOBSPVSiganlTrigger(
|
||||
isBullish =
|
||||
//
|
||||
isBullish &&
|
||||
cBar.IsBullish() &&
|
||||
isDecisionLastBearishStrBreakedUp
|
||||
//
|
||||
;
|
||||
@@ -890,6 +891,7 @@ bool DetectX121SMCXOBSPVSiganlTrigger(
|
||||
isBearish =
|
||||
//
|
||||
isBearish &&
|
||||
cBar.IsBearish() &&
|
||||
isDecisionLastBullishStrBreakedDown
|
||||
//
|
||||
;
|
||||
@@ -953,15 +955,19 @@ bool DetectX121SMCXOBSPVSiganlTrigger(
|
||||
double sls[];
|
||||
|
||||
//
|
||||
double iAtr = triggerConditions.x121Conditions.atrBuffer[1];
|
||||
double iPeak = triggerConditions.x121Conditions.peaksBuffer[1];
|
||||
double iVale = triggerConditions.x121Conditions.valesBuffer[1];
|
||||
double iAtr = decisionConditions.x121Conditions.atrBuffer[1];
|
||||
double iPeak = decisionConditions.x121Conditions.peaksBuffer[1];
|
||||
double iVale = decisionConditions.x121Conditions.valesBuffer[1];
|
||||
|
||||
//
|
||||
if (isBullish)
|
||||
{
|
||||
//
|
||||
double lowerVale = triggerCycleHelper.mX121Helper.xpvHelper.GetLowerVale(iVale);
|
||||
int lowerValeIDX = -1;
|
||||
double lowerVale = triggerCycleHelper.mX121Helper.xpvHelper.GetLowerVale(
|
||||
lowerValeIDX,
|
||||
iVale //
|
||||
);
|
||||
if (lowerVale > 0)
|
||||
{
|
||||
//
|
||||
@@ -980,7 +986,11 @@ bool DetectX121SMCXOBSPVSiganlTrigger(
|
||||
else if (isBearish)
|
||||
{
|
||||
//
|
||||
double higherPeak = triggerCycleHelper.mX121Helper.xpvHelper.GetHigherPeak(iPeak);
|
||||
int higherPeakIDX = -1;
|
||||
double higherPeak = triggerCycleHelper.mX121Helper.xpvHelper.GetHigherPeak(
|
||||
higherPeakIDX,
|
||||
iPeak //
|
||||
);
|
||||
if (higherPeak > 0)
|
||||
{
|
||||
//
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -30,6 +30,7 @@
|
||||
#include "../Signals/x-121.smc.test.signal.lib.mq5"
|
||||
#include "../Signals/x-121.smc.xobgpv.signal.lib.mq5"
|
||||
#include "../Signals/x-121.smc.xobspv.signal.lib.mq5"
|
||||
#include "../Signals/x-121.smc.xstrpv.signal.lib.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
@@ -185,13 +186,15 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
|
||||
//
|
||||
bool useTestSignal = false;
|
||||
bool useXOBGPVSignal = true;
|
||||
bool useXOBSPVSignal = true;
|
||||
bool useXOBGPVSignal = false;
|
||||
bool useXOBSPVSignal = false;
|
||||
bool useXSTRPVSignal = true;
|
||||
|
||||
//
|
||||
bool hasTestSignal = false;
|
||||
bool hasXOBGPVSignal = false;
|
||||
bool hasXOBSPVSignal = false;
|
||||
bool hasXSTRPVSignal = false;
|
||||
|
||||
//
|
||||
// Test Signal ...
|
||||
@@ -220,6 +223,15 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
hasSignal = hasXOBSPVSignal;
|
||||
}
|
||||
|
||||
//
|
||||
// XSTRPV Signal ...
|
||||
if (useXSTRPVSignal && !hasSignal)
|
||||
{
|
||||
//
|
||||
hasXSTRPVSignal = DetectXSTRPVSignal(conditions);
|
||||
hasSignal = hasXSTRPVSignal;
|
||||
}
|
||||
|
||||
//
|
||||
result = hasSignal;
|
||||
if (!result)
|
||||
@@ -325,6 +337,18 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
// Configure Signal Protector ...
|
||||
if (useXSTRPVSignal)
|
||||
{
|
||||
//
|
||||
signal.trailSL = false;
|
||||
signal.fullTPLevel = r2r;
|
||||
signal.partialCloseOnTPLevel = 2;
|
||||
signal.partialCloseMultiplier = 0.5;
|
||||
signal.trailSLStartOnReachTPLevel = 2;
|
||||
}
|
||||
|
||||
//
|
||||
// TODO: Remove this ...
|
||||
// XCSignalObject *iObj;
|
||||
@@ -964,6 +988,224 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XSTRPV Signal ...
|
||||
bool DetectXSTRPVSignal(
|
||||
X121SMCStrategyConditions &conditions //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
bool isBullish = false;
|
||||
bool isBearish = false;
|
||||
|
||||
//
|
||||
int zIndex = 0;
|
||||
int cIndex = zIndex + 1;
|
||||
int pIndex = cIndex + 1;
|
||||
int ppIndex = pIndex + 1;
|
||||
|
||||
//
|
||||
string symbol = GetSymbol();
|
||||
ENUM_TIMEFRAMES period = GetPeriod();
|
||||
|
||||
//
|
||||
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 cLL = cBar.FindLowest(7, MODE_LOW);
|
||||
double cHH = cBar.FindHighest(7, MODE_HIGH);
|
||||
|
||||
//
|
||||
datetime cTime = TimeCurrent();
|
||||
|
||||
//
|
||||
ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_XSTRPV;
|
||||
string providerStr = ToString(provider);
|
||||
|
||||
//
|
||||
// Detect Setup Conditions ...
|
||||
datetime setupTime = mXSTRPVConditions.setupTime;
|
||||
bool isSetuped = mXSTRPVConditions.IsSetuped();
|
||||
ENUM_X_DIRECTION setupDir = mXSTRPVConditions.dir;
|
||||
if (!isSetuped)
|
||||
{
|
||||
//
|
||||
// Detect Signal Setup ...
|
||||
isSetuped = DetectX121SMCXSTRPVSiganlSetup(
|
||||
symbol,
|
||||
period,
|
||||
mXSTRPVConditions,
|
||||
mTriggerCycleHelper,
|
||||
mDecisionCycleHelper,
|
||||
mAnalyseCycleHelper,
|
||||
mVerificationCycleHelper,
|
||||
mConsolidationCycleHelper,
|
||||
mVisionCycleHelper //
|
||||
);
|
||||
|
||||
//
|
||||
setupDir = mXSTRPVConditions.dir;
|
||||
setupTime = mXSTRPVConditions.setupTime;
|
||||
|
||||
//
|
||||
if (isSetuped)
|
||||
{
|
||||
//
|
||||
int items = AddX121SMCXSTRPVConditionsIfNotExists(
|
||||
mXSTRPVConditions,
|
||||
mXSTRPVConditionsCollection //
|
||||
);
|
||||
|
||||
//
|
||||
mXSTRPVConditions.Clean();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
int conditionsCount = ArraySize(mXSTRPVConditionsCollection);
|
||||
result = IsValidSize(conditionsCount);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Looking For Conditions ...
|
||||
int selectedIndex = 0;
|
||||
X121SMCStrategyXSTRPVSignalConditions mTmpConditions[];
|
||||
Copy(
|
||||
mXSTRPVConditionsCollection,
|
||||
mTmpConditions //
|
||||
);
|
||||
X121SMCStrategyXSTRPVSignalConditions mConditions;
|
||||
for (int i = 0; i < conditionsCount; i++)
|
||||
{
|
||||
//
|
||||
// Check Triggers ...
|
||||
bool canTrigger = mTmpConditions[i].CanTrigger();
|
||||
datetime triggerTime = mTmpConditions[i].triggerTime;
|
||||
if (!canTrigger)
|
||||
{
|
||||
//
|
||||
// Detect Signal Trigger ...
|
||||
canTrigger = DetectX121SMCXSTRPVSiganlTrigger(
|
||||
mTmpConditions[i],
|
||||
symbol,
|
||||
period,
|
||||
mTriggerCycleHelper,
|
||||
mDecisionCycleHelper,
|
||||
mAnalyseCycleHelper,
|
||||
mVerificationCycleHelper,
|
||||
mConsolidationCycleHelper,
|
||||
mVisionCycleHelper //
|
||||
);
|
||||
|
||||
//
|
||||
result = canTrigger;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bool isISetuped = mTmpConditions[i].IsSetuped();
|
||||
if (!isISetuped)
|
||||
{
|
||||
//
|
||||
ArrayRemove(
|
||||
mXSTRPVConditionsCollection,
|
||||
i,
|
||||
1 //
|
||||
);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
triggerTime = mTmpConditions[i].triggerTime;
|
||||
}
|
||||
|
||||
//
|
||||
if (canTrigger)
|
||||
{
|
||||
//
|
||||
selectedIndex = i;
|
||||
mConditions = mTmpConditions[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = IsValid(mConditions.setupTime) &&
|
||||
HasDirection(mConditions.dir);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Remove Selected Index from Main Collection ...
|
||||
ArrayRemove(
|
||||
mXSTRPVConditionsCollection,
|
||||
selectedIndex,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
// Check Signal Direction ...
|
||||
isBullish = IsBullish(mConditions.dir);
|
||||
isBearish = IsBearish(mConditions.dir);
|
||||
result = isBullish ||
|
||||
isBearish;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Issues Signal on Conditions ...
|
||||
conditions.sl = mConditions.sl;
|
||||
conditions.provider = providerStr;
|
||||
conditions.signalDir = mConditions.dir;
|
||||
conditions.target = mConditions.target;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
@@ -1015,6 +1257,9 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
//
|
||||
x121Inputs.Default();
|
||||
|
||||
//
|
||||
bool showAll = false;
|
||||
|
||||
//
|
||||
x121Inputs.showRSI = false;
|
||||
|
||||
@@ -1035,33 +1280,40 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
x121Inputs.xpvInputs.hcPeriod = hcPeriod;
|
||||
|
||||
//
|
||||
x121Inputs.xpvInputs.showSar = true;
|
||||
x121Inputs.xpvInputs.showPeaks = true;
|
||||
x121Inputs.xpvInputs.showVales = true;
|
||||
x121Inputs.xpvInputs.showSar = showAll || true;
|
||||
x121Inputs.xpvInputs.showPeaks = showAll || true;
|
||||
x121Inputs.xpvInputs.showVales = showAll || true;
|
||||
|
||||
//
|
||||
// XATR ...
|
||||
x121Inputs.xatrInputs.showATRUpper = false;
|
||||
x121Inputs.xatrInputs.showATRLower = false;
|
||||
x121Inputs.xatrInputs.showATRUpper = showAll || false;
|
||||
x121Inputs.xatrInputs.showATRLower = showAll || false;
|
||||
|
||||
//
|
||||
// XSTR ...
|
||||
x121Inputs.xstrInputs.showStr = true;
|
||||
x121Inputs.xstrInputs.showStrUpper = false;
|
||||
x121Inputs.xstrInputs.showStrLower = false;
|
||||
x121Inputs.xstrInputs.showStr = showAll || true;
|
||||
x121Inputs.xstrInputs.showStrUpper = showAll || false;
|
||||
x121Inputs.xstrInputs.showStrLower = showAll || false;
|
||||
|
||||
//
|
||||
// XCHE ...
|
||||
x121Inputs.xcheInputs.showLE1 = showAll || true;
|
||||
x121Inputs.xcheInputs.showLE2 = showAll || true;
|
||||
x121Inputs.xcheInputs.showSE1 = showAll || true;
|
||||
x121Inputs.xcheInputs.showSE2 = showAll || true;
|
||||
|
||||
//
|
||||
// XDON ...
|
||||
x121Inputs.xdonInputs.showOpen = false;
|
||||
x121Inputs.xdonInputs.showClose = true;
|
||||
x121Inputs.xdonInputs.showLow = true;
|
||||
x121Inputs.xdonInputs.showHigh = true;
|
||||
x121Inputs.xdonInputs.showOpen = showAll || false;
|
||||
x121Inputs.xdonInputs.showClose = showAll || false;
|
||||
x121Inputs.xdonInputs.showLow = showAll || false;
|
||||
x121Inputs.xdonInputs.showHigh = showAll || false;
|
||||
|
||||
//
|
||||
// XVWAP ...
|
||||
x121Inputs.xvwapInputs.showVWapFast = false;
|
||||
x121Inputs.xvwapInputs.showVWapMedium = false;
|
||||
x121Inputs.xvwapInputs.showVWapSlow = false;
|
||||
x121Inputs.xvwapInputs.showVWapFast = showAll || false;
|
||||
x121Inputs.xvwapInputs.showVWapMedium = showAll || false;
|
||||
x121Inputs.xvwapInputs.showVWapSlow = showAll || false;
|
||||
|
||||
//
|
||||
// Initialize Cycle Helpers ...
|
||||
|
||||
Reference in New Issue
Block a user