last ...
This commit is contained in:
@@ -1142,3 +1142,198 @@
|
||||
);
|
||||
bullishScore += tmpBullishScore;
|
||||
bearishScore += tmpBearishScore;
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//
|
||||
// Place EQM Orders ...
|
||||
void PlaceEQMOrders()
|
||||
{
|
||||
//
|
||||
int count = CountSetups();
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
XSignal supports[];
|
||||
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
string iSymbol = mSetups[i].GetSymbol();
|
||||
ENUM_TIMEFRAMES iPeriod = NULL; // All Periods ...
|
||||
string iProvider = NULL; // All Providers ...
|
||||
|
||||
//
|
||||
XPosition iPositions[];
|
||||
int iPositionsCount = mTrader.GetPositions(
|
||||
iPositions,
|
||||
iSymbol,
|
||||
iProvider,
|
||||
iPeriod,
|
||||
X_POSITION_TYPE_ALL //
|
||||
);
|
||||
if (!IsValidSize(iPositionsCount))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
int maxInDIDX = FindMaxDrawdownIndex(
|
||||
iPositions //
|
||||
);
|
||||
if (!IsValidIndex(maxInDIDX))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
XPosition maxInDP = iPositions[maxInDIDX];
|
||||
bool isLong = IsLong(maxInDP.type);
|
||||
|
||||
//
|
||||
XOHCL iZBar;
|
||||
bool isInited = iZBar.Init(
|
||||
iSymbol,
|
||||
iPeriod,
|
||||
0 //
|
||||
);
|
||||
if (!isInited)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
double iSupport = 0;
|
||||
double iResistance = 0;
|
||||
bool isDrawn = DrawTrendState(
|
||||
ChartID(),
|
||||
"XTRND",
|
||||
iZBar,
|
||||
iSupport,
|
||||
iResistance //
|
||||
);
|
||||
if (isDrawn)
|
||||
{
|
||||
//
|
||||
XSignal iSignal;
|
||||
|
||||
//
|
||||
double iSL = 0;
|
||||
double iTP = 0;
|
||||
double iEntry = 0;
|
||||
ENUM_POSITION_TYPE iType;
|
||||
ENUM_X_ORDER_MODES iMode;
|
||||
double iVolume = maxInDP.volume * 3;
|
||||
|
||||
//
|
||||
if (iSupport > 0 && isLong && iSupport > maxInDP.sl && maxInDP.sl > 0)
|
||||
{
|
||||
//
|
||||
// Add Short Support for Long ...
|
||||
iEntry = iSupport;
|
||||
iSL = maxInDP.tp;
|
||||
iTP = maxInDP.sl;
|
||||
iMode = X_ORDER_MODE_STOP;
|
||||
iType = POSITION_TYPE_SELL;
|
||||
|
||||
//
|
||||
bool isPrepared = iSignal.Prepare(
|
||||
iSymbol,
|
||||
XEQMSupportToken,
|
||||
iPeriod,
|
||||
iType,
|
||||
iMode,
|
||||
iEntry,
|
||||
iVolume,
|
||||
iSL,
|
||||
iTP //
|
||||
);
|
||||
if (isPrepared)
|
||||
{
|
||||
//
|
||||
iSignal.comment = GenerateSupportTag(maxInDP.ticket);
|
||||
|
||||
//
|
||||
AddRef(
|
||||
iSignal,
|
||||
supports ///
|
||||
);
|
||||
|
||||
//
|
||||
iSignal.Clean();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
if (iResistance > 0 && !isLong && iResistance < maxInDP.sl && maxInDP.sl > 0)
|
||||
{
|
||||
//
|
||||
// Add Long Support for Short ...
|
||||
iEntry = iResistance;
|
||||
iSL = maxInDP.tp;
|
||||
iTP = maxInDP.sl;
|
||||
iMode = X_ORDER_MODE_STOP;
|
||||
iType = POSITION_TYPE_BUY;
|
||||
|
||||
//
|
||||
bool isPrepared = iSignal.Prepare(
|
||||
iSymbol,
|
||||
XEQMSupportToken,
|
||||
iPeriod,
|
||||
iType,
|
||||
iMode,
|
||||
iEntry,
|
||||
iVolume,
|
||||
iSL,
|
||||
iTP //
|
||||
);
|
||||
if (isPrepared)
|
||||
{
|
||||
//
|
||||
iSignal.comment = GenerateSupportTag(maxInDP.ticket);
|
||||
|
||||
//
|
||||
AddRef(
|
||||
iSignal,
|
||||
supports ///
|
||||
);
|
||||
|
||||
//
|
||||
iSignal.Clean();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
int supportsCount = ArraySize(supports);
|
||||
if (!IsValidSize(supportsCount))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
ENUM_X_SIGNAL_EXECUTION_RESULT states[];
|
||||
int executeds = mTrader.ExecuteSignals(
|
||||
supports,
|
||||
states,
|
||||
ORDER_TIME_GTC,
|
||||
false,
|
||||
false // Ignore Policies
|
||||
);
|
||||
if (IsValidSize(executeds))
|
||||
{
|
||||
//
|
||||
string message = XEQMSupportToken + " Execute " + ToString(executeds) + " Supports ...";
|
||||
|
||||
//
|
||||
Alert(message);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user