last ...
This commit is contained in:
@@ -4171,6 +4171,109 @@ class XCX121Helper : public XCBaseHelper
|
|||||||
fl5Buffer
|
fl5Buffer
|
||||||
//
|
//
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// XDON ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// OPEN ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Upper ...
|
||||||
|
CopyBuffer(
|
||||||
|
mHandler,
|
||||||
|
X121_DON_OPEN_UPPER_LINE,
|
||||||
|
0,
|
||||||
|
totalBars,
|
||||||
|
donOpenUpperBuffer
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Lower ...
|
||||||
|
CopyBuffer(
|
||||||
|
mHandler,
|
||||||
|
X121_DON_OPEN_LOWER_LINE,
|
||||||
|
0,
|
||||||
|
totalBars,
|
||||||
|
donOpenLowerBuffer
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// CLOSE ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Upper ...
|
||||||
|
CopyBuffer(
|
||||||
|
mHandler,
|
||||||
|
X121_DON_CLOSE_UPPER_LINE,
|
||||||
|
0,
|
||||||
|
totalBars,
|
||||||
|
donCloseUpperBuffer
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Lower ...
|
||||||
|
CopyBuffer(
|
||||||
|
mHandler,
|
||||||
|
X121_DON_CLOSE_LOWER_LINE,
|
||||||
|
0,
|
||||||
|
totalBars,
|
||||||
|
donCloseLowerBuffer
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// HIGH ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Upper ...
|
||||||
|
CopyBuffer(
|
||||||
|
mHandler,
|
||||||
|
X121_DON_HIGH_UPPER_LINE,
|
||||||
|
0,
|
||||||
|
totalBars,
|
||||||
|
donHighUpperBuffer
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Lower ...
|
||||||
|
CopyBuffer(
|
||||||
|
mHandler,
|
||||||
|
X121_DON_HIGH_LOWER_LINE,
|
||||||
|
0,
|
||||||
|
totalBars,
|
||||||
|
donHighLowerBuffer
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// LOW ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Upper ...
|
||||||
|
CopyBuffer(
|
||||||
|
mHandler,
|
||||||
|
X121_DON_LOW_UPPER_LINE,
|
||||||
|
0,
|
||||||
|
totalBars,
|
||||||
|
donLowUpperBuffer
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Lower ...
|
||||||
|
CopyBuffer(
|
||||||
|
mHandler,
|
||||||
|
X121_DON_LOW_LOWER_LINE,
|
||||||
|
0,
|
||||||
|
totalBars,
|
||||||
|
donLowLowerBuffer
|
||||||
|
//
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1323,6 +1323,32 @@ class XCSwing : public XCBasePOI
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Swing Value ...
|
||||||
|
*
|
||||||
|
* @return ( double )
|
||||||
|
*/
|
||||||
|
double GetValue()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!IsValid())
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
IsSwingHigh()
|
||||||
|
? mBar.high
|
||||||
|
: mBar.low;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Overrides ...
|
// Overrides ...
|
||||||
|
|
||||||
@@ -4056,11 +4082,11 @@ struct XValueChange
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Fill Change Bar ...
|
* Fill Change Bar ...
|
||||||
*
|
*
|
||||||
* @param bar: XOHCL instance Reference, holds Change Bar ...
|
* @param bar: XOHCL instance Reference, holds Change Bar ...
|
||||||
* @param _symbol: String, Specified Symbol ...
|
* @param _symbol: String, Specified Symbol ...
|
||||||
* @param _period: ENUM_TIMEFRAMES _period member, Specified Period ...
|
* @param _period: ENUM_TIMEFRAMES _period member, Specified Period ...
|
||||||
*
|
*
|
||||||
* @return ( bool )
|
* @return ( bool )
|
||||||
*/
|
*/
|
||||||
bool FillBar(
|
bool FillBar(
|
||||||
|
|||||||
@@ -47,6 +47,26 @@ enum ENUM_X_121_SMC_PROVIDERS
|
|||||||
X_121_SMC_PROVIDER_VWAPC,
|
X_121_SMC_PROVIDER_VWAPC,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// X121 SL Method ...
|
||||||
|
enum ENUM_X_121_SMC_SL_TYPES
|
||||||
|
{
|
||||||
|
X_121_SMC_SL_TYPE_NONE,
|
||||||
|
X_121_SMC_SL_TYPE_LAST_SAR_CHANGED_BAR,
|
||||||
|
X_121_SMC_SL_TYPE_CURRENT_SAR_BOX,
|
||||||
|
X_121_SMC_SL_TYPE_LAST_DIRECTIONAL_SAR,
|
||||||
|
X_121_SMC_SL_TYPE_CURRENT_SAR,
|
||||||
|
X_121_SMC_SL_TYPE_DON_CLOSE_BOX,
|
||||||
|
X_121_SMC_SL_TYPE_FIBO_LEVEL_1_5,
|
||||||
|
X_121_SMC_SL_TYPE_FIBO_LEVEL_3,
|
||||||
|
X_121_SMC_SL_TYPE_VWAP_FAST,
|
||||||
|
X_121_SMC_SL_TYPE_VWAP_MID,
|
||||||
|
X_121_SMC_SL_TYPE_VWAP_SLOW,
|
||||||
|
X_121_SMC_SL_TYPE_SWING,
|
||||||
|
X_121_SMC_SL_TYPE_MOMENTUM,
|
||||||
|
X_121_SMC_SL_TYPE_REJECTION,
|
||||||
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// Pivot Types ...
|
// Pivot Types ...
|
||||||
enum ENUM_XPV_PIVOTS
|
enum ENUM_XPV_PIVOTS
|
||||||
|
|||||||
@@ -209,10 +209,11 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
|||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
double slAddition = 0;
|
||||||
sl =
|
sl =
|
||||||
hasLong
|
hasLong
|
||||||
? selectedSL - pip2
|
? selectedSL - slAddition
|
||||||
: selectedSL + pip2;
|
: selectedSL + slAddition;
|
||||||
|
|
||||||
//
|
//
|
||||||
// RISK Reward ...
|
// RISK Reward ...
|
||||||
@@ -244,8 +245,8 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
|||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
Print("PRV: ", provider);
|
// Print("PRV: ", provider);
|
||||||
DrawSignal(signal);
|
// DrawSignal(signal);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -505,6 +506,9 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
|||||||
double bid = GetBid(symbol);
|
double bid = GetBid(symbol);
|
||||||
datetime cTime = TimeCurrent();
|
datetime cTime = TimeCurrent();
|
||||||
|
|
||||||
|
//
|
||||||
|
double selectedSL = 0;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Here We Select Cycles For Conditions Check ...
|
// Here We Select Cycles For Conditions Check ...
|
||||||
ENUM_X_CYCLES cycles[5] = {
|
ENUM_X_CYCLES cycles[5] = {
|
||||||
@@ -672,12 +676,17 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
|||||||
: X_DIRECTION_BEARISH;
|
: X_DIRECTION_BEARISH;
|
||||||
conditions.provider = providerStr;
|
conditions.provider = providerStr;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Selectiong SL ...
|
||||||
|
selectedSL = SelectSL(
|
||||||
|
conditions,
|
||||||
|
conditions.signalDir,
|
||||||
|
X_121_SMC_SL_TYPE_SWING //
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Detect SL and TP ...
|
// Detect SL and TP ...
|
||||||
conditions.sl =
|
conditions.sl = selectedSL;
|
||||||
isBullish
|
|
||||||
? pSarChangeBar.low
|
|
||||||
: pSarChangeBar.high;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
@@ -1674,6 +1683,209 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// SL Selector Methods ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Select Specified Type of Stop Loss ...
|
||||||
|
*
|
||||||
|
* @param conditions: X121SMCStrategyConditions instance Reference ...
|
||||||
|
* @param forDir: ENUM_X_DIRECTION member, Signal Direction ...
|
||||||
|
* @param type: ENUM_X_121_SMC_SL_TYPES member, Specified Required SL Type ...
|
||||||
|
*
|
||||||
|
* @return ( double )
|
||||||
|
*/
|
||||||
|
double SelectSL(
|
||||||
|
X121SMCStrategyConditions &conditions,
|
||||||
|
ENUM_X_DIRECTION forDir,
|
||||||
|
ENUM_X_121_SMC_SL_TYPES type //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
string symbol = GetSymbol();
|
||||||
|
ENUM_TIMEFRAMES period = GetPeriod();
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isValid =
|
||||||
|
//
|
||||||
|
HasDirection(forDir) &&
|
||||||
|
conditions.IsValid() &&
|
||||||
|
type != X_121_SMC_SL_TYPE_NONE
|
||||||
|
//
|
||||||
|
;
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL zBar;
|
||||||
|
bool isInited = zBar.Init(
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
0 //
|
||||||
|
);
|
||||||
|
if (!isInited)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isBullish = IsBullish(forDir);
|
||||||
|
|
||||||
|
//
|
||||||
|
if (type == X_121_SMC_SL_TYPE_FIBO_LEVEL_3)
|
||||||
|
{
|
||||||
|
result = conditions.triggerConditions.x121Conditions.fl3Buffer[0];
|
||||||
|
}
|
||||||
|
else if (type == X_121_SMC_SL_TYPE_FIBO_LEVEL_1_5)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
isBullish
|
||||||
|
? conditions.triggerConditions.x121Conditions.fl1Buffer[0]
|
||||||
|
: conditions.triggerConditions.x121Conditions.fl5Buffer[0];
|
||||||
|
}
|
||||||
|
else if (type == X_121_SMC_SL_TYPE_DON_CLOSE_BOX)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
isBullish
|
||||||
|
? conditions.triggerConditions.x121Conditions.donCloseLowerBuffer[0]
|
||||||
|
: conditions.triggerConditions.x121Conditions.donCloseUpperBuffer[0];
|
||||||
|
}
|
||||||
|
else if (type == X_121_SMC_SL_TYPE_SWING)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int swingLowsCount = conditions.triggerConditions.state.CountSwingLows();
|
||||||
|
int swingHighsCount = conditions.triggerConditions.state.CountSwingHighs();
|
||||||
|
result =
|
||||||
|
isBullish
|
||||||
|
? conditions.triggerConditions.state.swingLows[swingLowsCount - 1].GetValue()
|
||||||
|
: conditions.triggerConditions.state.swingHighs[swingHighsCount - 1].GetValue();
|
||||||
|
}
|
||||||
|
else if (type == X_121_SMC_SL_TYPE_REJECTION)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
isBullish
|
||||||
|
? conditions.triggerConditions.state.bullishRejectionBars[conditions.triggerConditions.state.CountBullishRejectionBars() - 1].Lower()
|
||||||
|
: conditions.triggerConditions.state.bearishRejectionBars[conditions.triggerConditions.state.CountBearishRejectionBars() - 1].Upper();
|
||||||
|
}
|
||||||
|
else if (type == X_121_SMC_SL_TYPE_MOMENTUM)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
isBullish
|
||||||
|
? conditions.triggerConditions.state.bullishMomentumBars[conditions.triggerConditions.state.CountBullishMomentumBars() - 1].Lower()
|
||||||
|
: conditions.triggerConditions.state.bearishMomentumBars[conditions.triggerConditions.state.CountBearishMomentumBars() - 1].Upper();
|
||||||
|
}
|
||||||
|
else if (type == X_121_SMC_SL_TYPE_VWAP_FAST)
|
||||||
|
{
|
||||||
|
result = conditions.triggerConditions.x121Conditions.vwapFastBuffer[0];
|
||||||
|
}
|
||||||
|
else if (type == X_121_SMC_SL_TYPE_VWAP_MID)
|
||||||
|
{
|
||||||
|
result = conditions.triggerConditions.x121Conditions.vwapMidBuffer[0];
|
||||||
|
}
|
||||||
|
else if (type == X_121_SMC_SL_TYPE_VWAP_SLOW)
|
||||||
|
{
|
||||||
|
result = conditions.triggerConditions.x121Conditions.vwapSlowBuffer[0];
|
||||||
|
}
|
||||||
|
else if (type == X_121_SMC_SL_TYPE_CURRENT_SAR)
|
||||||
|
{
|
||||||
|
result = conditions.triggerConditions.x121Conditions.sarBuffer[0];
|
||||||
|
}
|
||||||
|
else if (type == X_121_SMC_SL_TYPE_CURRENT_SAR_BOX ||
|
||||||
|
type == X_121_SMC_SL_TYPE_LAST_SAR_CHANGED_BAR ||
|
||||||
|
type == X_121_SMC_SL_TYPE_LAST_DIRECTIONAL_SAR)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XOHCL cSarChangeBar;
|
||||||
|
XOHCL pSarChangeBar;
|
||||||
|
XValueChange cSarChange; // Current Sar Change (IsDirect) ...
|
||||||
|
XValueChange pSarChange; // Prev Sar Change (Direct) ...
|
||||||
|
XValueChange sarChanges[];
|
||||||
|
int sarChangesCount = mTriggerCycleHelper
|
||||||
|
.FillSarChanges(sarChanges);
|
||||||
|
if (!IsValidSize(sarChangesCount) || sarChangesCount < 2)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
cSarChange = sarChanges[sarChangesCount - 1];
|
||||||
|
pSarChange = sarChanges[sarChangesCount - 2];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isFilled = cSarChange.FillBar(
|
||||||
|
cSarChangeBar,
|
||||||
|
symbol,
|
||||||
|
period //
|
||||||
|
);
|
||||||
|
if (!isFilled)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
isFilled = pSarChange.FillBar(
|
||||||
|
pSarChangeBar,
|
||||||
|
symbol,
|
||||||
|
period //
|
||||||
|
);
|
||||||
|
if (!isFilled)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (type == X_121_SMC_SL_TYPE_LAST_SAR_CHANGED_BAR)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result = isBullish
|
||||||
|
? pSarChangeBar.low
|
||||||
|
: pSarChangeBar.high;
|
||||||
|
}
|
||||||
|
else if (type == X_121_SMC_SL_TYPE_CURRENT_SAR_BOX)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
isBullish
|
||||||
|
? zBar.FindLowest(
|
||||||
|
MathAbs(cSarChangeBar.Index() - 1),
|
||||||
|
MODE_LOW //
|
||||||
|
)
|
||||||
|
: zBar.FindHighest(
|
||||||
|
MathAbs(cSarChangeBar.Index() - 1),
|
||||||
|
MODE_HIGH //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (type == X_121_SMC_SL_TYPE_LAST_DIRECTIONAL_SAR)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XOHCL prevBar;
|
||||||
|
bool isInited = cSarChangeBar.GetPreviousBar(prevBar);
|
||||||
|
if (!isInited)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = isBullish
|
||||||
|
? prevBar.low
|
||||||
|
: prevBar.high;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user