Simple Coding Help - No Promise.

hmp

Well-Known Member
Even in past, it has been requested several times to use [ c ode ] [ / c ode ]

i
Nehal ji
Will you pl. explain me which line to be changed, or what actually i have to do ? I am not conversant regarding coding matter, so pl. excuse me if i am asking any naive question.
Thanks & regards.
 

trash

Well-Known Member
Thanks Amitji.
But while scanning i am getting Afl error & message is as following. Now from where to remove extra space? Because on message board i wont be able to click.

HaOpen = AMA(Ref(HaClose, -1), 0.5);



// for graph collapse

for(i = 0; i <= MAPeriod; i++) HaClose
----------------------------------------^

Error 10.
Array subscript out of range.
You must not access array elements outside 0..(BarCount-1) range

Regards


Maybe you are using lower version of Amibroker


Got nothing to do with lower versions.
You need to check if you have enough bars if your original loop uses condition other than i < Barcount or i > 0 (if iterating backwards).
If you don't do so then i.e. if Barcount of some symbol(s) is just 100 but maperiod is set to 200 then you will get error.

You also need to be aware of the fact that:
1. if you apply Verify Syntax check in AFL editor or if clicking Apply button in editor then only 200 bars are used so then barcount is 200 only internally.
2. During Optimization setup period then Barcount is set to 100 bars internally.
3. it may be the case that visible barcount is lower than some set period when zooming in and QuickAFL is ON.

That's why you have to ensure that your code always executes without error.

So if your loop condition is not using standard Barcount check but looks like
Code:
for(i = 0; i < period; i++)
or
Code:
for(i = 0; i < 1000; i++)
or
Code:
for( i = BarCount - 1; i > BarCount - 1000; i-- )
etc.

Then you have add a check to ensure error free execution in every possible case, for example

Code:
if( BarCount > MAPeriod ) // first check whether there are enough bars
{
    // this loop executes only if check result is true
    for(i = 0; i <= MAPeriod; i++)
    {
        // your code here....
    }
}
 
Last edited:

trash

Well-Known Member
Nehal ji
Will you pl. explain me which line to be changed, or what actually i have to do ? I am not conversant regarding coding matter, so pl. excuse me if i am asking any naive question.
Thanks & regards.
Nehal and Amitrandive are talking about adding code tags if posting AFL codes to ensure that:

1. thread pages become better readable if adding hundreds or thousands of lines of code into forum.
2. inserted code becomes better readable
3. code does not lose its original format.
4. code is "syntax error free" when copy&pasting it from forum into AFL editor. It is NOT ensured if you don't use code tags!

It takes just one second to add code tags. Just ONE.

 
Last edited:
Hi Seniors,

I am stuck with unique problem in amibroker 5.60 and 5.70 both:


When i find error in data ...use to edit data for that day...but lately when i do that on EOD database it changes format from YMD to DMy...like 2015 28 05 to 28 05 2028...extra quote get generated and database for TOSS...

Pls guide me for the same.

Same trouble fot stock split ..



Regards,
Kedarnath
 
Dear Friends & Respected Coders..
Good Evening...
I need Stochastic indicator in CANDLESTICK (OHLC) format for Amibroker..
I tried to search on net but failed..
Due to lack of programming knowledge, I tried to code it, but couldn't succeed.
At motivewave site I found something similar, Is it Stochastic indicator in candlestick format..??
any help would be greatly appreciated..
Thanks..
tk

Code:
http://www.motivewave.com/studies/stochastic_bars.htm
//method = moving average (ma), user defined, default is EMA
//kPeriod = user defined, default is 14
//slowPeriod = user defined, default is 3
//fastPeriod = user defined, default is 3
//top = user defined, default is 80
//bottom = user defined, default is 20
//index = current bar number
//MOR= more or equal, LOR= less or equal

//stochasticK=100*(currentClose-lowest)/(highest-lowest); highest and lowest are for kPeriod
highest = highest(index, kPeriod, HIGH);  
lowest = lowest(index, kPeriod, LOW); 
denom = highest - lowest; 
K = 100 * (close - lowest) / denom );
//Calculate the Slow MA
slowK = ma(method, index, slowPeriod, K);
fastK = ma(method, index, fastPeriod, slowK);
if (use d period)
     value = fastK
else
    val = slowK
endif
//Signals
setBarColor(val,top,bottom);
buy = val MOR= top;
sell = val LOR= bottom;
 

extremist

Well-Known Member
Dear Friends & Respected Coders..
Good Evening...
I need Stochastic indicator in CANDLESTICK (OHLC) format for Amibroker..
I tried to search on net but failed..
Due to lack of programming knowledge, I tried to code it, but couldn't succeed.
At motivewave site I found something similar, Is it Stochastic indicator in candlestick format..??
any help would be greatly appreciated..
Thanks..
tk

Code:
http://www.motivewave.com/studies/stochastic_bars.htm
//method = moving average (ma), user defined, default is EMA
//kPeriod = user defined, default is 14
//slowPeriod = user defined, default is 3
//fastPeriod = user defined, default is 3
//top = user defined, default is 80
//bottom = user defined, default is 20
//index = current bar number
//MOR= more or equal, LOR= less or equal

//stochasticK=100*(currentClose-lowest)/(highest-lowest); highest and lowest are for kPeriod
highest = highest(index, kPeriod, HIGH);  
lowest = lowest(index, kPeriod, LOW); 
denom = highest - lowest; 
K = 100 * (close - lowest) / denom );
//Calculate the Slow MA
slowK = ma(method, index, slowPeriod, K);
fastK = ma(method, index, fastPeriod, slowK);
if (use d period)
     value = fastK
else
    val = slowK
endif
//Signals
setBarColor(val,top,bottom);
buy = val MOR= top;
sell = val LOR= bottom;
Bro U want Stochastic in OHLC or u want stochastic colored Candle sticks as u shown in pic.
the pic u shared is not of OHLC stochastic
it gives green bar as stoch crosses 20 and so on
 

Similar threads