This commit is contained in:
2025-09-29 02:40:14 +03:30
parent 0e2138a4a9
commit 57be148292
3 changed files with 207 additions and 83 deletions
+134 -29
View File
@@ -457,7 +457,7 @@ void OnTick()
fima2Signaller.OnTick(); fima2Signaller.OnTick();
// //
// AnalyseMarket(1); AnalyseMarket(1);
} }
// //
@@ -611,14 +611,24 @@ void OnSignalTriggered(XSignal &signal)
return; return;
} }
//
// TODO: Fix this ...
return;
// //
// Draw Signal on Chart ... // Draw Signal on Chart ...
// XCSignalObject *iSignalObj; XCSignalObject *iSignalObj;
// bool has = fima2Signaller.poiDrawer.DrawSignal( bool has = fima2Signaller.poiDrawer.DrawSignal(
// signal, signal,
// iSignalObj, iSignalObj,
// 7 // 7 //
// ); );
//
if (has)
{
Print("Signal Issued: ", signal.GetObjectID());
}
// //
// Try to Execute Signal ... // Try to Execute Signal ...
@@ -626,29 +636,29 @@ void OnSignalTriggered(XSignal &signal)
// //
// Draw Signal Vertical Line ... // Draw Signal Vertical Line ...
// // //
CChartObjectVLine *iObj = new CChartObjectVLine(); // CChartObjectVLine *iObj = new CChartObjectVLine();
// // //
string iName = signal.GetTag(); // string iName = signal.GetObjectID();
color iColor = IsLong(signal.type) ? clrLime : clrRed; // color iColor = IsLong(signal.type) ? clrLime : clrRed;
// // //
bool has = iObj.Create( // bool has = iObj.Create(
fima2Signaller.poiDrawer.ChartIdentification(), // fima2Signaller.poiDrawer.ChartIdentification(),
iName, // iName,
fima2Signaller.poiDrawer.SubWindowIdentification(), // fima2Signaller.poiDrawer.SubWindowIdentification(),
signal.time // // signal.time //
); // );
if (has) // if (has)
{ // {
// // //
iObj.Width(2); // iObj.Width(2);
iObj.Color(iColor); // iObj.Color(iColor);
// // //
// eaDraws.Add(iObj); // // eaDraws.Add(iObj);
} // }
// // // //
// // Alert Issued Signal ... // // Alert Issued Signal ...
@@ -913,7 +923,8 @@ void AnalyseMarket(int barIndex = 0)
); );
// //
// HandleSignalLookup(bar); // XFIMASIgballer2First(bar);
HandleLookupSignal(bar);
// //
bar.Clean(); bar.Clean();
@@ -922,7 +933,7 @@ void AnalyseMarket(int barIndex = 0)
// //
// Handle Signal Looking Up ... // Handle Signal Looking Up ...
// Register it as XFIMA Signaller 2 ... // Register it as XFIMA Signaller 2 ...
void HandleSignalLookup(XOHCL &bar) void XFIMASIgballer2First(XOHCL &bar)
{ {
// //
bool has = bool has =
@@ -1805,4 +1816,98 @@ void HandleSignalLookup(XOHCL &bar)
SpecifiedClean(resistances); SpecifiedClean(resistances);
} }
//
void HandleLookupSignal(XOHCL &bar)
{
//
bool has =
bar.IsValid();
if (!has)
{
return;
}
//
XBoxZone iZone;
XSignal iSignal;
string iName = NULL;
bool isBullish = false;
bool isBearish = false;
int barIndex = bar.Index();
double iPrice = EMPTY_VALUE;
XFIMAConditions fimaConditions;
ENUM_X_PRICE iPriceType = X_PRICE_NONE;
ENUM_X_DIRECTION iDir = X_DIRECTION_NONE;
//
int cIDX = 0;
int pIDX = cIDX + 1;
//
// Check for a Cross ...
//
// fima2Signaller.fimaHelper.Update(barIndex);
has = fima2Signaller.fimaHelper.GetConditions(
fimaConditions,
barIndex,
5 //
);
//
double cSlowMA = fimaConditions.maSlowBuffer[cIDX];
double pSlowMA = fimaConditions.maSlowBuffer[pIDX];
//
double cMAUpper = fimaConditions.maBandUpperBuffer[cIDX];
double cMALower = fimaConditions.maBandLowerBuffer[cIDX];
//
double pMAUpper = fimaConditions.maBandUpperBuffer[pIDX];
double pMALower = fimaConditions.maBandLowerBuffer[pIDX];
//
bool isCrossedOver = cSlowMA > cMALower &&
pSlowMA < pMALower;
//
bool isCrossedUnder = cSlowMA < cMAUpper &&
cSlowMA > pMAUpper;
//
has = isCrossedOver ||
isCrossedUnder;
if (!has)
{
//
isBullish = false;
isBearish = false;
iDir = X_DIRECTION_NONE;
}
//
if (has)
{
//
isBullish = isCrossedOver;
isBearish = isCrossedUnder;
}
//
iDir = (isBullish && !isBearish)
? X_DIRECTION_BULLISH
: (isBearish && !isBullish)
? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
has = HasDirection(iDir);
if (has)
{
Print("Conditions Detected ...");
}
//
// Cleanup Resources ...
fimaConditions.Clean();
}
// //
+23
View File
@@ -1821,6 +1821,29 @@ struct XSignal
return result; return result;
} }
//
string GetObjectID()
{
//
string result = "";
//
if (!IsValid())
{
return result;
}
//
result = "XSignal_" +
symbol + "_" +
ToXString(period) + "_" +
ToXString(type) + "_" +
ToXString(TimeToSeconds(time));
//
return result;
}
// //
// Retrieve String Representation of Signal ... // Retrieve String Representation of Signal ...
string ToString() string ToString()
@@ -631,11 +631,13 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
ENUM_X_DIRECTION iDir = X_DIRECTION_NONE; ENUM_X_DIRECTION iDir = X_DIRECTION_NONE;
// //
XPivot pvPivots[];
string pvTrendName = "XXIFMA2PVTrend"; string pvTrendName = "XXIFMA2PVTrend";
CChartObjectTrend *pvTrendLine = NULL; CChartObjectTrend *pvTrendLine = NULL;
ENUM_X_DIRECTION pvTrend = X_DIRECTION_NONE; ENUM_X_DIRECTION pvTrend = X_DIRECTION_NONE;
// //
XPivot zgPivots[];
string zgTrendName = "XFIMA2ZGTrend"; string zgTrendName = "XFIMA2ZGTrend";
CChartObjectTrend *zgTrendLine = NULL; CChartObjectTrend *zgTrendLine = NULL;
ENUM_X_DIRECTION zgTrend = X_DIRECTION_NONE; ENUM_X_DIRECTION zgTrend = X_DIRECTION_NONE;
@@ -870,12 +872,12 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
// //
// Pivots ... // Pivots ...
XPivot pivots[]; XPivot pivots[];
int pivotsCount = poiDetector.ExtractPVPivots( count = poiDetector.ExtractPVPivots(
pivots, pivots,
barIndex, barIndex,
50 // 50 //
); );
has = IsValidSize(pivotsCount); has = IsValidSize(count);
// //
// Sort ... // Sort ...
@@ -1048,10 +1050,9 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
if (has) if (has)
{ {
// //
CArrayObj *drawnPivots = new CArrayObj(); Copy(
pivotsCount = poiDrawer.DrawPivots(
pivots, pivots,
drawnPivots // pvPivots //
); );
} }
@@ -1068,7 +1069,6 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
// //
// Support ... // Support ...
XBoxZone supportBox; XBoxZone supportBox;
// XCBoxObject *iSupportObj;
has = structure.zigzagAnalysis.HasSupportBox(supportBox); has = structure.zigzagAnalysis.HasSupportBox(supportBox);
if (has) if (has)
{ {
@@ -1078,32 +1078,11 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
supportBox, supportBox,
supports // supports //
); );
// has = poiDrawer.DrawBox(
// supportBox,
// iSupportObj,
// true, // Ignore At ...
// supportBox.type // Name ...
// );
// if (has)
// {
// //
// XPOIStyle iStyle;
// poiDrawer.GetBoxStyle(
// iStyle,
// supportBox.dir //
// );
// poiDrawer.ApplyBoxStyle(
// iSupportObj,
// iStyle //
// );
// iStyle.Clean();
// }
} }
// //
// Resistance ... // Resistance ...
XBoxZone resistanceBox; XBoxZone resistanceBox;
// XCBoxObject *iResistanceObj;
has = structure.zigzagAnalysis.HasResistanceBox(resistanceBox); has = structure.zigzagAnalysis.HasResistanceBox(resistanceBox);
if (has) if (has)
{ {
@@ -1113,37 +1092,17 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
resistanceBox, resistanceBox,
supports // supports //
); );
// has = poiDrawer.DrawBox(
// resistanceBox,
// iResistanceObj,
// true, // Ignore At ...
// resistanceBox.type // Name ...
// );
// if (has)
// {
// //
// XPOIStyle iStyle;
// poiDrawer.GetBoxStyle(
// iStyle,
// resistanceBox.dir //
// );
// poiDrawer.ApplyBoxStyle(
// iResistanceObj,
// iStyle //
// );
// iStyle.Clean();
// }
} }
// //
// Pivots ... // Pivots ...
XPivot pivots[]; XPivot pivots[];
int pivotsCount = poiDetector.ExtractZigZagPivots( count = poiDetector.ExtractZigZagPivots(
pivots, pivots,
barIndex, barIndex,
10 // 10 //
); );
has = IsValidSize(pivotsCount); has = IsValidSize(count);
// //
// Sort ... // Sort ...
@@ -1316,10 +1275,9 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
if (has) if (has)
{ {
// //
CArrayObj *drawnPivots = new CArrayObj(); Copy(
pivotsCount = fima2Signaller.poiDrawer.DrawPivots(
pivots, pivots,
drawnPivots // zgPivots //
); );
} }
@@ -1427,7 +1385,7 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
// //
// Do all Draws Here ... // Do all Draws Here ...
bool canDraw = true; bool canDraw = false;
if (canDraw) if (canDraw)
{ {
// //
@@ -1547,6 +1505,33 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
// //
// TrendLines ... // TrendLines ...
//
// Pivots ...
//
has = HasChild(pvPivots);
if (has)
{
//
CArrayObj *drawnPivots = new CArrayObj();
count = poiDrawer.DrawPivots(
pvPivots,
drawnPivots //
);
}
//
has = HasChild(zgPivots);
if (has)
{
//
CArrayObj *drawnPivots = new CArrayObj();
count = poiDrawer.DrawPivots(
zgPivots,
drawnPivots //
);
}
// //
// Patterns Bar ... // Patterns Bar ...
has = HasDirection(iDir); has = HasDirection(iDir);
@@ -1582,6 +1567,12 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
{ {
// //
// TODO: Provided SL ... // TODO: Provided SL ...
double _point = GetPoints(bar.symbol);
double slAddition = 5 * _point;
double slPrice =
isBullish
? iZone.lower - slAddition
: iZone.upper + slAddition;
// //
// Prepare Founded Signal ... // Prepare Founded Signal ...
@@ -1589,7 +1580,10 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
has = PrepareSignal( has = PrepareSignal(
signal, signal,
iDir, iDir,
targets // targets,
0, // Use Default R2R ...
slPrice, // Provided Price for SL ...
0 // Specified Risk in Point ....
); );
if (has) if (has)
{ {
@@ -1606,6 +1600,8 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
signal.Clean(); signal.Clean();
structure.Clean(); structure.Clean();
fimaConditions.Clean(); fimaConditions.Clean();
SpecifiedClean(pvPivots);
SpecifiedClean(zgPivots);
SpecifiedClean(supports); SpecifiedClean(supports);
SpecifiedClean(resistances); SpecifiedClean(resistances);
} }