Simple Coding Help - No Promise.

okabira

Well-Known Member
Code:
TN=TimeNum();
StartTime=TN>=091500;
GreenC=C>O;
RedC=C<O;
GreenCount=SumSince(StartTime,GreenC);
RedCount=SumSince(StartTime,RedC);

Hi LOVEENAJYOTHI ji

if i want to show values what should i right now ?
Nothing gets plotted so cannot interpret .
its coming blank __

--------
my strategy is to count bars .
suppose time elapsed now is 10.15
1.JPG


with every candle passing , it would count green bar and red bar

2) when time passes to 11.15 .. Green / red candle count gets added to prev. count
2.JPG


what should be the language to write this code?

PS : candle count shown is just arbitrary number ...not real counting done

Thanks
 

LOVEENAJYOTHI

Well-Known Member
Hi LOVEENAJYOTHI ji

if i want to show values what should i right now ?
Nothing gets plotted so cannot interpret .
its coming blank __

--------
my strategy is to count bars .
suppose time elapsed now is 10.15
View attachment 24638

with every candle passing , it would count green bar and red bar

2) when time passes to 11.15 .. Green / red candle count gets added to prev. count
View attachment 24639

what should be the language to write this code?

PS : candle count shown is just arbitrary number ...not real counting done

Thanks
1.Use the code snippet offered by @travi , it makes more sense.
2.About ur requirement, u can add it to ur title code to display counts on ur chart title.
Actually i thought u wanted to use the counts in ur Analysis Window (BackTesting/Exploration) as an additional Filter/Screener to an aready existing AFL.
 

okabira

Well-Known Member
1.Use the code snippet offered by @travi , it makes more sense.
2.About ur requirement, u can add it to ur title code to display counts on ur chart title.
Actually i thought u wanted to use the counts in ur Analysis Window (BackTesting/Exploration) as an additional Filter/Screener to an aready existing AFL.
Thanks
 

travi

Well-Known Member
@LOVEENAJYOTHI even i thought it was for Exploration. If its for a chart then you need to bring accuracy to the entire date,
bcos if its a local DB then most likely there is previous months Data, and possibly previous year too.
so Day will match each day in month and so on.

@okabira

Try this

Code:
Today = LastValue(Day()) == Day();
CurMonth = LastValue(Month()) == Month();
CurYear = LastValue(Year()) == Year();
TN=TimeNum();
StartTime=TN>=091500;
If(CurYear AND CurMonth AND Today AND StartTime)
{
    GreenC=C>O;
    RedC=C<O;
    GreenCount=SumSince(StartTime,GreenC);
    RedCount=SumSince(StartTime,RedC);
}


/*AND wherever you have this Line
// _N(Title = StrFormat("{{I.....
/* append this

...... + "Green: " + NumToStr(GreenCount(),1,False) + " Red: " + NumToStr(RedCount(),1,False)
 

LOVEENAJYOTHI

Well-Known Member
@LOVEENAJYOTHI even i thought it was for Exploration. If its for a chart then you need to bring accuracy to the entire date,
bcos if its a local DB then most likely there is previous months Data, and possibly previous year too.
so Day will match each day in month and so on.

@okabira

Try this

Code:
Today = LastValue(Day()) == Day();
CurMonth = LastValue(Month()) == Month();
CurYear = LastValue(Year()) == Year();
TN=TimeNum();
StartTime=TN>=091500;
If(CurYear AND CurMonth AND Today AND StartTime)
{
    GreenC=C>O;
    RedC=C<O;
    GreenCount=SumSince(StartTime,GreenC);
    RedCount=SumSince(StartTime,RedC);
}


/*AND wherever you have this Line
// _N(Title = StrFormat("{{I.....
/* append this

...... + "Green: " + NumToStr(GreenCount(),1,False) + " Red: " + NumToStr(RedCount(),1,False)
Thanks @travi .
The following won't do the job of finding NewDay /Today in the above case ?
Code:
Today=Day() != Ref(Day(),-1);
 

okabira

Well-Known Member
@LOVEENAJYOTHI even i thought it was for Exploration. If its for a chart then you need to bring accuracy to the entire date,
bcos if its a local DB then most likely there is previous months Data, and possibly previous year too.
so Day will match each day in month and so on.

@okabira

Try this

Code:
Today = LastValue(Day()) == Day();
CurMonth = LastValue(Month()) == Month();
CurYear = LastValue(Year()) == Year();
TN=TimeNum();
StartTime=TN>=091500;
If(CurYear AND CurMonth AND Today AND StartTime)
{
    GreenC=C>O;
    RedC=C<O;
    GreenCount=SumSince(StartTime,GreenC);
    RedCount=SumSince(StartTime,RedC);
}


/*AND wherever you have this Line
// _N(Title = StrFormat("{{I.....
/* append this

...... + "Green: " + NumToStr(GreenCount(),1,False) + " Red: " + NumToStr(RedCount(),1,False)

Nahi sirji ,

I am not able to explain to you correctly ... Hence you are not getting...
what I am seeing and interpreting ...
will right some time later after more research..
 

travi

Well-Known Member
Thanks @travi .
The following won't do the job of finding NewDay /Today in the above case ?
Code:
Today=Day() != Ref(Day(),-1);
Day() returns 1-31, ie. day part of date.

so whatever is returned b/w 1-31 will match the same digit in the previous month and the one before and so on.
it will give and aggregate for all the months found in the DB for that ticker.
so instead of Day != Ref(....), most codes will have LastValue(Day()) to get most recent value.

This itself becomes dynamic to refer to the most current day, similarly, we had month() to get current month.
If ppl had data from 2016, 17 and prev years, the year() check will handle that.
in that sense we're not leaving room for errors and code can run in chart as well as Analysis.

After doing the above, then the starttime variable can be used for more fine grain counting, if time is 091500 then not reqd,
but if you want hourly counts for eg. then we can loop through starttime and even get hourly counts :)
 

LOVEENAJYOTHI

Well-Known Member
Day() returns 1-31, ie. day part of date.

so whatever is returned b/w 1-31 will match the same digit in the previous month and the one before and so on.
it will give and aggregate for all the months found in the DB for that ticker.
so instead of Day != Ref(....), most codes will have LastValue(Day()) to get most recent value.

This itself becomes dynamic to refer to the most current day, similarly, we had month() to get current month.
If ppl had data from 2016, 17 and prev years, the year() check will handle that.
in that sense we're not leaving room for errors and code can run in chart as well as Analysis.

After doing the above, then the starttime variable can be used for more fine grain counting, if time is 091500 then not reqd,
but if you want hourly counts for eg. then we can loop through starttime and even get hourly counts :)
Thanks @travi , a delight, always.
 
Dear Happyji and Seniors
I am new to Amibroker and its Afls. Is it possible to daily 5 EMA High, Daily 5 EMA Close and Daily 5 EMA low on 1 Minute chart. If possible kindly proved me.
Thanking Your
 
Dear Happyji and Seniors
I am new to Amibroker and its Afls. Is it possible to plot daily 5 EMA High, Daily 5 EMA Close and Daily 5 EMA low on 1 Minute chart. If possible kindly give me the codes.
Thanking Your
 

Similar threads