Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
#
#
#
#
volumeEMALength = 30;
narrowSpreadFactor = 0.7;
wideSpreadFactor = 1.5;
aboveAvgVolfactor = 1.5;
ultraHighVolfactor = 2;
highCloseFactor = 0.70;
lowCloseFactor = 0.25;
GdojiFactor = 0.2; # C_RP
WickFactor = 0.1; # C_RP
colorBars = {default false, true};
trendText = {false, default true};
volumeDefinitions = { false, default true };
alerts = { default false, true };
#######
# Calculations
rec
def
rec
h),
# scond
rec isNewConfirmedUpThrustBar = (isConfirmedUpThrustBar[0] && !isConfirmedUpThru
stBar[1]);
# Two Period UpThrust Bar
rec isTwoPerUpT = isUpBar[1] && isWideSpreadBar[1] && isDownBar[0] && isDownClo
seBar[0] && !isUpThrustBar[0] && (absValue(open[1] - close[0]) < (GdojiFactor *
spread[1])) ;
# Three Period UpThrust Bar
rec isThreePerUpT = isUpBar[2] && isWideSpreadBar[2] && isDownBar[0] && isDownC
loseBar[0] && !isUpThrustBar[0] && (absValue(open[2] - close[0]) < (GdojiFactor
* spread[2])) ;
# C_RP 20100816
# rec isGraveDojiBar = (spread > avgSpread) && (open == low) && (close == low);
totally strict Gravestone Doji. Revised version below identifies a candle with a
bove average spread, a real body smaller than 20% of the spread, and a lower wic
k less than 10% of the spread as a Gravestone Doji pictured as a white triangle
above the candle.
rec isGraveDojiBar = (spread > avgSpread) && (absValue(open - close) < (GdojiFac
tor * spread)) && ((absValue(close - low) < (WickFactor * spread)) or (absValue
(open - low) < (WickFactor * spread))); # less strict Gravestone Doji
# trbar
def reversalLikelyBar = (volume[1] > sAvgVolume[0] && isUpBar[1] && isWideSpread
Bar[1] && isDownBar[0] && isDownCloseBar && isWideSpreadBar[0] && LongTermTrendS
lope > 0 && high == Highest(high, 10)[0]);
# hutbar
rec isPseudoUpThrustBar = (isUpBar[1] && (volume[1] > aboveAvgVolfactor * sAvgVo
lume[0]) && isDownBar[0] && isDownCloseBar && !isWideSpreadBar[0] && !isUpThrust
Bar[0]);
# hutcond
def pseudoUpThrustConfirmation = (isPseudoUpThrustBar[1] && isDownBar[0] && isDo
wnCloseBar && !isUpThrustBar[0]);
# C_RP Failed UpThrustConfirmation or pseudoUpThrustConfirmation occurs when the
close of bar following such confirmation is not lower than the close of the con
firmation bar
rec isFailedUpThrustConfirmation = (isNewConfirmedUpThrustBar[1] or pseudoUpThru
stConfirmation[1]) && close[0] >= close[1];
# tcbar
def weaknessBar = (isUpBar[1] && high[0] == Highest(high, 5)[0] && isDownBar[0]
&& (isDownCloseBar OR isMidCloseBar) && volume[0] > sAvgVolume[0] && !isWideSpre
adBar[0] && !isPseudoUpThrustBar[0]);
# stdn, stdn0, stdn1, stdn2
def strengthInDownTrend = (volume[0]
&& (isUpCloseBar OR isMidCloseBar) &&
Slope < 0);
def strengthInDownTrend0 = (volume[0]
&& (isUpCloseBar OR isMidCloseBar) &&
Slope < 0 && LongTermTrendSlope < 0);
def strengthInDownTrend1 = (volume[0]
######################################################################
# set the shapes on the graph
# upthurst and NOT confirmed - red square on top
plot upThrustBarPlot = if isUpThrustBar[0] AND !isNewConfirmedUpThrustBar[0] the
n (high + 2 * tickSize()) else Double.NAN;
upThrustBarPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
upThrustBarPlot.SetStyle(Curve.POINTS);
upThrustBarPlot.SetDefaultColor(Color.Red);
upThrustBarPlot.HideBubble();
upThrustBarPlot.HideTitle();
# C_RP 20100816
# any instance of a Gravestone Doji - white triangle on top
plot GraveDojiBarPlot = if isGraveDojiBar[0] then (high +4 * tickSize()) else Do
uble.NAN;
GraveDojiBarPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_TRIANGLES);
GraveDojiBarPlot.SetStyle(Curve.POINTS);
GraveDojiBarPlot.SetDefaultColor(CreateColor(255,255,255));
GraveDojiBarPlot.HideBubble();
GraveDojiBarPlot.HideTitle();
# C_RP
# Two Period UpThrust Plot - magenta triangle high on top
plot TwoPerUpTPlot = if isTwoPerUpT[0] then (high + 4 * tickSize()) else Double
.NAN;
TwoPerUpTPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_TRIANGLES);
TwoPerUpTPlot.SetStyle(Curve.POINTS);
TwoPerUpTPlot.SetDefaultColor(Color.magenta);
TwoPerUpTPlot.HideBubble();
TwoPerUpTPlot.HideTitle();
# C_RP
# Three Period UpThrust Plot - magenta triangle high on top
plot ThreePerUpTPlot = if isThreePerUpT[0] then (high + 4 * tickSize()) else Do
uble.NAN;
ThreePerUpTPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_TRIANGLES);
ThreePerUpTPlot.SetStyle(Curve.POINTS);
ThreePerUpTPlot.SetDefaultColor(Color.magenta);
ThreePerUpTPlot.HideBubble();
ThreePerUpTPlot.HideTitle();
# reversal likely - blue diamond on top C_RP red 6 * ticksize
plot reversalLikelyBarPlot = if reversalLikelyBar then (high + 6 * tickSize()) e
lse Double.NAN;
reversalLikelyBarPlot.SetPaintingStrategy(PaintingStrategy.POINTS);
reversalLikelyBarPlot.SetDefaultColor(Color.Red);
reversalLikelyBarPlot.HideBubble();
reversalLikelyBarPlot.HideTitle();
# new confirmed upthrust bar - red triangle (down) on top C_RP for upThrustCondi
tionOne only
plot isNewConfirmedUpThrustBarPlot = if isNewConfirmedUpThrustBar && upThrustCon
ditionOne then (high + 2 * tickSize()) else Double.NAN;
isNewConfirmedUpThrustBarPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_TRIAN
GLES);
isNewConfirmedUpThrustBarPlot.SetDefaultColor(Color.Red);
isNewConfirmedUpThrustBarPlot.HideBubble();
isNewConfirmedUpThrustBarPlot.HideTitle();
# new confirmed upthrust bar - red triangle (down) on top C_RP red arrow down at
4 * tickSize for conditions 2 and 3
plot isNewConfirmedUpThrustBarPlot23 = if isNewConfirmedUpThrustBar && (upThrust
ConditionTwo or upThrustConditionThree) then (high + 4 * tickSize()) else Double
.NAN;
isNewConfirmedUpThrustBarPlot23.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN)
;
isNewConfirmedUpThrustBarPlot23.SetDefaultColor(Color.Red);
isNewConfirmedUpThrustBarPlot23.HideBubble();
isNewConfirmedUpThrustBarPlot23.HideTitle();
# strength in down trend - lime square on bottom C_RP cyan for weakest strengthI
nDownTrend
plot strengthInDownTrendPlot = if strengthInDownTrend then (low - 4 * tickSize()
) else Double.NAN;
strengthInDownTrendPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
strengthInDownTrendPlot.SetDefaultColor(Color.cyan);
strengthInDownTrendPlot.HideBubble();
strengthInDownTrendPlot.HideTitle();
# strength in down trend - lime square on bottom C_RP for next-to-weakest streng
thInDownTrend
plot strengthInDownTrend1Plot = if strengthInDownTrend1 then (low - 4 * tickSize
()) else Double.NAN;
strengthInDownTrend1Plot.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
strengthInDownTrend1Plot.SetDefaultColor(Color.green);
strengthInDownTrend1Plot.HideBubble();
strengthInDownTrend1Plot.HideTitle();
# supply test in up trend - lime square on bottom of the bar C_RP grey
plot supplyTestInUpTrendBarPlot = if supplyTestInUpTrendBar then (low - 4 * tick
Size()) else Double.NAN;
supplyTestInUpTrendBarPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES)
;
supplyTestInUpTrendBarPlot.SetDefaultColor(CreateColor(153,153,153));
supplyTestInUpTrendBarPlot.HideBubble();
supplyTestInUpTrendBarPlot.HideTitle();
# successful test for supply - yellow triangle up on bottom of the bar C_RP cyan
plot successfulSupplyTestBarPlot = if successfulSupplyTestBar or successfulSuppl
yTestBar2 then (low - 2 * tickSize()) else Double.NAN;
successfulSupplyTestBarPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_TRIANGL
ES);
successfulSupplyTestBarPlot.SetDefaultColor(Color.cyan);
successfulSupplyTestBarPlot.HideBubble();
successfulSupplyTestBarPlot.HideTitle();
# successful test for supply - yellow triangle up on bottom of the bar C_RP cyan
double triangle for strong follow-up bar
plot successfulSupplyTestBarPlot2 = if successfulSupplyTestBar2 then (low - 4 *
tickSize()) else Double.NAN;
successfulSupplyTestBarPlot2.SetPaintingStrategy(PaintingStrategy.LINE_VS_TRIANG
LES);
successfulSupplyTestBarPlot2.SetDefaultColor(Color.cyan);
successfulSupplyTestBarPlot2.HideBubble();
successfulSupplyTestBarPlot2.HideTitle();
# stopping volume green (diamond) circle at bottom of bar
plot stopVolBarPlot = if stopVolBar then (low - 2 * tickSize()) else Double.NAN;
stopVolBarPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
stopVolBarPlot.SetDefaultColor(Color.green);
stopVolBarPlot.HideBubble();
stopVolBarPlot.HideTitle();
# green triangle up at bottom of the bar C_RP Green arrow up 4 * tickSize for st
rong strength_In_DownTrend
plot isStrengthConfirmationBarPlot = if isStrengthConfirmationBar then (low - 4
* tickSize()) else Double.NAN;
isStrengthConfirmationBarPlot.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
isStrengthConfirmationBarPlot.SetDefaultColor(Color.green);
isStrengthConfirmationBarPlot.HideBubble();
isStrengthConfirmationBarPlot.HideTitle();
# green triangle up at bottom of the bar C_RP Green arrow up 7 * tickSize for st
rongest strength_In_DownTrend with isUpCloseBar
plot isStrengthConfirmationBarPlot2 = if isStrengthConfirmationBar2 then (low 7 * tickSize()) else Double.NAN;
isStrengthConfirmationBarPlot2.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
isStrengthConfirmationBarPlot2.SetDefaultColor(Color.green);
isStrengthConfirmationBarPlot2.HideBubble();
isStrengthConfirmationBarPlot2.HideTitle();
# blue square at top of bar C_RP orange
plot isPseudoUpThrustBarPlot = if isPseudoUpThrustBar then (high + 2 * tickSize(
)) else Double.NAN;
isPseudoUpThrustBarPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
isPseudoUpThrustBarPlot.SetDefaultColor(CreateColor(255,102,102));
isPseudoUpThrustBarPlot.HideBubble();
isPseudoUpThrustBarPlot.HideTitle();
# blue triangle (down) at top of bar C_RP orange
plot pseudoUpThrustConfirmationPlot = if pseudoUpThrustConfirmation then (high +
2 * tickSize()) else Double.NAN;
pseudoUpThrustConfirmationPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_TRIA
NGLES);
pseudoUpThrustConfirmationPlot.SetDefaultColor(CreateColor(255,102,102));
pseudoUpThrustConfirmationPlot.HideBubble();
pseudoUpThrustConfirmationPlot.HideTitle();
# Failed UpthrustBarPlot Confirmation plots a green square 2 * tickSize above th
e failed bar C_RP
plot FailedUpThrustConfirmationPlot = if isFailedUpthrustConfirmation then (high
+ 2 * tickSize()) else Double.NAN;
FailedUpThrustConfirmationPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUA
RES);
FailedUpThrustConfirmationPlot.SetDefaultColor(Color.green);
FailedUpThrustConfirmationPlot.HideBubble();
FailedUpThrustConfirmationPlot.HideTitle();
# yellow triangle (down) at top of bar
plot weaknessBarPlot = if weaknessBar then (high + 2 * tickSize()) else Double.N
AN;
weaknessBarPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_TRIANGLES);
weaknessBarPlot.SetDefaultColor(Color.yellow);
weaknessBarPlot.HideBubble();
weaknessBarPlot.HideTitle();
# aqua triangle up at bottom of bar C_RP green triangle for next-to-strongest st
rengthInDownTrend
plot strengthInDownTrend2Plot = if strengthInDownTrend2 then (low - 2 * tickSize
######
# Candle definitions
AssignPriceColor( if colorBars and shortTermTrendSlope > 0 and MiddleTermTrendSl
ope > 0 and longtermtrendslope > 0 then CreateColor(0, 255, 0)
else if colorBars and shortTermTrendSlope > 0 and MiddleTermTrendSlope > 0 and
longtermtrendslope < 0 then Color.green else if
colorBars and shortTermTrendSlope > 0 and MiddleTermTrendSlope < 0 and longtermt
rendslope < 0 then CreateColor(153, 255, 153) else if
colorBars and shortTermTrendSlope < 0 and MiddleTermTrendSlope < 0 and longtermt
rendslope < 0 then Color.red else if
colorBars and shortTermTrendSlope < 0 and MiddleTermTrendSlope > 0 and longtermt
rendslope > 0 then CreateColor(153, 255, 153) else if
colorBars and shortTermTrendSlope < 0 and MiddleTermTrendSlope < 0 and longtermt
rendslope > 0 then color.orange
else if colorBars then Color.yellow else GetColor(7));
#######
# Trend Text Definitions
# C_RP 20100722 edited by Richard Paske to shorten text
# C_RP some colors changed to match symbols with text backgrounds
AddChartLabel(trendText, concat("Vol: ", if volume > sAvgVolume[0] + 2.0 * sAvgV
olumeSTD then "VH"
else if Volume[0] > (sAvgVolume[0] + 1.0 * sAvgVolumeSTD) then "H"
else if (Volume[0] > sAvgVolume[0]) then ">Avg"
else if (Volume[0] < sAvgVolume[0] && Volume[0] > (sAvgVolume[0] - 1.0 * sAv
gVolumeSTD)) then "<Avg"
else if (Volume[0] < (sAvgVolume[0] - 1.0 * sAvgVolumeSTD)) then "L"
else ""), Color.white);
AddChartLabel(trendText, concat("Spr: ", if (spread > (avgSpread * 2.0)) then "W
"
else if (spread > avgSpread) then ">Avg"
else "N"), Color.white);
# C_RP 20100809 added isVeryLowCloseBar and changed execution order so that both
Verys and Mid execute first
AddChartLabel(trendText, concat("Cls: ", if (isVeryHighCloseBar) then "VH"
else
else
else
else
if
if
if
if
"
else if stopVolBar then "Stopping volume. Normally indicates end of bearishn
ess is nearing."
else "",
if isUpThrustBar[0] then Color.Red
else if upThrustConditionOne then Color.red
else if upThrustConditionTwo && !upThrustConditionOne then Color.red
else if upThrustConditionThree then Color.red
else if isTwoPerUpT then Color.magenta
else if isThreePerUpT then Color.magenta
else if isGraveDojiBar then CreateColor(255,255,255)
else if strengthInDownTrend1 then Color.green
else if strengthInDownTrend0 && !strengthInDownTrend then Color.cyan
else if strengthInDownTrend && !strengthInDownTrend1 then Color.cyan
else if isFailedStrengthSignal then Color.red
else if supplyTestBar[0] then Color.white
else if successfulSupplyTestBar[0] then CreateColor(102,255,0)
else if isStrengthConfirmationBar then Color.Green
else if distributionBar then Color.magenta
else if isPseudoUpThrustBar[0] then (CreateColor(255,102,102))
else if pseudoUpThrustConfirmation then (CreateColor(255,102,102))
else if isFailedUpThrustConfirmation then (Color.green)
else if supplyTestInUpTrendBar then CreateColor(153,153,153)
else if strengthInDownTrend2 then Color.green
else if weaknessBar then Color.Yellow
else if noDemandBar then CreateColor(255,102,102)
else if noSupplyBar then Color.cyan
else if effortToMoveUpBar[0] then CreateColor(0, 255,0)
else if effortToMoveDownBar then Color.magenta
else if failedEffortUpMove then Color.Blue
else if stopVolBar then Color.green
else Color.black);
########
# Alerts
alert(if alerts and (isUpThrustBar[0]
or upThrustConditionOne
or (upThrustConditionTwo && !upThrustConditionOne)
or upThrustConditionThree
or strengthInDownTrend1
or (strengthInDownTrend0 && !strengthInDownTrend)
or (strengthInDownTrend && !strengthInDownTrend1)
or supplyTestBar[0]
or successfulSupplyTestBar[0]
or isStrengthConfirmationBar
or distributionBar
or isPseudoUpThrustBar[0]
or pseudoUpThrustConfirmation
or supplyTestInUpTrendBar
or strengthInDownTrend2
or weaknessBar
or noDemandBar
or noSupplyBar
or effortToMoveUpBar[0]
or effortToMoveDownBar
or failedEffortUpMove
or stopVolBar) then 1 else 0, if isUpThrustBar[0] then "An Upthrust Bar. A
sign of weakness."
else if upThrustConditionOne then "A downbar after an Upthrust. Confirm weak
ness."
else if upThrustConditionTwo && !upThrustConditionOne then "A High Volume do
wnbar after an Upthrust. Confirm weakness."
else if upThrustConditionThree then "This upthrust at very High Volume, Conf
irms weakness."
else if strengthInDownTrend1 then "Strength seen returning after a down tren
d. High volume adds to strength. "
else if strengthInDownTrend0 && !strengthInDownTrend then "Strength seen ret
urning after a down trend."
else if strengthInDownTrend && !strengthInDownTrend1 then "Strength seen ret
urning after a long down trend."
else if supplyTestBar[0] then "Test for supply."
else if successfulSupplyTestBar[0] then "An Upbar closing near High after a
Test confirms strength."
else if isStrengthConfirmationBar then "An Upbar closing near High. Confirms
return of Strength."
else if distributionBar then "A High Volume Up Bar closing down in a uptrend
shows Distribution."
else if isPseudoUpThrustBar[0] then "Psuedo UpThrust. A Sign of Weakness."
else if pseudoUpThrustConfirmation then "A Down Bar closing down after a Pse
udo Upthrust confirms weakness."
else if supplyTestInUpTrendBar then "Test for supply in a uptrend. Sign of S
trength."
else if strengthInDownTrend2 then "High volume upbar closing on the high ind
icates strength."
else if weaknessBar then "High volume Downbar after an upmove on high volume
indicates weakness."
else if noDemandBar then "No Demand. A sign of Weakness."
else if noSupplyBar then "No Supply. A sign of Strength."
else if effortToMoveUpBar[0] then "Effort to Rise. Bullish sign."
else if effortToMoveDownBar then "Effort to Fall. Bearish sign."
else if failedEffortUpMove then "Effort to Move up has failed. Bearish sign.
"
else if stopVolBar then "Stopping volume. Normally indicates end of bearishn
ess is nearing."
else "", Alert.BAR, Sound.Ding);
# Red Square
# Blue Diamond
d up bar, but
#
d down bar.
# Red Triangle Down
# Lime Square
or a supply
#
# Yellow Triangle Up
th.
# Lime Diamond
is nearing
#
# Lime Triangle Up
onfirms strength.
# Blue Square
Up Bar closing
#
- UpThrust bar.
- Reversal possible, yesterday was high volume wide sprea
today we reached 10 days high with low close wide sprea
- UpThrust confirmation.
- Strength bar (either strength is showing in down trend
test in up trend).
- An Upbar closing near High after a Test confirms streng
- Stopping volume. Normally indicates end of bearishness
/OR/ No supply.
- The previous bar saw strength coming back, This upbar c
- Psuedo UpThrust, A Sign of Weakness /OR/ A High Volume
down in a uptrend shows Distribution /OR/ No Demand.