last works ...
This commit is contained in:
@@ -314,6 +314,14 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
||||
signal,
|
||||
conditions //
|
||||
);
|
||||
|
||||
//
|
||||
DrawSignal(
|
||||
signal,
|
||||
conditions);
|
||||
|
||||
//
|
||||
// ClearDraws();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -330,6 +338,9 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
||||
signal.Clean();
|
||||
conditions.Clean();
|
||||
|
||||
//
|
||||
int pushers = 0;
|
||||
|
||||
//
|
||||
double sl = 0;
|
||||
double tp = 0;
|
||||
@@ -472,138 +483,24 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
||||
for (int i = 0; i < conditionsCount; i++)
|
||||
{
|
||||
//
|
||||
result = false;
|
||||
X121SMCStrategyConditions iConditions = mConditions[i];
|
||||
|
||||
//
|
||||
// LONG ...
|
||||
|
||||
//
|
||||
bool isSoImportantLong =
|
||||
iConditions.demandZone.IsValid() &&
|
||||
iConditions.bullishFVG.IsValid() &&
|
||||
iConditions.bullishOrderBlock.IsValid();
|
||||
|
||||
//
|
||||
bool isImportantLong =
|
||||
iConditions.demandZone.IsValid() &&
|
||||
(iConditions.bullishFVG.IsValid() ||
|
||||
iConditions.bullishOrderBlock.IsValid());
|
||||
|
||||
//
|
||||
bool isRiskyLong =
|
||||
iConditions.demandZone.IsValid() &&
|
||||
(iConditions.bullishFVG.IsValid() ||
|
||||
iConditions.bullishOrderBlock.IsValid());
|
||||
|
||||
//
|
||||
bool hasLongConditions = isSoImportantLong ||
|
||||
isImportantLong ||
|
||||
isRiskyLong;
|
||||
|
||||
//
|
||||
if (hasLongConditions)
|
||||
// Longs ...
|
||||
bool isAllowLong = AllowLong();
|
||||
if (isAllowLong)
|
||||
{
|
||||
//
|
||||
// Find Trigger for Input Positions ...
|
||||
// - [] Breakout;
|
||||
// - [] Engulf;
|
||||
// - [] Rejection Bar;
|
||||
// - [] Momentum Bar;
|
||||
|
||||
//
|
||||
// Price Must Breakout the Upper of Demand ...
|
||||
bool isBreakout =
|
||||
//
|
||||
cBar.IsBullish() &&
|
||||
zBar.low > conditions.demandZone.upper &&
|
||||
cBar.high > conditions.demandZone.upper &&
|
||||
cBar.close > conditions.demandZone.upper &&
|
||||
(cBar.open < conditions.demandZone.upper ||
|
||||
cBar.low < conditions.demandZone.upper)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Price Must have Bullish Trend and Momentum on Ticks ...
|
||||
bool isTicksBullishMomentum =
|
||||
IsTicksBullish() &&
|
||||
IsTicksHasMomentum();
|
||||
|
||||
//
|
||||
bool hasMpmentumBar =
|
||||
//
|
||||
cBar.
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
hasLongConditions =
|
||||
hasLongConditions &&
|
||||
//
|
||||
isBreakout &&
|
||||
isTicksBullishMomentum
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
if (hasLongConditions)
|
||||
{
|
||||
//
|
||||
removeIDX = i;
|
||||
conditions = iConditions;
|
||||
DrawConditions(iConditions);
|
||||
Print("hasLongConditions");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// SHORT ...
|
||||
|
||||
//
|
||||
bool isSoImportantShort =
|
||||
iConditions.supplyZone.IsValid() &&
|
||||
iConditions.bearishFVG.IsValid() &&
|
||||
iConditions.bearishOrderBlock.IsValid();
|
||||
|
||||
//
|
||||
bool isImportantShort =
|
||||
iConditions.supplyZone.IsValid() &&
|
||||
(iConditions.bearishFVG.IsValid() ||
|
||||
iConditions.bearishOrderBlock.IsValid());
|
||||
|
||||
//
|
||||
bool isRiskyShort =
|
||||
iConditions.supplyZone.IsValid() &&
|
||||
(!iConditions.bearishFVG.IsValid() &&
|
||||
!iConditions.bearishOrderBlock.IsValid());
|
||||
|
||||
//
|
||||
bool hasShortConditions = isSoImportantShort ||
|
||||
isImportantShort ||
|
||||
isRiskyShort;
|
||||
|
||||
//
|
||||
if (hasShortConditions)
|
||||
// Shorts ...
|
||||
bool isAllowShort = AllowShort();
|
||||
if (isAllowShort)
|
||||
{
|
||||
//
|
||||
// Find Trigger for Input Positions ...
|
||||
// - [] Breakout;
|
||||
// - [] Engulf;
|
||||
// - [] Rejection Bar;
|
||||
// - [] Momentum Bar;
|
||||
|
||||
//
|
||||
|
||||
//
|
||||
removeIDX = i;
|
||||
conditions = iConditions;
|
||||
DrawConditions(iConditions);
|
||||
Print("hasShortConditions");
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
@@ -617,6 +514,22 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
||||
removeIDX,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
signal.sl = sl;
|
||||
signal.tp = tp;
|
||||
signal.type = type;
|
||||
signal.mode = mode;
|
||||
signal.entry = entry;
|
||||
signal.volume = volume;
|
||||
signal.symbol = mSymbol;
|
||||
signal.pushers = pushers;
|
||||
signal.provider = GetTag();
|
||||
signal.time = TimeCurrent();
|
||||
signal.period = _5MState.period;
|
||||
|
||||
//
|
||||
result = PrepareSignal(signal);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -694,19 +607,9 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
||||
*/
|
||||
void SaveTickData()
|
||||
{
|
||||
//
|
||||
datetime time = TimeCurrent();
|
||||
double ask = GetAsk(mSymbol);
|
||||
double bid = GetBid(mSymbol);
|
||||
|
||||
//
|
||||
XTick tick;
|
||||
bool isInited = tick.Init(
|
||||
mSymbol,
|
||||
time,
|
||||
bid,
|
||||
ask //
|
||||
);
|
||||
bool isInited = tick.Init(mSymbol);
|
||||
if (!isInited)
|
||||
{
|
||||
return;
|
||||
@@ -719,6 +622,57 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Spread Passed for Positions...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsSpreadPass()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
int length = 5;
|
||||
|
||||
//
|
||||
int ticksCount = ArraySize(mTicks);
|
||||
if (ticksCount <= length)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int start = -1;
|
||||
int end = -1;
|
||||
CalculateTicksParams(
|
||||
start,
|
||||
end,
|
||||
length + 1 //
|
||||
);
|
||||
result = IsValidIndex(start) &&
|
||||
IsValidIndex(end);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
end -= 1;
|
||||
double spread = 0;
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
spread += mTicks[i].spread;
|
||||
}
|
||||
spread /= length;
|
||||
|
||||
//
|
||||
result = mTicks[ticksCount - 1].spread <= spread;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate Ticks Param for Looping through Last n items ...
|
||||
*
|
||||
@@ -907,6 +861,14 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
||||
// Collect all Drawn Objects ...
|
||||
CArrayObj mDrawnObjects;
|
||||
|
||||
/**
|
||||
* Clear all Drawn Objects ...
|
||||
*/
|
||||
void ClearDraws()
|
||||
{
|
||||
mDrawnObjects.Clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove Specified Drawn Object ...
|
||||
*
|
||||
@@ -933,7 +895,11 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
||||
{
|
||||
//
|
||||
string iName = ((CChartObject *)mDrawnObjects.At(i)).Name();
|
||||
string iObjName = ((XCBaseObject *)mDrawnObjects.At(i)).ObjName();
|
||||
string iObjName = NULL;
|
||||
if (!IsValid(iName))
|
||||
{
|
||||
iObjName = ((XCBaseObject *)mDrawnObjects.At(i)).ObjName();
|
||||
}
|
||||
|
||||
//
|
||||
if ((IsValid(iName) &&
|
||||
@@ -989,6 +955,10 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
||||
//
|
||||
mForceDisabled = false;
|
||||
|
||||
//
|
||||
R2R(2);
|
||||
Volume(0.01);
|
||||
|
||||
//
|
||||
string symbol = Symbol();
|
||||
ENUM_TIMEFRAMES period = Period();
|
||||
@@ -1092,6 +1062,9 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
||||
delete m5MPOI;
|
||||
delete m15MPOI;
|
||||
// delete m4HSupDemPOI;
|
||||
|
||||
//
|
||||
ClearDraws();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1729,26 +1702,10 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
||||
//
|
||||
string name = zone.GetTag();
|
||||
RemoveObject(name);
|
||||
// int idx = FindIndex(zone, mSupplyZones);
|
||||
// if (IsValidIndex(idx))
|
||||
// {
|
||||
// // //
|
||||
// // ArrayRemove(
|
||||
// // mSupplyZones,
|
||||
// // idx,
|
||||
// // 1 //
|
||||
// // );
|
||||
|
||||
// //
|
||||
// }
|
||||
|
||||
//
|
||||
zone.to = TimeCurrent();
|
||||
name = zone.GetTag();
|
||||
// AddRef(
|
||||
// zone,
|
||||
// mSupplyZones //
|
||||
// );
|
||||
|
||||
//
|
||||
XCSupplyZoneObject *iObj;
|
||||
@@ -1791,26 +1748,10 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
||||
//
|
||||
string name = zone.GetTag();
|
||||
RemoveObject(name);
|
||||
// int idx = FindIndex(zone, mDemandZones);
|
||||
// if (IsValidIndex(idx))
|
||||
// {
|
||||
// // //
|
||||
// // ArrayRemove(
|
||||
// // mDemandZones,
|
||||
// // idx,
|
||||
// // 1 //
|
||||
// // );
|
||||
|
||||
// //
|
||||
// }
|
||||
|
||||
//
|
||||
zone.to = TimeCurrent();
|
||||
name = zone.GetTag();
|
||||
// AddRef(
|
||||
// zone,
|
||||
// mDemandZones //
|
||||
// );
|
||||
|
||||
//
|
||||
XCDemandZoneObject *iObj;
|
||||
@@ -1853,26 +1794,10 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
||||
//
|
||||
string name = zone.GetTag();
|
||||
RemoveObject(name);
|
||||
// int idx = FindIndex(zone, mBearishOrderBlocks);
|
||||
// if (IsValidIndex(idx))
|
||||
// {
|
||||
// // //
|
||||
// // ArrayRemove(
|
||||
// // mBearishOrderBlocks,
|
||||
// // idx,
|
||||
// // 1 //
|
||||
// // );
|
||||
|
||||
// //
|
||||
// }
|
||||
|
||||
//
|
||||
zone.to = TimeCurrent();
|
||||
name = zone.GetTag();
|
||||
// AddRef(
|
||||
// zone,
|
||||
// mBearishOrderBlocks //
|
||||
// );
|
||||
|
||||
//
|
||||
XCBearishOrderBlockObject *iObj;
|
||||
@@ -1915,26 +1840,10 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
||||
//
|
||||
string name = zone.GetTag();
|
||||
RemoveObject(name);
|
||||
// int idx = FindIndex(zone, mBullishOrderBlocks);
|
||||
// if (IsValidIndex(idx))
|
||||
// {
|
||||
// // //
|
||||
// // ArrayRemove(
|
||||
// // mBullishOrderBlocks,
|
||||
// // idx,
|
||||
// // 1 //
|
||||
// // );
|
||||
|
||||
// //
|
||||
// }
|
||||
|
||||
//
|
||||
zone.to = TimeCurrent();
|
||||
name = zone.GetTag();
|
||||
// AddRef(
|
||||
// zone,
|
||||
// mBullishOrderBlocks //
|
||||
// );
|
||||
|
||||
//
|
||||
XCBullishOrderBlockObject *iObj;
|
||||
@@ -1977,26 +1886,10 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
||||
//
|
||||
string name = zone.GetTag();
|
||||
RemoveObject(name);
|
||||
// int idx = FindIndex(zone, mBearishFVGs);
|
||||
// if (IsValidIndex(idx))
|
||||
// {
|
||||
// //
|
||||
// // ArrayRemove(
|
||||
// // mBearishFVGs,
|
||||
// // idx,
|
||||
// // 1 //
|
||||
// // );
|
||||
|
||||
// //
|
||||
// }
|
||||
|
||||
//
|
||||
zone.to = TimeCurrent();
|
||||
name = zone.GetTag();
|
||||
// AddRef(
|
||||
// zone,
|
||||
// mBearishFVGs //
|
||||
// );
|
||||
|
||||
//
|
||||
XCBearishFVGObject *iObj;
|
||||
@@ -2039,26 +1932,10 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
||||
//
|
||||
string name = zone.GetTag();
|
||||
RemoveObject(name);
|
||||
// int idx = FindIndex(zone, mBullishFVGs);
|
||||
// if (IsValidIndex(idx))
|
||||
// {
|
||||
// // //
|
||||
// // ArrayRemove(
|
||||
// // mBullishFVGs,
|
||||
// // idx,
|
||||
// // 1 //
|
||||
// // );
|
||||
|
||||
// //
|
||||
// }
|
||||
|
||||
//
|
||||
zone.to = TimeCurrent();
|
||||
name = zone.GetTag();
|
||||
// AddRef(
|
||||
// zone,
|
||||
// mBullishFVGs //
|
||||
// );
|
||||
|
||||
//
|
||||
XCBullishFVGObject *iObj;
|
||||
@@ -2085,6 +1962,199 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
||||
mDrawnObjects.Add(iObj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw Specified Swing Bars ...
|
||||
*
|
||||
* @param bar: XOHLC instance ...
|
||||
* @param isLow: Boolean ...
|
||||
*/
|
||||
void DrawSwingBar(
|
||||
XOHCL &bar,
|
||||
bool isLow //
|
||||
)
|
||||
{
|
||||
//
|
||||
if (!bar.IsValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
string tagPref =
|
||||
isLow
|
||||
? ToString(X_POI_SWING_LOW)
|
||||
: ToString(X_POI_SWING_HIGH);
|
||||
string name = bar.GetTag(tagPref);
|
||||
RemoveObject(name);
|
||||
|
||||
//
|
||||
double price =
|
||||
isLow
|
||||
? bar.low
|
||||
: bar.high;
|
||||
char arrowCode =
|
||||
isLow
|
||||
? (char)188
|
||||
: (char)108;
|
||||
color clr =
|
||||
isLow
|
||||
? clrAqua
|
||||
: clrMagenta;
|
||||
ENUM_ARROW_ANCHOR anchor =
|
||||
isLow
|
||||
? ANCHOR_TOP
|
||||
: ANCHOR_BOTTOM;
|
||||
|
||||
//
|
||||
CChartObjectArrow *iObj;
|
||||
iObj = new CChartObjectArrow();
|
||||
bool isCreated = iObj.Create(
|
||||
ChartID(),
|
||||
name,
|
||||
0,
|
||||
bar.time,
|
||||
price,
|
||||
arrowCode //
|
||||
);
|
||||
if (!isCreated)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Configure Object ...
|
||||
iObj.Width(1);
|
||||
iObj.Color(clr);
|
||||
iObj.Anchor(anchor);
|
||||
|
||||
//
|
||||
mDrawnObjects.Add(iObj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw Momentum Bar ...
|
||||
*
|
||||
* @param bar: XOHCL instance ...
|
||||
*/
|
||||
void DrawMomentumBar(XOHCL &bar)
|
||||
{
|
||||
//
|
||||
if (!bar.IsValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
bool isBullish = bar.IsBullish();
|
||||
string name = bar.GetTag(ToString(X_POI_MOMENTUM_BAR));
|
||||
RemoveObject(name);
|
||||
|
||||
//
|
||||
double price =
|
||||
isBullish
|
||||
? bar.low
|
||||
: bar.high;
|
||||
char arrowCode =
|
||||
isBullish
|
||||
? (char)225
|
||||
: (char)226;
|
||||
color clr =
|
||||
isBullish
|
||||
? clrAqua
|
||||
: clrMagenta;
|
||||
ENUM_ARROW_ANCHOR anchor =
|
||||
isBullish
|
||||
? ANCHOR_TOP
|
||||
: ANCHOR_BOTTOM;
|
||||
|
||||
//
|
||||
CChartObjectArrow *iObj;
|
||||
iObj = new CChartObjectArrow();
|
||||
bool isCreated = iObj.Create(
|
||||
ChartID(),
|
||||
name,
|
||||
0,
|
||||
bar.time,
|
||||
price,
|
||||
arrowCode //
|
||||
);
|
||||
if (!isCreated)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Configure Object ...
|
||||
iObj.Width(1);
|
||||
iObj.Color(clr);
|
||||
iObj.Anchor(anchor);
|
||||
|
||||
//
|
||||
mDrawnObjects.Add(iObj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw Bullish Rejection Bar ...
|
||||
*
|
||||
* @param bar: XOHCL instance ...
|
||||
*/
|
||||
void DrawRejectionBar(XOHCL &bar)
|
||||
{
|
||||
//
|
||||
if (!bar.IsValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
bool isBullish = bar.GetLowShadow() > bar.GetHighShadow();
|
||||
string name = bar.GetTag(ToString(X_POI_REJECTION_BAR));
|
||||
RemoveObject(name);
|
||||
|
||||
//
|
||||
double price =
|
||||
isBullish
|
||||
? bar.low
|
||||
: bar.high;
|
||||
char arrowCode =
|
||||
isBullish
|
||||
? (char)217
|
||||
: (char)218;
|
||||
color clr =
|
||||
isBullish
|
||||
? clrAqua
|
||||
: clrMagenta;
|
||||
ENUM_ARROW_ANCHOR anchor =
|
||||
isBullish
|
||||
? ANCHOR_TOP
|
||||
: ANCHOR_BOTTOM;
|
||||
|
||||
//
|
||||
CChartObjectArrow *iObj;
|
||||
iObj = new CChartObjectArrow();
|
||||
bool isCreated = iObj.Create(
|
||||
ChartID(),
|
||||
name,
|
||||
0,
|
||||
bar.time,
|
||||
price,
|
||||
arrowCode //
|
||||
);
|
||||
if (!isCreated)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Configure Object ...
|
||||
iObj.Width(1);
|
||||
iObj.Color(clr);
|
||||
iObj.Anchor(anchor);
|
||||
|
||||
//
|
||||
mDrawnObjects.Add(iObj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw Specific Condition ...
|
||||
*
|
||||
@@ -2129,6 +2199,67 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw Specified Signal ...
|
||||
*
|
||||
* @param signal: XSignal instance ...
|
||||
* @param conditions: X121SMCStrategyConditions instance ...
|
||||
*/
|
||||
void DrawSignal(
|
||||
XSignal &signal,
|
||||
X121SMCStrategyConditions &conditions //
|
||||
)
|
||||
{
|
||||
//
|
||||
if (!signal.IsValid() ||
|
||||
!conditions.IsValid())
|
||||
{
|
||||
//
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// DrawConditions(conditions);
|
||||
|
||||
//
|
||||
string name = signal.GetTag();
|
||||
RemoveObject(name);
|
||||
|
||||
//
|
||||
XCSignalObject *iObj;
|
||||
iObj = new XCSignalObject();
|
||||
|
||||
//
|
||||
bool isCreated = iObj.Create(
|
||||
ChartID(),
|
||||
name,
|
||||
0,
|
||||
signal //
|
||||
);
|
||||
if (!isCreated)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
iObj.TPWidth(1);
|
||||
iObj.TPColor(clrGreen);
|
||||
iObj.TPWidth(STYLE_DOT);
|
||||
|
||||
//
|
||||
iObj.SLWidth(1);
|
||||
iObj.SLColor(clrRed);
|
||||
iObj.SLWidth(STYLE_DOT);
|
||||
|
||||
//
|
||||
iObj.EntryWidth(1);
|
||||
iObj.EntryColor(clrYellow);
|
||||
iObj.EntryWidth(STYLE_DOT);
|
||||
|
||||
//
|
||||
mDrawnObjects.Add(iObj);
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user