Dear community, I need help for building a custom indicator on Easylanguage.
I provide a brief explaination of the indicator.
I would like to calculate a function for every bar in a range of past bars. Than i would like to pick the highest and lowest value among the values of the function for each bar in the range; then i would sum the highest value to a moving average and subtract the lowest value from the same moving average. So my idea is to build a two bands indicator. I am not an expert in programming so if you could help me making the code I would be able to understand the logic behind. Thanks to anyone who will help me. Regards.
Help for an indicator-Custom bands [SOLVED]
- TJ
- Posts: 7745
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
Re: Help for an indicator-Custom bands
The first steps in writing an indicator --Dear community, I need help for building a custom indicator on Easylanguage.
I provide a brief explaination of the indicator.
I would like to calculate a function for every bar in a range of past bars. Than i would like to pick the highest and lowest value among the values of the function for each bar in the range; then i would sum the highest value to a moving average and subtract the lowest value from the same moving average. So my idea is to build a two bands indicator. I am not an expert in programming so if you could help me making the code I would be able to understand the logic behind. Thanks to anyone who will help me. Regards.
1. You must be able to visualize it -- draw a mockup chart, with notes explaining the salient points of the indicator.
2. You must be able to manually demonstrate it -- put some numbers on an Excel spreadsheet and show us how the calculation is done.
After the above is done, then you can attempt to write some pseudo-codes.
Re: Help for an indicator-Custom bands
Function = (Close - sma(30))/standarddev
I need to compute this value for the last 30 bars and pick the greates and the lowest values.
Than i would sum the greatest value of the function to the sma(30) and i would subtract the lowest value of the function from the sma(30). I hope i have been more clear now. Thanks a lot TJ
I need to compute this value for the last 30 bars and pick the greates and the lowest values.
Than i would sum the greatest value of the function to the sma(30) and i would subtract the lowest value of the function from the sma(30). I hope i have been more clear now. Thanks a lot TJ
-
- Posts: 275
- Joined: 22 Apr 2014
- Has thanked: 70 times
- Been thanked: 72 times
Re: Help for an indicator-Custom bands
Like this? Subtracting the lowest of the standarddev vaues would give you a line that is very close the moving average. This is substacting highest value from the MA and adding the highest value to the MA.
-
- Posts: 275
- Joined: 22 Apr 2014
- Has thanked: 70 times
- Been thanked: 72 times
Re: Help for an indicator-Custom bands
@Marktwizz,
I had to make a minor correction to the code as I realised that the values of your function needed to be absolute values.
I had to make a minor correction to the code as I realised that the values of your function needed to be absolute values.
Code: Select all
inputs:
priceseries(close),
lookback(30);
vars:
series(0),
funcseries(0),
funcseries_highestvalue(0),
bandhigh(0),
bandlow(0);
funcseries = absvalue((priceseries - average(priceseries,lookback)) / StandardDev(priceseries,lookback,2));
funcseries_highestvalue = HighestFC(funcseries,lookback);
series = AverageFC(priceseries,lookback);
bandhigh = series + funcseries_highestvalue;
bandlow = series - funcseries_highestvalue;
Plot1(series);
Plot2(bandhigh);
Plot3(bandlow);
-
- Posts: 275
- Joined: 22 Apr 2014
- Has thanked: 70 times
- Been thanked: 72 times
Re: Help for an indicator-Custom bands
Using StdDev directly on the price series will always result in jumpy values of your bands. If you want smoother bands then another appoach would be to load the 30 highest values into an array and then apply a little bit of averaging. You get more or less the same but smoother. Making minor adjustments to lookback length and band smoothing gives you some flexibility. There can be serveral different but similar ways to solve the same problem in Easylanguage. One is not better than the other but it helps to be aware of them.
Code: Select all
inputs:
priceseries(close),
lookback(30),
bandsmoothing(5);
vars:
xx(0),
Peak(0),
series(0),
funcseries(0),
bandhigh(0),
bandlow(0);
arrays:
HV_array[100](0);
funcseries = absvalue((priceseries - average(priceseries,lookback)) / StandardDev(priceseries,lookback,2));
series = AverageFC(priceseries,lookback);
For xx = 0 to LookBack-1
begin
HV_Array[xx] = funcseries[xx];
Array_Sort(HV_Array,0,LookBack,false);
end;
Peak = AverageArray(HV_array,bandsmoothing);
bandhigh = series+peak;
bandlow = series-peak;
Plot1(series);
Plot2(bandhigh);
Plot3(bandlow);
-
- Posts: 275
- Joined: 22 Apr 2014
- Has thanked: 70 times
- Been thanked: 72 times
Re: Help for an indicator-Custom bands
Declare a variable, lets say y ....then y=HV_array[19]
You might to look through this. http://www.traderslaboratory.com/forums ... ylanguage/
regards,
Alex
You might to look through this. http://www.traderslaboratory.com/forums ... ylanguage/
regards,
Alex