Not being a programmer, I came across a situation that I can't figure out..
I have a study that plots from the times 0100 to 0700, AFTER 0700, I want to remove the old study and replace it with a new one...
How can I turn the "status off " of a study or erase its previous plot completely ??
Would trendlines be a better way ?
Re-Plotting High of the Day
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2223 times
Re: Erasing existing plot lines
It depends.Not being a programmer, I came across a situation that I can't figure out..
I have a study that plots from the times 0100 to 0700, AFTER 0700, I want to remove the old study and replace it with a new one...
How can I turn the "status off " of a study or erase its previous plot completely ??
Would trendlines be a better way ?
If it is a straight line, a Trendline drawing object might be easier.
Otherwise you can use a loop to re-plot everything in the past.
-
- Posts: 742
- Joined: 09 Apr 2010
- Location: Texas
- Has thanked: 483 times
- Been thanked: 274 times
- Contact:
Re: Erasing existing plot lines
Yes, TJ, a straight line..
Basically, I'm trying to capture the "developing" high and low of a session, then, when the session is over and the high and low has been determined.. erase the developing high and low ...and replace it with the final high and low of the session.
Thanks TJ ..
Basically, I'm trying to capture the "developing" high and low of a session, then, when the session is over and the high and low has been determined.. erase the developing high and low ...and replace it with the final high and low of the session.
Thanks TJ ..
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Erasing existing plot lines
Indicator lines cannot be turned off, Henry said here so something like `NoPlot()` will not help.How can I turn the "status off " of a study or erase its previous plot completely ??
Would trendlines be a better way ?
You can use Abort to turn off the study, but this would require that you manually re-enable the indicator each time it has been turned off (which can become a pain if you have a lot of charts).
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Erasing existing plot lines
One way to do that is with a Plot that displays the developing high (or low) and is replaced with the final high (or low) when the session has ended (with a loop, like TJ said).Basically, I'm trying to capture the "developing" high and low of a session, then, when the session is over and the high and low has been determined.. erase the developing high and low ...and replace it with the final high and low of the session.
For example:
Code: Select all
Variables:
highOfSession(0),
sessionEndingTime(180000), // 18:00:00
x(0);
if (BarStatus(1) = 2) then begin
highOfSession = MaxList(highOfSession, High);
if (Time_s < sessionEndingTime) then
Plot1(highOfSession);
if (Time_s[1] < sessionEndingTime and
Time_s >= sessionEndingTime) then begin
for x = 100 downto 0 begin
if (Date[x] = Date) then
Plot1[x](highOfSession);
end;
highOfSession = 0;
end;
end;
When the session has ended (after 18:00 in the code example), the plot becomes:
Is this what you meant?
- Attachments
-
- scr.25-11-2014 11.07.31.png
- (5.94 KiB) Downloaded 1979 times
-
- scr.25-11-2014 11.07.09.png
- (6.25 KiB) Downloaded 1968 times
-
- Posts: 742
- Joined: 09 Apr 2010
- Location: Texas
- Has thanked: 483 times
- Been thanked: 274 times
- Contact:
Re: Erasing existing plot lines
JoshM: Yes, that is EXACTLY what I meant, thanks so much for the very "elegant" solution !!
You saved me many hours of trial and error, figuring that out..
You saved me many hours of trial and error, figuring that out..
-
- Posts: 196
- Joined: 08 Aug 2012
- Has thanked: 41 times
- Been thanked: 41 times
Re: Re-Plotting High of the Day
josh
could that be used to plot OHLC of previous day based on a certain session instead of relying on the session template under instrument formatting ?
I would like to use a regular globex session for the charting, but show the OHLC of pit session for crude.
09:00 - 14:30
could your code be used to do that ?
shane
could that be used to plot OHLC of previous day based on a certain session instead of relying on the session template under instrument formatting ?
I would like to use a regular globex session for the charting, but show the OHLC of pit session for crude.
09:00 - 14:30
could your code be used to do that ?
shane
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Re-Plotting High of the Day
Like this?could that be used to plot OHLC of previous day based on a certain session instead of relying on the session template under instrument formatting ?
I would like to use a regular globex session for the charting, but show the OHLC of pit session for crude.
09:00 - 14:30
Here the previous day OHLC of the pit session are plotted as soon as the new pit session begins (see the vertical lines that highlight the pit sessions).
Code: Select all
Inputs:
SessionStart(900),
SessionEnd(1430);
Variables:
highOfPrevSession(0),
lowOfPrevSession(0),
closeOfPrevSession(0),
openOfPrevSession(0),
highThisSession(0),
lowThisSession(0),
closeThisSession(0),
openThisSession(0),
startTime(SessionStart * 100),
endTime(SessionEnd * 100);
if (BarStatus(1) = 2) then begin
// Reset variables
if (Time_s[1] < startTime) and
(Time_s >= startTime) then begin
highOfPrevSession = lowThisSession;
lowOfPrevSession = highThisSession;
openOfPrevSession = openThisSession;
closeOfPrevSession = closeThisSession;
lowThisSession = 9999;
highThisSession = 0;
end;
if (Time_s[1] < startTime) and (Time_s >= startTime) then
openThisSession = Open;
if (Time_s[1] < endTime) and (Time_s >= endTime) then
closeThisSession = Close;
// Only collect high and low during custom
// session; only works when this session doesn't
// span midnight
if (Time_s >= startTime) and
(Time_s <= endTime) then begin
highThisSession = MaxList(highThisSession, High);
lowThisSession = MinList(lowThisSession, Low);
end;
Plot1(highOfPrevSession, "High");
Plot2(lowOfPrevSession, "Low");
Plot3(openOfPrevSession, "Open");
Plot4(closeOfPrevSession, "Close");
end;
- Attachments
-
- previousPitSessionOHLC.pla
- (5.65 KiB) Downloaded 680 times
-
- scr.26-11-2014 11.06.11.png
- (13.67 KiB) Downloaded 1939 times
-
- Posts: 196
- Joined: 08 Aug 2012
- Has thanked: 41 times
- Been thanked: 41 times
Re: Re-Plotting High of the Day
hey !
thats fantastic !
Excellent work Josh !
Thank you for your efforts, this is a great piece of coding.
sincerely,
Shane
thats fantastic !
Excellent work Josh !
Thank you for your efforts, this is a great piece of coding.
sincerely,
Shane