last ...
This commit is contained in:
@@ -151,6 +151,26 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
||||
mR2R = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Max Allowed Spread ...
|
||||
*
|
||||
* @return ( double )
|
||||
*/
|
||||
double MaxAllowedSpread()
|
||||
{
|
||||
return mMaxAllowedSpread;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Max Allowed Spread ...
|
||||
*
|
||||
* @param value: Double ...
|
||||
*/
|
||||
void MaxAllowedSpread(double value)
|
||||
{
|
||||
mMaxAllowedSpread = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Long Signalling State ...
|
||||
*
|
||||
@@ -318,7 +338,8 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
||||
//
|
||||
DrawSignal(
|
||||
signal,
|
||||
conditions);
|
||||
conditions //
|
||||
);
|
||||
|
||||
//
|
||||
// ClearDraws();
|
||||
@@ -479,19 +500,45 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
||||
|
||||
//
|
||||
// Loop through Conditions for Filter Based on POIs ...
|
||||
int removeIDX = -1;
|
||||
int conditionsIDX = -1;
|
||||
for (int i = 0; i < conditionsCount; i++)
|
||||
{
|
||||
//
|
||||
result = false;
|
||||
X121SMCStrategyConditions iConditions = mConditions[i];
|
||||
|
||||
//
|
||||
bool isSpreadPassed = IsSpreadPass();
|
||||
if (!isSpreadPassed)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Longs ...
|
||||
bool isAllowLong = AllowLong();
|
||||
if (isAllowLong)
|
||||
{
|
||||
//
|
||||
hasLong = false;
|
||||
|
||||
//
|
||||
if (hasLong)
|
||||
{
|
||||
//
|
||||
conditionsIDX = i;
|
||||
|
||||
//
|
||||
type = POSITION_TYPE_BUY;
|
||||
entry = GetEntry(mSymbol, type);
|
||||
sl = iConditions.demandZone.lower - (10 * points);
|
||||
risk = entry - sl;
|
||||
reward = risk * r2r;
|
||||
tp = entry + reward;
|
||||
|
||||
//
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -500,18 +547,41 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
||||
if (isAllowShort)
|
||||
{
|
||||
//
|
||||
hasShort = false;
|
||||
|
||||
//
|
||||
if (hasShort)
|
||||
{
|
||||
//
|
||||
conditionsIDX = i;
|
||||
|
||||
//
|
||||
type = POSITION_TYPE_SELL;
|
||||
entry = GetEntry(mSymbol, type);
|
||||
sl = iConditions.supplyZone.upper + (10 * points);
|
||||
risk = sl - entry;
|
||||
reward = risk * r2r;
|
||||
tp = entry - reward;
|
||||
|
||||
//
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = hasLong ||
|
||||
hasShort;
|
||||
|
||||
//
|
||||
// Rmove Signal Condition ...
|
||||
if (result &&
|
||||
IsValidIndex(removeIDX))
|
||||
IsValidIndex(conditionsIDX))
|
||||
{
|
||||
//
|
||||
ArrayRemove(
|
||||
mConditions,
|
||||
removeIDX,
|
||||
conditionsIDX,
|
||||
1 //
|
||||
);
|
||||
|
||||
@@ -530,6 +600,10 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
||||
|
||||
//
|
||||
result = PrepareSignal(signal);
|
||||
|
||||
//
|
||||
hasLong = false;
|
||||
hasShort = false;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -561,13 +635,14 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
||||
// Props ...
|
||||
|
||||
//
|
||||
string mSymbol; // Trading Symbol ...
|
||||
ENUM_TIMEFRAMES mPeriod; // Trading TimeFrame ...
|
||||
bool mForceDisabled; // Force Disabled ...
|
||||
bool mAllowLong; // Allow Long Signals
|
||||
bool mAllowShort; // Allow Short Signals
|
||||
double mR2R; // Risk/Rewar Ratio ...
|
||||
double mVolume; // Static Volume Per Trades ...
|
||||
string mSymbol; // Trading Symbol ...
|
||||
ENUM_TIMEFRAMES mPeriod; // Trading TimeFrame ...
|
||||
bool mForceDisabled; // Force Disabled ...
|
||||
bool mAllowLong; // Allow Long Signals
|
||||
bool mAllowShort; // Allow Short Signals
|
||||
double mR2R; // Risk/Rewar Ratio ...
|
||||
double mVolume; // Static Volume Per Trades ...
|
||||
double mMaxAllowedSpread; // Max Allowed Spread ...
|
||||
|
||||
//
|
||||
XTick mTicks[]; // Hold Ticks Data ...
|
||||
@@ -634,6 +709,12 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
||||
|
||||
//
|
||||
int length = 5;
|
||||
double pointValue = GetPoints(mSymbol);
|
||||
double maxAllowedSpread = MaxAllowedSpread();
|
||||
if (maxAllowedSpread > 0)
|
||||
{
|
||||
maxAllowedSpread *= pointValue;
|
||||
}
|
||||
|
||||
//
|
||||
int ticksCount = ArraySize(mTicks);
|
||||
@@ -659,15 +740,21 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
||||
|
||||
//
|
||||
end -= 1;
|
||||
double spread = 0;
|
||||
double spreadAVG = 0;
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
spread += mTicks[i].spread;
|
||||
spreadAVG += mTicks[i].spread;
|
||||
}
|
||||
spread /= length;
|
||||
spreadAVG /= length;
|
||||
|
||||
//
|
||||
result = mTicks[ticksCount - 1].spread <= spread;
|
||||
double lastSpread = mTicks[ticksCount - 1].spread;
|
||||
|
||||
//
|
||||
result = lastSpread <= spreadAVG &&
|
||||
(maxAllowedSpread <= 0
|
||||
? true
|
||||
: lastSpread <= maxAllowedSpread);
|
||||
|
||||
//
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user