| Coding Forum Collaborate, receive help, or discuss coding related issues. |
![]() | | Tweet | |
| | #1 | ||
![]() | Making Pivots These pivots give me S1-5 R1-5 Prev - open, close, high, low. But i need daily, weekly and monthly now! Is this a big coding task or is it possible to change the code i have, i can post the code if need be? | ||
| |
|
| | #2 | ||
![]() | Re: Making Pivots if you don't share what you have, I doubt you can entice/encourage/prompt people to share what they have... such is the life on the internet. . Last edited by Tams; 07-09-2009 at 11:49 AM. | ||
| |
|
| | #3 | ||
![]() | Re: Making Pivots Take a look at this post and see if it helps you. http://www.traderslaboratory.com/for...html#post70460 Regards, Antonio | ||
| |
|
| | #4 | ||
![]() | Re: Making Pivots Paul | ||
| |
|
| | #5 | ||
![]() | Re: Making Pivots | ||
| |
|
| | #6 | ||
![]() | Re: Making Pivots Is there a way to edit this code to change from weekly to monthly? I can change all the labels and values but what needs changing in the formula? Code: [LegacyColorValue = true];
input: PivotType(0),
BarsBack(60),
ShowOpen(0),
ShowClose(0),
ShowHalfPivots(0),
ShowLevel(0),
WeeksAgo(1),
NewDayTM(1510),
RoundLevels(false),
DecPlaces(2),
SupResType(0);
var: theday(0);
var: cnt(0),Maxcnt(11);
array:
TL[12](-1),Val[12](-1),
Color[12](6),Label[12]("L"),FTextID[12](-1), TLabel[12](" ");
var: sdate(0),stime(0),fPivot(0),twOpen(0),theRange(0);
if lastbaronchart then begin
if dayofweek(date) >= 5 and time >= NewDayTM
then theday = 0 else theday = 1;
theday = theday + WeeksAgo-1;
if theday <= 0 then begin
theday = 0;
twOpen = 0;
end else twopen = theday-1;
Val[10] = CloseW(theday);
if PivotType >0 and PivotType <4 then Val[11] = OpenW(twopen) else Val[11] = OpenW(theday);
if PivotType = 1 then fPivot = (HighW(theday) + LowW(theday) + Val[11]) /3
else if PivotType = 2 then fPivot = (HighW(theday) + LowW(theday) + Val[11] + Val[11]) /4
else if PivotType = 3 then fPivot = (HighW(theday) + LowW(theday) + Val[10] + Val[11]) /4
else if PivotType = 4 then fPivot = (HighW(theday) + LowW(theday) + Val[10] + Val[11]) /4
else fPivot = (HighW(theday) + LowW(theday) + Val[10]) /3;
if SupResType = 1 then begin
theRange = (HighW(theday) - LowW(theday))/2;
VAl[1] = fPivot;
VAl[2] = fPivot + theRange; {R1}
VAl[3] = fPivot - theRange; {S1}
VAl[4] = VAl[2] + theRange; {R2}
VAl[5] = VAl[3] - theRange; {S2}
VAl[6] = VAl[4] + theRange; {R3}
VAl[7] = VAl[5] - theRange; {S3}
VAl[8] = VAl[6] + theRange; {R4}
VAl[9] = VAl[7] - theRange; {S4}
end
else begin
VAl[1] = fPivot;
VAl[2] = fPivot + fPivot - LowW(theday); {R1}
VAl[3] = fPivot + fPivot - HighW(theday); {S1}
VAl[4] = fPivot + VAl[2] - VAl[3]; {R2}
VAl[5] = fPivot - VAl[2] + VAl[3]; {S2}
VAl[6] = fPivot + VAl[4] - VAl[3]; {R3}
VAl[7] = fPivot - VAl[4] + VAl[3]; {S3}
VAl[8] = fPivot + VAl[4] - VAl[5]; {R4}
VAl[9] = fPivot - VAl[4] + VAl[5]; {S4}
end;
if RoundLevels then begin
for cnt = 1 to 11 begin
val[cnt] = roundInst(val[cnt]);
end;
end;
Color[1] = White;
Color[2] = red;
Color[3] = green;
Color[4] = red;
Color[5] = green;
Color[6] = red;
Color[7] = green;
Color[8] = red;
Color[9] = green;
Color[10] = Yellow;
Color[11] = DarkBrown;
TLabel[1] = "Weekly Pivot - ";
TLabel[2] = "Weekly R1 - ";
TLabel[3] = "Weekly S1 - ";
TLabel[4] = "Weekly R2 - ";
TLabel[5] = "Weekly S2 - ";
TLabel[6] = "Weekly R3 - ";
TLabel[7] = "Weekly S3 - ";
TLabel[8] = "Weekly R4 - ";
TLabel[9] = "Weekly S4 - ";
TLabel[10] = "Weekly Close - ";
TLabel[11] = "Weekly Open - ";
sdate = Date[BarsBack];
stime = Time[BarsBack];
for cnt= 1 to Maxcnt begin
if cnt < 10 or (ShowClose <> 0 and cnt = 10) or (ShowOpen <> 0 and cnt = 11) then begin
if TL[cnt] < 0 then begin {dosn't exist, create new TL}
TL[cnt] = TL_New (sdate, stime, Val[cnt],
date, time , Val[cnt]);
TL_SetColor (TL[cnt], Color[cnt]);
if cnt >= 10 then TL_SetStyle (TL[cnt], Tool_Dotted)
else TL_SetStyle (TL[cnt], Tool_Dotted);
end;
if TL_Exist(TL[cnt]) then begin {exist}
TL_SetEnd (TL[cnt], date, time , Val[cnt]);
TL_SetBegin (TL[cnt], sdate, stime, Val[cnt]); {reset TL}
TL_SetExtRight(TL[cnt],true);
end;
{do text stuff}
if FTextID[cnt] < 0 then begin {is new}
FTextID[cnt] = Text_New(sdate, stime, Val[cnt], "zzz");
Text_SetStyle(FTextID[cnt], 1, 2);
Text_SetColor(FTextID[cnt], Color[cnt]);
end;
if FTextID[cnt] >= 0 then begin {already exists}
Text_SetLocation(FTextID[cnt], sdate, stime, Val[cnt]);
Text_SetString(FTextID[cnt],TLabel[cnt] + NumToStr(Val[cnt], DecPlaces) + " " );
end;
end; {count < 6, etc.}
end; {cnt}
Array: HalfTL[9](-1),HalfVal[9](0),HTextID[9](-1);
{could be off a hair if RoundLevels is used, cause these would be based on rounded numbers}
if ShowHalfPivots <> 0 then begin
HalfVal[1] = ((Val[4] - Val[2])/2) + Val[2];
HalfVal[2] = ((Val[2] - Val[1])/2) + Val[1];
HalfVal[3] = ((Val[1] - Val[3])/2) + Val[3];
HalfVal[4] = ((Val[3] - Val[5])/2) + Val[5]; {s1-s2}
HalfVal[5] = ((Val[4] - Val[6])/2) + Val[6];
HalfVal[6] = ((Val[5] - Val[7])/2) + Val[7]; {s2-s3}
HalfVal[7] = ((Val[6] - Val[8])/2) + Val[8];
HalfVal[8] = ((Val[7] - Val[9])/2) + Val[9]; {s3-s4}
if RoundLevels then begin
for cnt = 1 to 8 begin
HalfVal[cnt] = roundInst(HalfVal[cnt]);
end;
end;
for cnt= 1 to 8 begin
if HalfTL[cnt] < 0 then begin {dosn't exist, create new TL}
HalfTL[cnt] = TL_New (sdate, stime, HalfVal[cnt],
date, time , HalfVal[cnt]);
TL_SetColor (HalfTL[cnt], DarkGray);
TL_SetStyle (HalfTL[cnt], Tool_Dotted);
end;
if TL_Exist(HalfTL[cnt]) then begin {exist}
TL_SetEnd (HalfTL[cnt], date, time , HalfVal[cnt]);
TL_SetBegin (HalfTL[cnt], sdate, stime, HalfVal[cnt]); {reset TL}
TL_SetExtRight(HalfTL[cnt],true);
end;
{do text stuff}
if HTextID[cnt] < 0 then begin {is new}
HTextID[cnt] = Text_New(sdate, stime, HalfVal[cnt], "zzz");
Text_SetStyle(HTextID[cnt], 1, 2);
Text_SetColor(HTextID[cnt], DarkGray);
end;
if HTextID[cnt] >= 0 then begin {already exists}
Text_SetLocation(HTextID[cnt], sdate, stime, HalfVal[cnt]);
Text_SetString(HTextID[cnt], NumToStr(HalfVal[cnt], DecPlaces) + " " );
end;
end; {cnt}
end; {ShowHalfPivots}
{think HalfTL resets to -1 is automatic, when inputs changed, so no need to do here}
end; {last bar}
{default color for 2,3 is black. Change in properties, if not using a black background}
if ShowLevel > 0 and ShowLevel <= 4 then begin
noplot(2);
noplot(3);
if ShowLevel = 1 then begin
Plot2[-1](Val[2] + .5,"h");
Plot3[-1](Val[3] - .5,"l");
end
else if ShowLevel = 2 then begin
Plot2[-1](Val[4] + .5,"h");
Plot3[-1](Val[5] - .5,"l");
end
else if ShowLevel = 3 then begin
Plot2[-1](Val[6] + .5,"h");
Plot3[-1](Val[7] - .5,"l");
end
else if ShowLevel = 4 then begin
Plot2[-1](Val[8] + .5,"h");
Plot3[-1](Val[9] - .5,"l");
end;
end; Chris | ||
| |
|
![]() |
| Thread Tools | |
| Display Modes | Help Others By Rating This Thread |
| |
| ∧ Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Making It | Tams | Books | 5 | 05-28-2009 10:14 AM |
| Making TS Plot Wider | daedalus | Coding Forum | 14 | 04-23-2009 10:37 AM |
| Making 5 Posts [Disregard] | Leecifer | Support Center | 2 | 12-05-2007 08:47 PM |
| Anyone here making $100K+ | carcanaques | General Discussion | 9 | 10-27-2007 09:30 AM |
| Your ODDS of Making It | rwalkerx | Beginners Forum | 2 | 12-06-2006 01:24 PM |