last ...
This commit is contained in:
@@ -853,6 +853,33 @@ struct XOHCL
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool GetPreviousBar(XOHCL &bar)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int idx = Index();
|
||||
|
||||
//
|
||||
result = bar.Init(
|
||||
this.symbol,
|
||||
this.period,
|
||||
idx + 1 //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Bar has Strong Body or Not ...
|
||||
bool HasStrongBody()
|
||||
@@ -877,6 +904,239 @@ struct XOHCL
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Bar Must Open Below Prce
|
||||
// and Close Above it ...
|
||||
bool IsBreakUp(
|
||||
double price // a Price to Check Breake
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = HasStrongBody();
|
||||
if (!result || price <= 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Select required Prices ...
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
close > price &&
|
||||
open < price;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Bar Must Open Above Prce
|
||||
// and Close Below it ...
|
||||
bool IsBreakDown(
|
||||
double price // a Price to Check Breake
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = HasStrongBody();
|
||||
if (!result || price <= 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Select required Prices ...
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
open > price &&
|
||||
close < price;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool IsBreakOut(
|
||||
double price, // a Price to Check Breake
|
||||
bool useHighLow = true // if true using High and Low price for Breakeouts, if not use Open Close
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = HasStrongBody();
|
||||
if (!result || price <= 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Select required Prices ...
|
||||
|
||||
//
|
||||
double selectedUp =
|
||||
useHighLow
|
||||
? high
|
||||
: GetUp();
|
||||
double selectedDown =
|
||||
useHighLow
|
||||
? low
|
||||
: GetDown();
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
selectedUp > price &&
|
||||
selectedDown < price;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Bar is Inside Previus Bar ...
|
||||
bool IsInsideBar(
|
||||
double threshold = 5 // Points Distance between Up and Down
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (threshold < 0)
|
||||
{
|
||||
threshold = 0;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL pBar;
|
||||
result = GetPreviousBar(pBar);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double offset = PointToPrice(threshold, this.symbol);
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
pBar.high > this.high &&
|
||||
pBar.low < this.low &&
|
||||
MathAbs(pBar.low - this.low) > offset &&
|
||||
MathAbs(pBar.high - this.high) > offset
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Bar has Strongest Body in a Range ...
|
||||
bool HasStrongestBody(
|
||||
int loopback = 3 // loopback candles to compare it ...
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double body = GetBody();
|
||||
XOHCL prev = this;
|
||||
for (int i = 0; i < loopback; i++)
|
||||
{
|
||||
//
|
||||
bool isValid = prev.GetPreviousBar(prev);
|
||||
if (!isValid)
|
||||
{
|
||||
//
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
result &&
|
||||
body > prev.GetBody()
|
||||
//
|
||||
;
|
||||
if (!result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Bar has Weakest Body in a Range ...
|
||||
bool HasWeakestBody(
|
||||
int loopback = 3 // loopback candles to compare it ...
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double body = GetBody();
|
||||
XOHCL prev = this;
|
||||
for (int i = 0; i < loopback; i++)
|
||||
{
|
||||
//
|
||||
bool isValid = prev.GetPreviousBar(prev);
|
||||
if (!isValid)
|
||||
{
|
||||
//
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
result &&
|
||||
body < prev.GetBody()
|
||||
//
|
||||
;
|
||||
if (!result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Determines Swings based On this Bar ...
|
||||
// Calculates Based on atleast 3 Bars Prev ...
|
||||
|
||||
Reference in New Issue
Block a user