vraag aan Eric

Stel hier uw vragen over TA-script, of help anderen met het oplossen van hun probleem
Plaats reactie
metalernie
Berichten: 255
Lid geworden op: di feb 19, 2008 10:31 am

vraag aan Eric

Bericht door metalernie »

Hoi Eric, Ik gebruik onderstaande indicator van jou op de 5 minuut en nu heb ik een vraag en dat is kun je een filter inbouwen op basis van de macd 12-26-9 van de 30 minuut. Dus alleen longs als de macd meezit en shorts visa versa. Maar ik heb wel graag dat de orders afgesloten worden als de oscillator veranderd en eventueel opnieuw erin gaan mocht de macd nog hetzelfde staan.Alvast bedankt voor de moeite
___ #TT Ultimate ToSc (indicator) __________
{ My Trend Holy Grail }

[LegacyColorValue = true];

Inputs: {------------------------------------------------}
Price(Close),
Length(20), { Length for Average True Range (ATR) & Std. Deviation (SD) Calcs }
nK(1.5), { Keltner Channel ATRs from Average }
nBB(2), { Bollinger Band Std. Devs. from Average }
AlertLine( 1 ), { BBS_Index level at which to issue alerts }
AlertlColor( magenta); { Color for BBS_Ind below alert line }


Variables: {---------------------------------------------}
ATR(0), { Average True Range }
SDev(0), { Standard Deviation }
BBS_Ind(0), { Bollinger Band Squeeze Indicator }
alertTextID(-1),
Denom(0),
LHMult(0);



if ( barnumber=1 ) then
Begin
If minmove <> 0 then
LHMult = pricescale/minmove;
end;

if barnumber = 1 and alertTextID = -1 then
alertTextID = Text_New(date,time,0,"dummy");

{-- Calculate BB Squeeze Indicator ----------------------}
ATR = AvgTrueRange(Length);
SDev = StandardDev(Price, Length, 1);

Denom = (nK*ATR);
If Denom <> 0 then
BBS_Ind = (nBB * SDev) /Denom;

If BBS_Ind < Alertline then
Plot1(0, "BBS_Ind") else noplot(1);
//SetPlotColor(1, NormalColor);

{-- Plot the Index & Alert Line -------------------------}
//Plot1(0, "BBS_Ind");

{-- Plot delta of price from Donchian mid line ----------}
value2 = LinearRegValue(price-((Highest(H, Length)+Lowest(L, Length))/2
+ xAverage(c,Length))/2,Length,0);

var:color(0); //color = yellow;

if value2 > 0 then
if value2 > value2[1] then
color = blue
else
color = red;

if value2 < 0 then
if value2 < value2[1] then color = red
else
color = blue;

{-- Calculates the Macd to Define Trend Break -- }

Inputs: FastMA(5), SlowMA(13), MacdMA(1);
VAR:MA(0),XMA(0);

MA = MACD(Close, FastMA, SlowMA);
XMA = XAverage(MACD(Close, FastMA, SlowMA), MacdMA);
plot4(ma/2, "MADiff");
plot5(xma/2, "MAx");
if ma > 0 then setplotcolor(4,BLUE);
if ma < 0 then setplotcolor(4,red);


Plot3((value2{*LHMult}/10), "NickmNxtMove", color);
plot6(0,"ZeroLine");

{{-- Issue Alert when the Squeeze is On ------------------}
if BBS_Ind crosses below AlertLine
and Text_GetTime(alertTextID) <> time then
begin
text_setLocation(alertTextID, date, time, 0);
Alert("BB Squeeze Alert");
end;

{-- Issue Alert when the Squeeze Releases ---------------}
if BBS_Ind crosses above AlertLine
and Text_GetTime(alertTextID) <> time then
begin
text_setLocation(alertTextID, date, time, 0);
Alert("BB Squeeze Is Over");
end;
}

*)

var
Length, i, FastMA, SlowMA, MacdMA: integer;
nK, nBB, AlertLine: real;
ATR, SDev, BBS_Ind, Plot1, sMA, sXMA, sTemp, Value2: TSeries;
begin
{ Parameters }
Length := CreateParameterInteger('ATR/SDEV Length', 1, 999, 20, true);
nK := CreateParameterReal('Keltner factor', 0, 999, 1.5, true);
nBB := CreateParameterReal('BolBand factor', 0, 999, 2, true);
AlertLine := CreateParameterReal('Alertline', 0, 999, 1, true);
FastMA := CreateParameterInteger('Fast MA', 1, 999, 5, true);
SlowMA := CreateParameterInteger('Slow MA', 1, 999, 13, true);
MacdMA := CreateParameterInteger('Macd MA', 1, 999, 1, true);

{ Indicator eigenschappen }
with Indicator do
begin
RequiredBars := 5*Length;
end;

{ Berekening }
ATR := MA(TrueRange(High, Low, Close), maSimple, Length);
SDev := StdDev(Close, Length);

BBS_Ind := DivideSeries(MultiplySeriesBy(SDev, nBB), MultiplySeriesBy(ATR, nK));
Plot1 := CreateSeries(BarCount);
for i:=0 to BarCount-1 do
begin
if IsValid(BBS_Ind) and (BBS_Ind < AlertLine) then
Plot1 := 0;
end;

sMA := MACD(Close, FastMA, SlowMA);
sXMA := MA(sMA, maExponential, MacdMA);
for i:=FirstValidIndex(sMA) to BarCount-1 do
begin
if sMA > 0 then SetBarColor(0, i, clBlue) else // color MADiff
if sMA < 0 then SetBarColor(0, i, clRed);
end;

{-- Plot delta of price from Donchian mid line ----------}
// value2 = LinearRegValue(price-((Highest(H, Length)+Lowest(L, Length))/2
// + xAverage(c,Length))/2, Length, 0);
sTemp := DivideSeriesBy(AddSeries(HighSeries(High, Length), LowSeries(Low, Length)), 2);
sTemp := DivideSeriesBy(AddSeries(sTemp, MA(Close, maExponential, Length)), 2);
sTemp := SubtractSeries(Close, sTemp);
Value2 := MovingRegression(sTemp, Length);

for i:=FirstValidIndex(Value2)+1 to BarCount-1 do
begin
if Value2 > 0 then
begin
if Value2 > Value2[i-1] then
SetBarColor(2, i, clPurple)
else
SetBarColor(2, i, clYellow);
end else
if Value2 < 0 then
begin
if Value2 < Value2[i-1] then
SetBarColor(2, i, clYellow)
else
SetBarColor(2, i, clPurple);
end else
end;

with CreateLine(DivideSeriesBy(sMA, 2)) do // 0
begin
Color := clWhite;
Name := 'MADiff';
LineType := ltBar;
end;
with CreateLine(DivideSeriesBy(sXMA, 2)) do // 1
begin
Color := clWhite;
Name := 'MAx';
LineType := ltClose;
Visible := false;
end;
with CreateLine(DivideSeriesBy(Value2, 10)) do // 2
begin
Color := clWhite;
Name := 'NickmNxtMove';
LineType := ltDot;
Width := 2;
end;
with CreateLine(Plot1) do // 3
begin
Color := clWhite;
Name := 'BBS_Ind';
LineType := ltDot;
Width := 2;
end;
end.
Plaats reactie