Add Opposit Signal Generator Function in XSignal Structure ...
This commit is contained in:
@@ -637,6 +637,73 @@ struct XSignal
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Generate Opposit Direction ...
|
||||
bool GenerateOpposit(
|
||||
XSignal &mSignal // Oppsoit Signal
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
ENUM_POSITION_TYPE mType = GetOpposit(this.type);
|
||||
double mEntry = GetExit(this.symbol, mType);
|
||||
|
||||
//
|
||||
bool isLong = IsLong(mType);
|
||||
|
||||
//
|
||||
double mTP = 0;
|
||||
this.RegularTP(mTP);
|
||||
|
||||
//
|
||||
double mSL = 0;
|
||||
this.RegularSL(mSL);
|
||||
|
||||
//
|
||||
// Calculate Risk Reward Ratio ...
|
||||
double risk = MathAbs(this.entry - mSL);
|
||||
double reward = MathAbs(this.entry - mTP);
|
||||
|
||||
//
|
||||
double r2r = reward / risk;
|
||||
|
||||
//
|
||||
mSL = isLong
|
||||
? mEntry - risk
|
||||
: mEntry + risk;
|
||||
|
||||
//
|
||||
mTP = isLong
|
||||
? mEntry + reward
|
||||
: mEntry - reward;
|
||||
|
||||
//
|
||||
result = mSignal.Prepare(
|
||||
this.symbol,
|
||||
this.provider,
|
||||
this.period,
|
||||
mType,
|
||||
this.mode,
|
||||
mEntry,
|
||||
this.volume,
|
||||
this.action,
|
||||
mSL,
|
||||
mTP //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
void Clean()
|
||||
|
||||
Reference in New Issue
Block a user