last ...
This commit is contained in:
@@ -192,7 +192,275 @@ class XCXOM1SignallerBase
|
||||
*
|
||||
* @param barIndex: int
|
||||
*/
|
||||
void ProcessTick(int barIndex = 0)
|
||||
virtual void ProcessTick(int barIndex = 0)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Guards Based on MarketConditions ...
|
||||
*
|
||||
* @param guards: XGuard[]
|
||||
* @param barIndex: int
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int CheckForGuard(
|
||||
XGuard &guards[],
|
||||
int barIndex = 0 //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
SpecifiedClean(guards);
|
||||
|
||||
//
|
||||
result = ArraySize(guards);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Virtuals ...
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
XCXOM1Helper *mHelper; // Indicator Helper ...
|
||||
|
||||
//
|
||||
int mProcessedTicksCount; // Prcoessed Ticks Count ...
|
||||
datetime mLastCheckedBarTime; // Last Checked Bar Time ...
|
||||
|
||||
/**
|
||||
* Check Permissions for Analysing Market ...
|
||||
*
|
||||
* @param _symbol: Symbol ...
|
||||
* @param _period: Period ...
|
||||
* @param time: Specified Date Time ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool CanAnalyse(
|
||||
string _symbol,
|
||||
ENUM_TIMEFRAMES _period,
|
||||
datetime time //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (canAnalyseEventListener != NULL)
|
||||
{
|
||||
//
|
||||
result = canAnalyseEventListener(
|
||||
_symbol,
|
||||
_period,
|
||||
time //
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle New Bar's Process ...
|
||||
*
|
||||
* @param barIndex: int
|
||||
*/
|
||||
void ProcessNewBar(int barIndex = 0)
|
||||
{
|
||||
//
|
||||
// Normalize Bar Index ...
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Try to Update Zone's Lifetime ...
|
||||
int count = ArraySize(zones);
|
||||
bool has = count > 0;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
// Loop through Zones ...
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
// Update Lifetime by Bar Index ...
|
||||
// zones[i].UpdateByBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// drawer.DrawZone(
|
||||
// zones[i],
|
||||
// true, // Draw Price ...
|
||||
// true, // Draw Middle ...
|
||||
// true // Draw From ...
|
||||
// );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Check XOMZones Validations ...
|
||||
}
|
||||
|
||||
/**
|
||||
* Process Exists Zones ...
|
||||
* Detect a Zone for trigger ...
|
||||
*
|
||||
* @param barIndex: int
|
||||
*/
|
||||
void ProcessZones(int barIndex = 0)
|
||||
{
|
||||
//
|
||||
// Check Zones Exists ...
|
||||
int count = ArraySize(zones);
|
||||
bool has = IsValidSize(count);
|
||||
if (!has)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Loop Through Zones ...
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts iZone to Signal and Notify Signal ...
|
||||
*
|
||||
* @param iZone: XOM1Zone
|
||||
*/
|
||||
void PrepareSignal(XOM1Zone &zone)
|
||||
{
|
||||
//
|
||||
// Validate Zone ...
|
||||
if (!zone.IsValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Create Signal ...
|
||||
XSignal signal;
|
||||
|
||||
//
|
||||
signal.time = zone.to;
|
||||
signal.provider = name;
|
||||
signal.symbol = zone.symbol;
|
||||
signal.period = zone.period;
|
||||
signal.mode = X_ORDER_MODE_MARKET;
|
||||
signal.conditions = "XConditions";
|
||||
signal.comment = ToXString(zone.reason);
|
||||
signal.type = zone.IsBullish()
|
||||
? POSITION_TYPE_BUY
|
||||
: POSITION_TYPE_SELL;
|
||||
|
||||
//
|
||||
// Get Entry ...
|
||||
signal.entry = GetXEntry(zone.symbol, zone.dir);
|
||||
|
||||
//
|
||||
// Calculate SL ...
|
||||
double providedSL = zone.IsBullish()
|
||||
? zone.lower
|
||||
: zone.upper;
|
||||
signal.sl = providedSL;
|
||||
|
||||
//
|
||||
// Calculate Risk ...
|
||||
double risk = MathAbs(signal.entry - signal.sl);
|
||||
|
||||
//
|
||||
// Calculate Reward ...
|
||||
double r2r = 2;
|
||||
double reward = risk * r2r;
|
||||
|
||||
//
|
||||
// Calculate TP ...
|
||||
double providedTP = zone.IsBullish()
|
||||
? signal.entry + reward
|
||||
: signal.entry - reward;
|
||||
signal.tp = providedTP;
|
||||
|
||||
//
|
||||
// Calculate Targets ...
|
||||
// TODO: Handle this ...
|
||||
|
||||
//
|
||||
// Set Min Volume ...
|
||||
signal.volume = 0.01;
|
||||
|
||||
//
|
||||
NotifyOnSignalEvent(signal);
|
||||
}
|
||||
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
TOnSignal mOnSignalEventHandlers[]; // Signal Recieved Event Handlers ...
|
||||
};
|
||||
|
||||
//
|
||||
class XCXOM1FIMASignaller : public XCXOM1SignallerBase
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
XCXOM1FIMASignaller(
|
||||
string _name, // Name ...
|
||||
string _symbol, // Symbol ...
|
||||
ENUM_TIMEFRAMES _period, // Period ...
|
||||
XOM1Inputs &_inputs, // Indicator Inputs ...
|
||||
XOM1SignallerConfig &_config // Config ...
|
||||
) : XCXOM1SignallerBase(_name,
|
||||
_symbol,
|
||||
_period,
|
||||
_inputs,
|
||||
_config //
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XCXOM1FIMASignaller()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Overrides ...
|
||||
|
||||
/**
|
||||
* Handle Ticks Process ...
|
||||
*
|
||||
* @param barIndex: int
|
||||
*/
|
||||
virtual void ProcessTick(int barIndex = 0)
|
||||
{
|
||||
//
|
||||
// Normalize Bar Index ...
|
||||
@@ -557,219 +825,53 @@ class XCXOM1SignallerBase
|
||||
iBar.Clean();
|
||||
iConditions.Clean();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Check Guards Based on MarketConditions ...
|
||||
*
|
||||
* @param guards: XGuard[]
|
||||
* @param barIndex: int
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int CheckForGuard(
|
||||
XGuard &guards[],
|
||||
int barIndex = 0 //
|
||||
)
|
||||
//
|
||||
class XCXIMAC5020Signaller : public XCXOM1SignallerBase
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
XCXIMAC5020Signaller(
|
||||
string _name, // Name ...
|
||||
string _symbol, // Symbol ...
|
||||
ENUM_TIMEFRAMES _period, // Period ...
|
||||
XOM1Inputs &_inputs, // Indicator Inputs ...
|
||||
XOM1SignallerConfig &_config // Config ...
|
||||
) : XCXOM1SignallerBase(_name,
|
||||
_symbol,
|
||||
_period,
|
||||
_inputs,
|
||||
_config //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
SpecifiedClean(guards);
|
||||
|
||||
//
|
||||
result = ArraySize(guards);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Virtuals ...
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
XCXOM1Helper *mHelper; // Indicator Helper ...
|
||||
|
||||
//
|
||||
TOnSignal mOnSignalEventHandlers[]; // Signal Recieved Event Handlers ...
|
||||
|
||||
//
|
||||
int mProcessedTicksCount; // Prcoessed Ticks Count ...
|
||||
datetime mLastCheckedBarTime; // Last Checked Bar Time ...
|
||||
|
||||
//
|
||||
bool CanAnalyse(
|
||||
string _symbol,
|
||||
ENUM_TIMEFRAMES _period,
|
||||
datetime time //
|
||||
)
|
||||
// Deconstructor ...
|
||||
~XCXIMAC5020Signaller()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (canAnalyseEventListener != NULL)
|
||||
{
|
||||
//
|
||||
result = canAnalyseEventListener(
|
||||
_symbol,
|
||||
_period,
|
||||
time //
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Overrides ...
|
||||
|
||||
/**
|
||||
* Handle New Bar's Process ...
|
||||
* Handle Ticks Process ...
|
||||
*
|
||||
* @param barIndex: int
|
||||
*/
|
||||
void ProcessNewBar(int barIndex = 0)
|
||||
virtual void ProcessTick(int barIndex = 0)
|
||||
{
|
||||
//
|
||||
// Normalize Bar Index ...
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Try to Update Zone's Lifetime ...
|
||||
int count = ArraySize(zones);
|
||||
bool has = count > 0;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
// Loop through Zones ...
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
// Update Lifetime by Bar Index ...
|
||||
// zones[i].UpdateByBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// drawer.DrawZone(
|
||||
// zones[i],
|
||||
// true, // Draw Price ...
|
||||
// true, // Draw Middle ...
|
||||
// true // Draw From ...
|
||||
// );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Check XOMZones Validations ...
|
||||
}
|
||||
|
||||
/**
|
||||
* Process Exists Zones ...
|
||||
* Detect a Zone for trigger ...
|
||||
*
|
||||
* @param barIndex: int
|
||||
*/
|
||||
void ProcessZones(int barIndex = 0)
|
||||
{
|
||||
//
|
||||
// Check Zones Exists ...
|
||||
int count = ArraySize(zones);
|
||||
bool has = IsValidSize(count);
|
||||
if (!has)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Loop Through Zones ...
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts iZone to Signal and Notify Signal ...
|
||||
*
|
||||
* @param iZone: XOM1Zone
|
||||
*/
|
||||
void PrepareSignal(XOM1Zone &zone)
|
||||
{
|
||||
//
|
||||
// Validate Zone ...
|
||||
if (!zone.IsValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Create Signal ...
|
||||
XSignal signal;
|
||||
|
||||
//
|
||||
signal.time = zone.to;
|
||||
signal.provider = name;
|
||||
signal.symbol = zone.symbol;
|
||||
signal.period = zone.period;
|
||||
signal.mode = X_ORDER_MODE_MARKET;
|
||||
signal.conditions = "XConditions";
|
||||
signal.comment = ToXString(zone.reason);
|
||||
signal.type = zone.IsBullish()
|
||||
? POSITION_TYPE_BUY
|
||||
: POSITION_TYPE_SELL;
|
||||
|
||||
//
|
||||
// Get Entry ...
|
||||
signal.entry = GetXEntry(zone.symbol, zone.dir);
|
||||
|
||||
//
|
||||
// Calculate SL ...
|
||||
double providedSL = zone.IsBullish()
|
||||
? zone.lower
|
||||
: zone.upper;
|
||||
signal.sl = providedSL;
|
||||
|
||||
//
|
||||
// Calculate Risk ...
|
||||
double risk = MathAbs(signal.entry - signal.sl);
|
||||
|
||||
//
|
||||
// Calculate Reward ...
|
||||
double r2r = 2;
|
||||
double reward = risk * r2r;
|
||||
|
||||
//
|
||||
// Calculate TP ...
|
||||
double providedTP = zone.IsBullish()
|
||||
? signal.entry + reward
|
||||
: signal.entry - reward;
|
||||
signal.tp = providedTP;
|
||||
|
||||
//
|
||||
// Calculate Targets ...
|
||||
// TODO: Handle this ...
|
||||
|
||||
//
|
||||
// Set Min Volume ...
|
||||
signal.volume = 0.01;
|
||||
|
||||
//
|
||||
NotifyOnSignalEvent(signal);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Extensions ...
|
||||
|
||||
//
|
||||
Reference in New Issue
Block a user