|
Prag/czechrepublic
Experience: Intermediate
Platform: Multicharts, NinjaTrader
Broker: IB
Trading: Currency
Posts: 3 since Jan 2014
Thanks Given: 0
Thanks Received: 1
|
Helo,
i have one script Pivot points
For day is formula:
......
if date <> date[1] then begin
....
for month is
...
if month(date) <> month(date)[1] then begin
...
but for week do not work. you have any idea how to do it:
Complete script:
--------------------------------------------------------------------
inputs:
StartCalcTime (0000),
EndCalcTime (2359),
PlaceTextRight (true),
PlotDateChange (true),
PlotToDateEnd (true),
IgnoreWeekends (true),
PivColor (yellow),
R1Color (Red),
R2Color (Red),
R3Color (Red),
S1Color (green),
S2Color (green),
S3Color (green),
TLSize (2),
TLStyle (2);
Variables:
Monday2Friday (false),
RR1 (0),
RR2 (0),
RR3 (0),
SS1 (0),
SS2 (0),
SS3 (0),
PP (0),
RR1TL (0),
RR2TL (0),
RR3TL (0),
SS1TL (0),
SS2TL (0),
SS3TL (0),
PPTL (0),
DayHi (-999999),
DayLo (+999999),
HaveTLs (false),
StartTime (0),
EndTime (0),
R1Txt (0),
R2Txt (0),
R3Txt (0),
S1Txt (0),
S2Txt (0),
S3Txt (0),
PPTxt (0),
SessClose (0),
TextStylehoriz (1),//0,1,2
TextStyleVert (2);//0,1,2
if IgnoreWeekends then begin
if dayofweek(date) >= monday and dayofweek(date) <=friday then
Monday2Friday=True
else
Monday2Friday=false;
end
else begin
Monday2Friday = True;
end;
if Monday2Friday then begin
if week(date)<> week(date)[1] then begin
if PlaceTextRight then
TextStyleVert = 1;
if PlotDateChange then
starttime = Time
else
starttime = StartCalcTime;
endtime = time[1];
PP = (DayHi+DayLo+SessClose[1])/3;
RR1 = PP*2 - DayLo;
RR2 = PP + (DayHi - DayLo);
RR3 = DayHi + 2*(PP-DayLo);
SS1 = (PP*2) - DayHi;
SS2 = PP - (DayHi - daylo);
SS3 = dayLo - 2*(DayHi-PP);
dayhi = -999999;
Daylo = +999999;
HaveTLs = false;
end;
if time > StartCalcTime and time <= EndCalcTime then begin
if High >= dayhi then dayhi = High;
if Low <=daylo then daylo=Low;
SessClose=close;
end;
if HaveTLs = false then begin
HaveTLs = true;
RR1TL = tl_new (date, starttime, RR1, date, endtime, RR1);
tl_setcolor(rr1TL, R1color);
tl_setsize(RR1TL, TLSize);
tl_setstyle(rr1tl, tlstyle);
RR2TL = tl_new (date, starttime, RR2, date, endtime, RR2);
tl_setcolor(rr2TL, R2color);
tl_setsize(RR2TL, TLSize);
tl_setstyle(rr2tl, tlstyle);
RR3TL = tl_new (date, starttime, RR3, date, endtime, RR3);
tl_setcolor(rr3TL, R3color);
tl_setsize(RR3TL, TLSize);
tl_setstyle(rr3tl, tlstyle);
SS1TL = tl_new (date, starttime, SS1, date, endtime, SS1);
tl_setcolor(SS1TL, S1color);
tl_setsize(SS1TL, TLSize);
tl_setstyle(SS1tl, tlstyle);
SS2TL = tl_new (date, starttime, SS2, date, endtime, SS2);
tl_setcolor(SS2TL, S2color);
tl_setsize(SS2TL, TLSize);
tl_setstyle(SS2tl, tlstyle);
SS3TL = tl_new (date, starttime, SS3, date, endtime, SS3);
tl_setcolor(SS3TL, S3color);
tl_setsize(SS3TL, TLSize);
tl_setstyle(SS3tl, tlstyle);
PPTL = tl_new (date, starttime, PP, date, endtime, PP);
tl_setcolor(PPTL, Pivcolor);
tl_setsize(PPTL, TLSize);
tl_setstyle(PPtl, tlstyle);
R1Txt = text_new(Date, Starttime, RR1,"R1 W");
Text_setstyle(R1Txt,Textstylehoriz, textstylevert);
text_setcolor(R1Txt, R1Color);
R2Txt = text_new(Date, Starttime, RR2,"R2 W");
Text_setstyle(R2Txt,Textstylehoriz, textstylevert);
text_setcolor(R2Txt, R2Color);
R3Txt = text_new(Date, Starttime, RR3,"R3 W");
Text_setstyle(R3Txt,Textstylehoriz, textstylevert);
text_setcolor(R3Txt, R3Color);
S1Txt = text_new(Date, Starttime, SS1,"S1 W");
Text_setstyle(S1Txt,Textstylehoriz, textstylevert);
text_setcolor(S1Txt, S1Color);
S2Txt = text_new(Date, Starttime, SS2,"S2 W");
Text_setstyle(S2Txt,Textstylehoriz, textstylevert);
text_setcolor(S2Txt, S2Color);
S3Txt = text_new(Date, Starttime, SS3,"S3 W");
Text_setstyle(S3Txt,Textstylehoriz, textstylevert);
text_setcolor(S3Txt, S3Color);
PPTxt = text_new(Date, Starttime, PP,"PP W");
Text_setstyle(PPTxt,Textstylehoriz, textstylevert);
text_setcolor(PPTxt, PivColor);
end
else begin
if plottodateend then
endtime = EndTime
else
endtime = EndCalcTime;
TL_setend(RR1TL, date, endtime, RR1);
TL_setend(RR2TL, date, endtime, RR2);
TL_setend(RR3TL, date, endtime, RR3);
TL_setend(SS1TL, date, endtime, SS1);
TL_setend(SS2TL, date, endtime, SS2);
TL_setend(SS3TL, date, endtime, SS3);
TL_setend(PPTL, date, endtime, PP);
if PlaceTextRight then begin
text_setlocation(R1Txt, date, endTime, RR1);
text_setlocation(R2Txt, date, endTime, RR2);
text_setlocation(R3Txt, date, endTime, RR3);
text_setlocation(S1Txt, date, endTime, SS1);
text_setlocation(S2Txt, date, endTime, SS2);
text_setlocation(S3Txt, date, endTime, SS3);
text_setlocation(PPTxt, date, endTime, PP);
end;
end;
end;
if 0=1 then
begin
plot1(PP,"PP",PivColor,TLSize);
end
else begin
Noplot(1);
end;
|