Simple Coding Help - No Promise.

str = NumToStr(nbar, 1.0) ;
PlotTextSetFont( str, "Arial", 18, i, pos+Offset, Clrtext );
PlotText(str, i, pos+Offset, Clrtext) ;
hi,
i am currently using 6.30 version. but when i insert the above code its showing the error. following is the code i am currently using can you please help me.

Code:
_SECTION_BEGIN("Bar Count");
// Author: Pratap Balakrishnan
// Copyright: All rights reserved. Not to be circulated or shared or posted on websites without the author's written permission.
// email id: [email protected]
//
// mode Text - show the barcount as a number above/below the price bars
//             every n bars as set
// mode Histogram- shows the barcount as an histogam. Best used on a different pane
//

showhisto = ParamToggle("Mode", "Text|Histogram", 0) ;
everyn = Param("Show Text Every N bars", 3, 1, 10000, 1) ;
showabove = ParamToggle("Show Pos", "Below|Above", 0) ;
Clrtext = ParamColor("Text Color", colorBlack) ;

nd = Day()!=Ref(Day(),-1) ;

nbar = 1+BarsSince(nd) ;

if (showhisto)
    Plot(nbar, "Day Bar Count", colorBlue, styleHistogram) ;
else
{
    bi = BarIndex() ;

    showtextbar = ((nbar -1) % everyn) == 0 ;
    if (showabove)
    {
        pos = H ;
        Offset = 10 ;
    }
    else
    {
        pos = L ;
        Offset = -10;
    }

    Visfirst = FirstVisibleValue(bi) ;
    Vislast = LastVisibleValue(bi) ;

    for (i = Visfirst; i <= Vislast ; i++)
    {
        if (showtextbar[i])
        {
            str = NumToStr(nbar[i], 1.0) ;
            
            PlotText(str, i, pos[i]+Offset, Clrtext) ;
        }
    }
//    PlotShapes(showtextbar*shapeSmallCircle, colorBlue, 0, H, 50) ;

}
_SECTION_END();
 

augubhai

Well-Known Member
So now you know it can fail ..
Code:
zTickSize=0.05;
function zRoundUp(zValue) {return ceil(zValue/zTickSize)*zTickSize;}
function zRoundDown(zValue) {return floor(zValue/zTickSize)*zTickSize;}

pricex =  9744.351;
t2 = zRoundDown(pricex) ;

_N( Title = ( "" + t2 ) ) ;
Sorry about the late reply. Had not logged in for a few days, and had not seen your reply.

I am guessing that you are saying that zRoundDown() does not work in the example that you shared. I am not sure if that is what you mean. Your example code rounds down properly in my AB. I have been using that code for years now, so I would be surprised if it doesn't work.

It could be an issue with the Amibroker versions. I use AB version 5.40.3 (as outdated as me). Though I had purchased a later version of AB, I continue using the old version, mainly because it compresses range bars in a style that I prefer.

My version of AB does have other issues related to rounding off though. It does not display the hundredths place value of numbers greater than 10000 (NF and BNF). 12171.85 is displayed as either 12171.8 or 12171.9. And when I use Prec(C%10000,2) to find the hundredths place value (ignoring the first digit), it gives me either 2171.84 or 2171.85. Strange, but I am used to it now...
 
Hi coders.... need a help

below is a exploration code of monthly high/Low of previous month. I want to add date column for both high/low so that I can easily understand when any particular symbol made high/low in previous month.


PMH = TimeFrameGetPrice("H",inMonthly,0,expandLast);
PML = TimeFrameGetPrice("L",inMonthly,0,expandLast);
Filter = 1;
AddColumn(PMH,"P Month High");
AddColumn(PML,"P Month Low");


attaching image for reference
hl.jpg
 

Romeo1998

Well-Known Member
Hi coders.... need a help

below is a exploration code of monthly high/Low of previous month. I want to add date column for both high/low so that I can easily understand when any particular symbol made high/low in previous month.


PMH = TimeFrameGetPrice("H",inMonthly,0,expandLast);
PML = TimeFrameGetPrice("L",inMonthly,0,expandLast);
Filter = 1;
AddColumn(PMH,"P Month High");
AddColumn(PML,"P Month Low");


attaching image for reference View attachment 43060
in analysis use Daily periodicity and explore...
Left column date/time will show the last date of data present of previous month...
right columns will show date of high n low but it is in datenum format...
i tried to convert it to string, but was not successful, maybe some senior coders will be able to help...
good luck :)

Code:
TimeFrameSet(inMonthly);
pmh = H;
pml = L;
TimeFrameRestore();

pmh = TimeFrameExpand(pmh,inMonthly,expandFirst);
pml = TimeFrameExpand(pml,inMonthly,expandFirst);

pmh_date = ValueWhen(pmh==H  ,DateNum());
pml_date = ValueWhen(pml==l  ,DateNum());

Filter = Month()!=Ref(Month(),1);
AddColumn(PMH,"P Month High");
AddColumn(pmh_date,"PMH_date",1.0);
AddColumn(PML,"P Month Low");
AddColumn(pml_date,"PML_date",1.0);
1592737227027.png
 
in analysis use Daily periodicity and explore...
Left column date/time will show the last date of data present of previous month...
right columns will show date of high n low but it is in datenum format...
i tried to convert it to string, but was not successful, maybe some senior coders will be able to help...
good luck :)

Code:
TimeFrameSet(inMonthly);
pmh = H;
pml = L;
TimeFrameRestore();

pmh = TimeFrameExpand(pmh,inMonthly,expandFirst);
pml = TimeFrameExpand(pml,inMonthly,expandFirst);

pmh_date = ValueWhen(pmh==H  ,DateNum());
pml_date = ValueWhen(pml==l  ,DateNum());

Filter = Month()!=Ref(Month(),1);
AddColumn(PMH,"P Month High");
AddColumn(pmh_date,"PMH_date",1.0);
AddColumn(PML,"P Month Low");
AddColumn(pml_date,"PML_date",1.0);
View attachment 43064

Thanks alot for your efforts sir. I did not find any periodicity option in analysis. so when I tried to run ur code it showed nothing. only blank columns seen.
 

Similar threads