Pi cycle

Stel hier uw vragen over TA-script, of help anderen met het oplossen van hun probleem
Plaats reactie
petdev
Berichten: 128
Lid geworden op: wo jun 12, 2013 4:25 pm

Pi cycle

Bericht door petdev »

Beste Eric,

Ik kwam onlangs deze indicator tegen met diverse MA-instellingen.
Zou je eens kunnen kijken of deze in TA-script te vertalen is?
Input svp variabel maken ipv vastgelegd in script; zowel MA's als vermenigvuldigingsfactoren lang/kort-MA.
Bron:
https://se.tradingview.com/script/tftQi ... Indicator/

------------------------------------------
//@version=5

indicator("Pi-Cycle Bottom, Top, & Improved Top in One Indicator", "Pi-Cycle Bottom, Top, & Improved Top", overlay=true)

xPrice = close


// Improved Pi-Cycle Top Indicator, BitcoinMamo and Mark Lefevre//
x569 = ta.sma(xPrice,569)*2.77*5
x126 = ta.sma(xPrice, 126)*5


plot(x569, title="MA 569 * 2.77",color=color.red,linewidth=1)
plot(x126, title="MA 126",color=color.red, linewidth=1)

plotshape(series=ta.crossover(x126,x569),style=shape.arrowup,color=color.red,location=location.top,size=size.huge)


x1=close

// Original Pi-Cycle Top Indicator Philip Swift//
x350 = ta.sma(x1,350)*2.0/5
x111 = ta.sma(x1, 111)/5


plot(x350, title="MA 350 * 2",color=color.green,linewidth=1)
plot(x111, title="MA 111",color=color.green, linewidth=1)

plotshape(series=ta.crossunder(x350,x111),style=shape.arrowup,color=color.green,location=location.bottom,size=size.huge)



// Original Pi-Cycle Bottom Indicator PlanC//
x471 = ta.sma(x1,471)*0.745/20
x150 = ta.ema(x1,150)/20


plot(x471, title="MA 471 * 0.745",color=color.blue,linewidth=1)
plot(x150, title="EMA 150",color=color.blue, linewidth=1)

plotshape(series=ta.crossover(x471,x150),style=shape.arrowup,color=color.blue,location=location.bottom,size=size.huge)
Eric
Berichten: 3536
Lid geworden op: za sep 10, 2005 2:41 am
Locatie: Den Haag

Re: Pi cycle

Bericht door Eric »

Ik heb een poging gewaagd. Je moet de schaal wel op logaritmisch zetten om hetzelfde beeld te krijgen.

Code: Selecteer alles

{- Filename: PI cycle -}

procedure PlotLine(x: real; AColor: TColor);
begin
  with CreateTrendLine(x, 0, x, 0) do
  begin
    Y1Pct := 0;
    Y2Pct := 100;
    Color := AColor;
    Width := 1;
  end;
end;

var
  nMA1a, nMA2a, nMA1b, nMA2b, nMA1c, nMA2c: integer;
  nFactor1a, nFactor2a, nFactor1b, nFactor2b, nFactor1c, nFactor2c: real;
  sMA1a, sMA2a, sMA1b, sMA2b, sMA1c, sMA2c: TSeries;
  x1, x2, x3: TLineCrossings;
  i: integer;
begin
{ Parameters }
  nMA1a := CreateParameterInteger('MA periode 1a', 1, 9999, 569, true);
  nFactor1a := CreateParameterReal('MA factor 1a', 1, 9999, 2.77*5, true);
  nMA2a := CreateParameterInteger('MA periode 2a', 1, 9999, 126, true);
  nFactor2a := CreateParameterReal('MA factor 2a', 1, 9999, 5, true);

  nMA1b := CreateParameterInteger('MA periode 1b', 1, 9999, 350, true);
  nFactor1b := CreateParameterReal('MA factor 1b', 1, 9999, 2.0/5, true);
  nMA2b := CreateParameterInteger('MA periode 2b', 1, 9999, 111, true);
  nFactor2b := CreateParameterReal('MA factor 2b', 1, 9999, 1/5, true);

  nMA1c := CreateParameterInteger('MA periode 1c', 1, 9999, 471, true);
  nFactor1c := CreateParameterReal('MA factor 1c', 1, 9999, 0.745/20, true);
  nMA2c := CreateParameterInteger('EMA periode 2c', 1, 9999, 150, true);
  nFactor2c := CreateParameterReal('EMA factor 2c', 1, 9999, 1/20, true);

{ Indicator eigenschappen }
  with Indicator do 
  begin
    RequiredBars := nMA1a+nMA2a+nMA1b+nMA2b+nMA1c+nMA2c;
    NewBand := false;
    ScaleRange := srCommon;
  end;

{ Berekening }
  sMA1a := MultiplySeriesBy(MA(Close, maSimple, nMA1a), nFactor1a);
  sMA2a := MultiplySeriesBy(MA(Close, maSimple, nMA2a), nFactor2a);
  sMA1b := MultiplySeriesBy(MA(Close, maSimple, nMA1b), nFactor1b);
  sMA2b := MultiplySeriesBy(MA(Close, maSimple, nMA2b), nFactor2b);
  sMA1c := MultiplySeriesBy(MA(Close, maSimple, nMA1c), nFactor1c);
  sMA2c := MultiplySeriesBy(MA(Close, maExponential, nMA2c), nFactor2c);

{ Signalen }
  x1 := Crossings(sMA1a, sMA2a);
  x2 := Crossings(sMA1b, sMA2b);
  x3 := Crossings(sMA1c, sMA2c);
  for i:=0 to BarCount-1 do
  begin
    if x1[i] = lc2Over1 then PlotLine(BarPosition[i], clRed);
    if x2[i] = lc2Over1 then PlotLine(BarPosition[i], RGB(0,128,0));
    if x3[i] = lc1Over2 then PlotLine(BarPosition[i], RGB(0,0,255));
  end;

{ Weergave }
  with CreateLine(sMA1a) do
  begin
    Name := 'MA1a';
    Color := clRed;
  end;
  with CreateLine(sMA2a) do
  begin
    Name := 'MA2a';
    Color := clRed;
  end;
  with CreateLine(sMA1b) do
  begin
    Name := 'MA1b';
    Color := RGB(0,128,0);
  end;
  with CreateLine(sMA2b) do
  begin
    Name := 'MA2b';
    Color := RGB(0,128,0);
  end;
  with CreateLine(sMA1c) do
  begin
    Name := 'MA1c';
    Color := RGB(0,0,255);
  end;
  with CreateLine(sMA2c) do
  begin
    Name := 'MA2c';
    Color := RGB(0,0,255);
  end;
end.
btc.GIF
---
Eric
petdev
Berichten: 128
Lid geworden op: wo jun 12, 2013 4:25 pm

Re: Pi cycle

Bericht door petdev »

Eric,

Dank weer voor de snelle service.
Ziet er goed en flexibel uit.

Groet, Peter
Plaats reactie