Clock

#1
Hello,

I have the following AFL to measure the remaining time of the candle.


function GetSecondNum()
{
Time = Now( 4 );
Seconds = int( Time % 100 );
Minutes = int( Time / 100 % 100 );
Hours = int( Time / 10000 % 100 );
SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
return SecondNum;
}

RequestTimedRefresh( 1 );
TimeFrame = Interval();
SecNumber = GetSecondNum();
SecsLeft = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
SecsToGo = TimeFrame - SecsLeft;
Secsleft = SecsToGo % 60 ;
Minleft = int( SecsToGo / 60 );
Time = "\\c06 " + Minleft + "\\c06 :" + "\\c06 " + Secsleft ;


I need one alarms 10 seconds before the time finalizes.
At the moment the clock leaves in the high part the diagram in the left end. As I can move it to the right part of the graph.
Somebody can help me. Thank you very much.

Greetings,
 
#2
hi
add these lines below your formula

sec10=IIf(Minleft<1AND Secsleft<10,1,0); // <<== where is 10 means 10 sec

secColor=WriteIf(sec10==1,"\\c08 ","\\c06 ");
Title = "\\c06 " + Minleft + " :" + secColor+ Secsleft ;


and for alarm maybe you can use

if( sec10==1 ) Plot(1,"",colorDarkOliveGreen ,styleArea|styleOwnScale,0,1,0,-5);
OR you can use
if( Minleft<1 AND Secsleft <20 AND Secsleft >18 ) Say(".. @. 20 sec Get Ready"); // @ 20 sec get ready
 
Last edited:
#3
Hello,

Thank you very much by the answer.

The clock appears in the margin left superior of the graph.
That I must do so that appears in the margin right superior. That code AFL I must use. It is possible. Thanks again.

Greetings,
 
#4
where in the right side, top or bottom ?

there are 3 ways (that i know) to see TEXT in the right of your chart
1) PlotText 2) GFX Functions 3) Title= " ";

the flowing is with PlotText, and if you put your formula into an indicator chart then its easy to add also those 3 lines

Code:
MinleftSTR=NumToStr(Minleft,1);  SecsleftSTR=NumToStr(Secsleft ,1); 
// where is 50 is the Y and you have to adjust it ([B]also  read the manual for PlotText[/B]( ''text'', x, y, color, bkcolor = colorDefault ) 
 PlotText(MinleftSTR+":"+SecsleftSTR, BarCount + 1, 50, colorBlack, IIf(sec10,colorYellow,colorWhite));

enjoy it
 
Last edited:
#6
when I added the code(clock) bars disappeared from chart.Am I missing something?
i wrote:
the flowing is with PlotText, and if you put your formula into an indicator chart then its easy to add also those 3 lines

that means for you that you like to put the formula in bar chart it is better to skip the plottext line

maybe later if i have time, i will make my own Gfx Clock formula and will go in any chart
for now lets see what Jose Mary will say.
 
#7
Hello,

There am addition 3 lines AFL, but not with himself what I try.
I have modified the numbers to see if it managed to move the clock towards the right, but this ne does not move.
I pass the AFL to you I have as it

function GetSecondNum()
{
Time = Now( 4 );
Seconds = int( Time % 100 );
Minutes = int( Time / 100 % 100 );
Hours = int( Time / 10000 % 100 );
SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
return SecondNum;
}

RequestTimedRefresh( 1 );
TimeFrame = Interval();
SecNumber = GetSecondNum();
SecsLeft = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
SecsToGo = TimeFrame - SecsLeft;
Secsleft = SecsToGo % 60 ;
Minleft = int( SecsToGo / 60 );
Time = "\\c06 " + Minleft + "\\c06 :" + "\\c06 " + Secsleft ;
sec10=IIf(Minleft<1AND Secsleft<10,4,0); // <<== where is 10 means 10 sec

secColor=WriteIf(sec10==1,"\\c08 ","\\c06 ");
Title = "\\c06 " + Minleft + " :" + secColor+ Secsleft ;

MinleftSTR=NumToStr(Minleft,1); SecsleftSTR=NumToStr(Secsleft ,1);
PlotText(MinleftSTR+":"+SecsleftSTR,BarCount +1, 1, colorBlack, IIf(sec10,colorYellow,colorWhite));


Greetings,
 
#8
when I added the code(clock) bars disappeared from chart.Am I missing something?
hi vxl you can add this line instead, for your price Charts

Code:
MinleftSTR=NumToStr(Minleft,1); SecsleftSTR=NumToStr(Secsleft ,1);
PlotText("Time to Go\n"+MinleftSTR+":"+SecsleftSTR,BarCount +1,LastValue( L,1), colorBlack, IIf(sec10,colorYellow,colorWhite));
 

Similar threads