Problem with plotbar

Posted By: nanotir

Problem with plotbar - 04/26/16 17:04

Hi

I cannot find out why this script works for XAGUSD but not for GBPUSD

Some ideas?

Quote:
//#define GBP
#define XAG


function run()
{
set(PLOTNOW+TESTNOW);
set(TICKS);


BarPeriod = 1440;

StartDate = 2010;
EndDate = 2016;

PlotScale = 40;

PlotWidth = 800;
PlotHeight1 = 320;

vars PriceC = series(priceClose());
static var High, Low;
static var ArrayPrice[1000];
int i;

#ifdef XAG
asset("XAG/USD");
var Low = 14.0;
var high = 50;
var grid = 1;
#endif

#ifdef GBP
asset("GBP/USD");
var Low = 1.000;
var high = 1.800;
var grid = 0.010;
#endif


int divi = (high-Low)/grid;


ArrayPrice[0]=Low;
for(i=1;i<divi;i++)
{
ArrayPrice[i]=ArrayPrice[i-1]+grid;
plot(strf("#NT%i",i),ArrayPrice[i],0,BLUE);
}

int c;
var a;
static var Counter[1000];

for(i=0;i<divi;i++)
{
if(PriceC[0]>=ArrayPrice[i] and PriceC[0]<ArrayPrice[i+1])
{
Counter[i]=Counter[i]+1;
c = Counter[i];
a = ArrayPrice[i];
plotBar("Spectrum",a,a,c,BARS+AVG+LBL2,RED);
}
}



}
Posted By: jcl

Re: Problem with plotbar - 04/27/16 08:43

You're plotting all GBP prices to the same bar number 1. Multiply the bar number, the first "a" in your call, with 100 to distribute the histogram on 100 different bars.
Posted By: nanotir

Re: Problem with plotbar - 04/27/16 11:18

Thanks!
I see now that tt worked for XAG because a>1 in that case.

Btw...I am trying to export the counter array of the script using the print function with the TO_CSV option but I cant make it to work. Some ideas? Thanks
Posted By: jcl

Re: Problem with plotbar - 04/29/16 11:58

Any print(TO_CSV,..) call just prints the resulting string in the CSV file. So you just have to pass a format string containing the counter number in the proper .csv format that you need.
© 2024 lite-C Forums