last ...
This commit is contained in:
@@ -2481,6 +2481,85 @@ struct XBarTracker
|
||||
symbol = NormalizeSymbol(NULL);
|
||||
period = NormalizePeriod(NULL);
|
||||
}
|
||||
|
||||
//
|
||||
bool GetBar(
|
||||
XOHCL &bar,
|
||||
int index = 0 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = bar.Init(
|
||||
symbol,
|
||||
period,
|
||||
index //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool GetBar(
|
||||
XOHCL &bar,
|
||||
datetime time = NULL //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
NormalizeTime(time);
|
||||
|
||||
//
|
||||
int barIndex = iBarShift(
|
||||
symbol,
|
||||
period,
|
||||
time,
|
||||
false //
|
||||
);
|
||||
|
||||
//
|
||||
result = barIndex >= 0;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = bar.Init(
|
||||
symbol,
|
||||
period,
|
||||
barIndex //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int Index(datetime time = NULL)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
NormalizeTime(time);
|
||||
|
||||
//
|
||||
result = iBarShift(
|
||||
symbol,
|
||||
period,
|
||||
time,
|
||||
false //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
@@ -3523,6 +3602,10 @@ bool IsValid(datetime value)
|
||||
//
|
||||
return result;
|
||||
}
|
||||
bool IsSpecifiedValid(datetime value)
|
||||
{
|
||||
return IsValid(value);
|
||||
}
|
||||
|
||||
//
|
||||
// Validate a Period Param ...
|
||||
@@ -4341,7 +4424,9 @@ void CalculateTPSL(
|
||||
double mEntry, // Entry Price
|
||||
double mR2R = 1, // Provided Risk To Reward Ratio
|
||||
double slPrice = 0, // Provided SL Price
|
||||
double tpPrice = 0 // Provided TP Price
|
||||
double tpPrice = 0, // Provided TP Price
|
||||
double priceToRisk = 0, // If Entry equal to Provided SL Price Risk Point
|
||||
double priceToReward = 0 // If Entry equal to Provided TP Price Reward Point
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -4378,26 +4463,34 @@ void CalculateTPSL(
|
||||
//
|
||||
bool canCalculateBasedOnSL = slPrice > 0 &&
|
||||
(isLong
|
||||
? slPrice < mEntry
|
||||
: slPrice > mEntry);
|
||||
? slPrice <= mEntry
|
||||
: slPrice >= mEntry);
|
||||
|
||||
//
|
||||
bool canCalculateBasedOnTP = tpPrice > 0 &&
|
||||
(isLong
|
||||
? tpPrice > mEntry
|
||||
: tpPrice < mEntry);
|
||||
? tpPrice >= mEntry
|
||||
: tpPrice <= mEntry);
|
||||
|
||||
//
|
||||
if (canCalculateBasedOnSL && !canCalculateBasedOnTP)
|
||||
{
|
||||
//
|
||||
risk = MathAbs(mEntry - slPrice);
|
||||
if (risk == 0)
|
||||
{
|
||||
risk = priceToRisk;
|
||||
}
|
||||
reward = risk * mR2R;
|
||||
}
|
||||
else if (!canCalculateBasedOnSL && canCalculateBasedOnTP)
|
||||
{
|
||||
//
|
||||
reward = MathAbs(mEntry - tpPrice);
|
||||
if (reward == 0)
|
||||
{
|
||||
reward = priceToReward;
|
||||
}
|
||||
risk = reward / mR2R;
|
||||
}
|
||||
else if (!canCalculateBasedOnSL && !canCalculateBasedOnTP)
|
||||
|
||||
Reference in New Issue
Block a user