last ...
This commit is contained in:
@@ -209,10 +209,11 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
||||
);
|
||||
|
||||
//
|
||||
double slAddition = 0;
|
||||
sl =
|
||||
hasLong
|
||||
? selectedSL - pip2
|
||||
: selectedSL + pip2;
|
||||
? selectedSL - slAddition
|
||||
: selectedSL + slAddition;
|
||||
|
||||
//
|
||||
// RISK Reward ...
|
||||
@@ -244,8 +245,8 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
Print("PRV: ", provider);
|
||||
DrawSignal(signal);
|
||||
// Print("PRV: ", provider);
|
||||
// DrawSignal(signal);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -505,6 +506,9 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
||||
double bid = GetBid(symbol);
|
||||
datetime cTime = TimeCurrent();
|
||||
|
||||
//
|
||||
double selectedSL = 0;
|
||||
|
||||
//
|
||||
// Here We Select Cycles For Conditions Check ...
|
||||
ENUM_X_CYCLES cycles[5] = {
|
||||
@@ -672,12 +676,17 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
||||
: X_DIRECTION_BEARISH;
|
||||
conditions.provider = providerStr;
|
||||
|
||||
//
|
||||
// Selectiong SL ...
|
||||
selectedSL = SelectSL(
|
||||
conditions,
|
||||
conditions.signalDir,
|
||||
X_121_SMC_SL_TYPE_SWING //
|
||||
);
|
||||
|
||||
//
|
||||
// Detect SL and TP ...
|
||||
conditions.sl =
|
||||
isBullish
|
||||
? pSarChangeBar.low
|
||||
: pSarChangeBar.high;
|
||||
conditions.sl = selectedSL;
|
||||
|
||||
//
|
||||
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