//=================================================
// BEARISH ORDER BLOCK
//=================================================
if (!bullishSetup &&
close > open)
{
zoneTop = high;
zoneBottom = low;
return true;
}
}
return false;
}
//=========================================================
// TRADE LEVELS
//=========================================================
private void CalculateTradeLevels(
PatternSetup setup)
{
//=====================================================
// LONG / W
//=====================================================
if (setup.IsLong)
{
double lowestBottom =
Math.Min(
setup.FirstPivot,
setup.SecondPivot);
setup.Stop =
RoundPrice(
lowestBottom -
(StopBufferTicks *
TickSize));
double risk =
setup.Entry -
setup.Stop;
if (risk < TickSize)
risk = TickSize;
setup.TP1 =
RoundPrice(
setup.Entry +
(risk *
Target1R));
setup.TP2 =
RoundPrice(
setup.Entry +
(risk *
Target2R));
setup.TP3 =
RoundPrice(
setup.Entry +
(risk *
Target3R));
}
//=====================================================
// SHORT / M
//=====================================================
else
{
double highestTop =
Math.Max(
setup.FirstPivot,
setup.SecondPivot);
setup.Stop =
RoundPrice(
highestTop +
(StopBufferTicks *
TickSize));
double risk =
setup.Stop -
setup.Entry;
if (risk < TickSize)
risk = TickSize;
setup.TP1 =
RoundPrice(
setup.Entry -
(risk *
Target1R));
setup.TP2 =
RoundPrice(
setup.Entry -
(risk *
Target2R));
setup.TP3 =
RoundPrice(
setup.Entry -
(risk *
Target3R));
}
}
//=========================================================
// DRAW M
//=========================================================
private void DrawDoubleTop(
PatternSetup setup)
{
if (!ShowPatternLines)
return;
int firstAgo =
CurrentBar -
setup.FirstPivotBar;
int neckAgo =
CurrentBar -
setup.NecklineBar;
int secondAgo =
CurrentBar -
setup.SecondPivotBar;
Draw.Line(
this,
setup.Tag + "_M1",
firstAgo,
setup.FirstPivot,
neckAgo,
setup.Neckline,
Brushes.OrangeRed);
Draw.Line(
this,
setup.Tag + "_M2",
neckAgo,
setup.Neckline,
secondAgo,
setup.SecondPivot,
Brushes.OrangeRed);
Draw.Text(
this,
setup.Tag + "_M",
"M",
secondAgo,
setup.SecondPivot +
(8 * TickSize),
Brushes.OrangeRed);
}
//=========================================================
// DRAW W
//=========================================================
private void DrawDoubleBottom(
PatternSetup setup)
{
if (!ShowPatternLines)
return;
int firstAgo =
CurrentBar -
setup.FirstPivotBar;
int neckAgo =
CurrentBar -
setup.NecklineBar;
int secondAgo =
CurrentBar -
setup.SecondPivotBar;
Draw.Line(
this,
setup.Tag + "_W1",
firstAgo,
setup.FirstPivot,
neckAgo,
setup.Neckline,
Brushes.LimeGreen);
Draw.Line(
this,
setup.Tag + "_W2",
neckAgo,
setup.Neckline,
secondAgo,
setup.SecondPivot,
Brushes.LimeGreen);
Draw.Text(
this,
setup.Tag + "_W",
"W",
secondAgo,
setup.SecondPivot -
(8 * TickSize),
Brushes.LimeGreen);
}
//=========================================================
// DRAW SETUP
//=========================================================
private void DrawSetupLevels(
PatternSetup setup,
int endAbsoluteBar)
{
if (!setup.Activated)
return;
if (endAbsoluteBar <
setup.SecondPivotBar)
{
endAbsoluteBar =
setup.SecondPivotBar;
}
if (endAbsoluteBar >
CurrentBar)
{
endAbsoluteBar =
CurrentBar;
}
int startAgo =
CurrentBar -
setup.SecondPivotBar;
int endAgo =
CurrentBar -
endAbsoluteBar;
//=====================================================
// NECKLINE
//=====================================================
if (ShowNeckline)
{
Draw.Line(
this,
setup.Tag + "_NECK",
startAgo,
setup.Neckline,
endAgo,
setup.Neckline,
Brushes.Gold);
Draw.Text(
this,
setup.Tag + "_NECK_TEXT",
"NECK",
endAgo,
setup.Neckline,
Brushes.Gold);
}
//=====================================================
// FVG / ORDER BLOCK
//=====================================================
if (setup.HasZone)
{
bool showZone =
(setup.IsFVG &&
ShowFVG)
||
(!setup.IsFVG &&
ShowOrderBlock);
if (showZone)
{
Brush zoneBrush;
int zoneOpacity;
//=============================================
// FVG COLORS
//
// LONG FVG = GREEN
// SHORT FVG = RED
//=============================================
if (setup.IsFVG)
{
if (setup.IsLong)
{
zoneBrush =
Brushes.LimeGreen;
}
else
{
zoneBrush =
Brushes.Red;
}
zoneOpacity =
FVGOpacity;
}
//=============================================
// ORDER BLOCK
// KEEP EXISTING BLUE COLOR
//=============================================
else
{
zoneBrush =
Brushes.DodgerBlue;
zoneOpacity =
15;
}
Draw.Rectangle(
this,
setup.Tag + "_ZONE",
false,
startAgo,
setup.ZoneTop,
endAgo,
setup.ZoneBottom,
zoneBrush,
zoneBrush,
zoneOpacity);
Draw.Text(
this,
setup.Tag + "_ZONE_TEXT",
setup.IsFVG
? (setup.IsLong
? "LONG FVG"
: "SHORT FVG")
: "OB",
endAgo,
setup.ZoneTop,
zoneBrush);
}
}
//=====================================================
// ENTRY
//=====================================================
if (ShowEntry)
{
Draw.Line(
this,
setup.Tag + "_ENTRY",
startAgo,
setup.Entry,
endAgo,
setup.Entry,
Brushes.White);
Draw.Text(
this,
setup.Tag + "_ENTRY_TEXT",
setup.IsLong
? "LONG"
: "SHORT",
endAgo,
setup.Entry,
Brushes.White);
}
//=====================================================
// STOP RECTANGLE
//=====================================================
if (ShowStopRectangle)
{
DrawStopRectangle(
setup,
startAgo,
endAgo);
}
//=====================================================
// TARGETS
//=====================================================
if (ShowTargets)
{
DrawTarget(
setup,
startAgo,
endAgo,
setup.TP1,
"1");
DrawTarget(
setup,
startAgo,
endAgo,
setup.TP2,
"2");
DrawTarget(
setup,
startAgo,
endAgo,
setup.TP3,
"3");
}
}
//=========================================================
// STOP RECTANGLE
//
// LONG TEXT = GREEN
// SHORT TEXT = RED
//=========================================================
private void DrawStopRectangle(
PatternSetup setup,
int startAgo,
int endAgo)
{
string stopText =
setup.IsLong
? "SHORT"
: "LONG";
Brush stopBrush;
if (stopText == "LONG")
{
stopBrush =
Brushes.LimeGreen;
}
else
{
stopBrush =
Brushes.Red;
}
double halfHeight =
(StopRectangleHeightTicks *
TickSize) / 2.0;
if (halfHeight <
TickSize)
{
halfHeight =
TickSize;
}
double boxTop =
setup.Stop +
halfHeight;
double boxBottom =
setup.Stop -
halfHeight;
Draw.Rectangle(
this,
setup.Tag +
"_STOP_RECTANGLE",
false,
startAgo,
boxTop,
endAgo,
boxBottom,
stopBrush,
stopBrush,
StopRectangleOpacity);
int textAgo =
endAgo;
if (startAgo >
endAgo)
{
textAgo =
endAgo +
((startAgo -
endAgo) / 2);
}
Draw.Text(
this,
setup.Tag +
"_STOP_RECTANGLE_TEXT",
stopText,
textAgo,
setup.Stop,
Brushes.White);
}