Hi,
With try and error I found out the following:
I replaced ==> LastBarOnChart=date=today
with ==> Daylastbar=date=today //true if last bar on daychart is today – most right one on the chart
Weeklastbar=date-dayofweek+1=today //true if last bar on weekchart is this week – most right one on the chart
Monthlastbar=date-day+1=today //true if last bar on monthchart is this month- most right one on the chart
And used these variables in the “if” conditions. => Are these calculations, to check if the most right bar in the day, week or month chart is the last one available (EOF) and therefore Today, correct??
So the code becomes as follows:
Once SwingPointer=4
Daylastbar=date=today
Weeklastbar=date-dayofweek+1=today
Monthlastbar=date-day+1=today
//continue swing Up
if UpCount>0 and Close>Close[SwingPointer] then
DownCount=0
UpCount=UpCount+1
//Draw Full Upswing (9 downto 1) or draw Ongoing Upswing if Last bar on chart
if UpCount=9 or Daylastbar or Weeklastbar or Monthlastbar then
BarPointer=0
for SwingNr=Upcount downto 1 do
drawtext("#SwingNr#",barindex-BarPointer,high[BarPointer]+CountDistance*pointsize,Dialog,Bold,16) coloured(0,0,250)
BarPointer=BarPointer+1
next
last9bar=barindex
//Reset UpSwing Counter
UpCount=0
endif
//Failed UpSwing
elsif UpCount>0 and Close<Close[SwingPointer] then
//Reset UpSwing Counter
UpCount=0
endif
//Continue DownSwing
if DownCount>0 and Close<Close[SwingPointer] then
UpCount=0
DownCount=DownCount+1
//Draw Full Downswing (9 downto 1) or draw Ongoing DownSwing if Last bar on chart
if DownCount=9 or Daylastbar or Weeklastbar or Monthlastbar then
BarPointer=0
for SwingNr=DownCount downto 1 do
drawtext("#SwingNr#",barindex-BarPointer,low[BarPointer]-CountDistance*pointsize,Dialog,Bold,16) coloured(255,0,0)
BarPointer=BarPointer+1
next
last9bar=barindex
//Reset DownSwing Counter
DownCount=0
endif
//Failed DownSwing
elsif DownCount>0 and Close>Close[SwingPointer] then
//Reset DownSwing Counter
DownCount=0
endif
//Begin Upswing
if UpCount=0 and barindex-last9bar>1 then
if close>close[SwingPointer] then
UpCount=1
DownCount=0
if Daylastbar or Weeklastbar or Monthlastbar then
//Draw Start of UpSwing (only Today's bar)
drawtext("1",barindex,high+CountDistance*pointsize,Dialog,Bold,16) coloured(0,0,250)
endif
endif
endif
//Begin Downswing
if DownCount=0 and barindex-last9bar>1 then
if close<close[SwingPointer] then
DownCount=1
UpCount=0
if Daylastbar or Weeklastbar or Monthlastbar then
//Draw Start of DownSwing (only Today's bar)
drawtext("1",barindex,low-CountDistance*pointsize,Dialog,Bold,16) coloured(255,0,0)
endif
endif
endif
return