/*[[ Name := MovingPivot Author := MojoFX Link := Notes := Separate Window := No First Color := Lime First Draw Type := Line First Symbol := 217 Use Second Data := Yes Second Color := Cyan Second Draw Type := Line Second Symbol := 218 ]]*/ input: formula(0); input: show_comment(1); input: how_long(-1); input: drw(1); //input: pPeriod(288); input: pPeriod(32); var: cnt(0); var: begin_bar(0); var: prev_day(0), cur_day(0); var: day_high(0); var: day_low(0); var: phigh(0); var: plow(0); var: pclose(0); var: textvar(""); var: P(0),S(0),R(0),S1(0),R1(0),S2(0),R2(0),S3(0),R3(0) ; var: pertama(true),prevbars(0); SetLoopCount(0); SetLoopCount(0); if bars1 then pertama=true; prevbars=bars; if pertama then begin_bar=bars-pPeriod; if formula < 0 or formula > 3 then exit; begin_bar+=1; for cnt = begin_bar downto 0 { pclose = CLOSE[cnt]; phigh=h[highest(MODE_HIGH,cnt+pPeriod-1,pPeriod)]; plow=l[lowest(MODE_LOW,cnt+pPeriod-1,pPeriod)]; P = (phigh + plow + pclose) / 3; if formula = 1 then { R = P + P - plow; S = P + P - phigh; } else if formula = 2 then { R = P + phigh - plow; S = P - phigh + plow; } else if formula = 3 then { R = P + P - plow - plow + phigh; S = P + P - phigh - phigh + plow; }; if formula = 0 then { SetIndexValue(cnt, P); } else { SetIndexValue(cnt, R); SetIndexValue2(cnt, S); }; begin_bar-=1; };