InvestorsHub Logo
Followers 11
Posts 2529
Boards Moderated 1
Alias Born 04/03/2009

Re: None

Wednesday, 03/07/2012 12:41:33 PM

Wednesday, March 07, 2012 12:41:33 PM

Post# of 3631
Spdpro@ Pivot Code: I rewrote a borrowed code (off some site, can't remember) to provide dashes in all time frames. The dashes do not connect. For some reason the lines do and I can't figure out why ... no matter, the dashes work fine. (i.e. If you change the code from DASHES to LINE, they connect, so use dashes instead.)

I also added S4 and R4.

There is something in the code that defines a Bear market and a Bull market. In these cases, it provides a RR and SS. I'm still trying to figure that out but, so far, I have not seen them come into play. If it does, I'll decide if I want to keep it or try and delete it.

This code has a Person's Filter.

Next, I'm considering writing a code for Fibonacci Pivots. The formulas look interesting to me.

#####

input marketThreshold = 0.00;
input timeFrame = {default DAY, "2 DAYS", "3 DAYS", "4 DAYS", WEEK, MONTH, "OPT EXP"};
input showOnlyToday = no;
input applyPersonsLevelsFilter = no;

rec marketType = {default DISABLED, NEUTRAL, BEARISH, BULLISH};

def PP2 = high(period = timeFrame)[2] + low(period = timeFrame)[2] + close(period = timeFrame)[2];

marketType = if !applyPersonsLevelsFilter then marketType.DISABLED else
if PP2[-1] > (PP2[-1] + PP2 + PP2[1]) / 3 + marketThreshold then marketType.BULLISH else
if PP2[-1] < (PP2[-1] + PP2 + PP2[1]) / 3 - marketThreshold then marketType.BEARISH else marketType.NEUTRAL;

plot R4;
plot R3;
plot R2;
plot R1;
plot RR;
plot PP;
plot SS;
plot S1;
plot S2;
plot S3;
plot S4;

if showOnlyToday and !IsNaN(close(period = timeFrame)[-1])
then {
R1 = Double.NaN;
R2 = Double.NaN;
R3 = Double.NaN;
R4 = Double.NaN;
PP = Double.NaN;
S1 = Double.NaN;
S2 = Double.NaN;
S3 = Double.NaN;
S4 = Double.NaN;

} else {

PP = (high(period = timeFrame)[1] + low(period = timeFrame)[1] + close(period = timeFrame)[1]) / 3;
R1 = 2 * PP - low(period = timeFrame)[1];
R2 = PP + high(period = timeFrame)[1] - low(period = timeFrame)[1];
R3 = R2 + high(period = timeFrame)[1] - low(period = timeFrame)[1];
R4 = R3 + high(period = timeFrame)[1] - low(period = timeFrame)[1];

S1 = 2 * PP - high(period = timeFrame)[1];
S2 = PP - high(period = timeFrame)[1] + low(period = timeFrame)[1];
S3 = S2 - high(period = timeFrame)[1] + low(period = timeFrame)[1];
S4 = S3 - high(period = timeFrame)[1] + low(period = timeFrame)[1];

}

RR = if (marketType == marketType.BEARISH or marketType == marketType.NEUTRAL) then R1 else R2;
SS = if (marketType == marketType.BULLISH or marketType == marketType.NEUTRAL) then S1 else S2;

RR.setHiding(!applyPersonsLevelsFilter);
R1.setHiding(applyPersonsLevelsFilter);
R2.setHiding(applyPersonsLevelsFilter);
R3.hide();
R4.hide();
SS.setHiding(!applyPersonsLevelsFilter);
S1.setHiding(applyPersonsLevelsFilter);
S2.setHiding(applyPersonsLevelsFilter);
S3.hide();
S4.hide();

PP.SetDefaultColor(GetColor(0));
R1.SetDefaultColor(GetColor(2));
R2.SetDefaultColor(GetColor(8));
R3.SetDefaultColor(GetColor(3));
R4.SetDefaultColor(GetColor(5));
S1.SetDefaultColor(GetColor(6));
S2.SetDefaultColor(GetColor(1));
S3.SetDefaultColor(GetColor(3));
S4.SetDefaultColor(GetColor(5));


SS.DefineColor("S1", GetColor(6));
SS.DefineColor("S2", GetColor(6));
SS.AssignValueColor(if SS == S1 then SS.color("S1") else SS.color("S2"));

RR.DefineColor("R1", GetColor(5));
RR.DefineColor("R2", GetColor(5));
RR.AssignValueColor(if RR == R1 then RR.color("R1") else RR.color("R2"));

PP.SetStyle(Curve.firm);
RR.SetStyle(Curve.SHORT_DASH);
R1.SetStyle(Curve.SHORT_DASH);
R2.SetStyle(Curve.SHORT_DASH);
R3.SetStyle(Curve.SHORT_DASH);
SS.SetStyle(Curve.SHORT_DASH);
S1.SetStyle(Curve.SHORT_DASH);
S2.SetStyle(Curve.SHORT_DASH);
S3.SetStyle(Curve.SHORT_DASH);

def paintingStrategy = if timeframe == timeframe.WEEK then PaintingStrategy.DASHES else if timeFrame == timeFrame.MONTH or timeFrame == timeFrame."OPT EXP" then PaintingStrategy.DASHES else PaintingStrategy.DASHES;

PP.SetPaintingStrategy(paintingStrategy);
RR.SetPaintingStrategy(paintingStrategy);
R1.SetPaintingStrategy(paintingStrategy);
R2.SetPaintingStrategy(paintingStrategy);
R3.SetPaintingStrategy(paintingStrategy);
R4.SetPaintingStrategy(paintingStrategy);
SS.SetPaintingStrategy(paintingStrategy);
S1.SetPaintingStrategy(paintingStrategy);
S2.SetPaintingStrategy(paintingStrategy);
S3.SetPaintingStrategy(paintingStrategy);
S4.SetPaintingStrategy(paintingStrategy);


#####

Join the InvestorsHub Community

Register for free to join our community of investors and share your ideas. You will also get access to streaming quotes, interactive charts, trades, portfolio, live options flow and more tools.