Page 1 of 1

Set firstbar for Owner-draw indicator

PostPosted: Tue Feb 21, 2017 5:38 am
by Gidien
Hi,

Is it possible to initialize the firstbar which is drawn in a owner-draw indicator?

Explanation:
I wrote a point and figure view indicator and set is as owner-draw indicator. After loading the history and calculation the point and figure data, the indicator will have 1000 bars.
If the indicator is loaded the first time, then it will draw the whole data to the screen(1000 bars). This make the indicator unreadable. I have allways to zoom in to the chart to see only last 50 bars.

Is there a way to setup the owner-draw indicator,maybe in the Draw(stage,context) function, to show only the last 50 bars at the first time?

best Guido

Re: Set firstbar for Owner-draw indicator

PostPosted: Wed Feb 22, 2017 4:40 am
by Apprentice
Sure.
However I should see the exact implementation.
U can use loop like this.
Code: Select all
for period=source:size()-1-Look_Back_Period,source:size()-1,1 do
end

Re: Set firstbar for Owner-draw indicator

PostPosted: Wed Feb 22, 2017 5:37 am
by Gidien
Sorry didn't understand the solution.

Lets take my point and figure indicator.
viewtopic.php?f=17&t=31328&hilit=point+and+figure

In this indicator i create a new candlegroup.
instance:createCandleGroup("pf,"..bs..","..rc, "pf", open, high, low, close, volume, "PF", false);
If the boxsize is small then the candlegroup can have more then 500 bars(candles).

If the view indicator is loaded the first time , then all created bars are drawn.
It looks like this.

firstload.png


I have to zoom into the chart after the first load.
Then it looks like this.

afterzoom.png


My intention is not to limit the available bars(candle) of the indicator. My intention is to draw only the last x bars of all available bars at the first load. It should look like the zoom picture at the first load.

best
Guido

Re: Set firstbar for Owner-draw indicator

PostPosted: Tue Feb 28, 2017 4:49 am
by Apprentice
Can you share your code.
Will fix it for you.

Re: Set firstbar for Owner-draw indicator

PostPosted: Wed Mar 01, 2017 3:26 am
by Gidien
Here it is.

PF_SOURCE.lua
(23.3 KiB) Downloaded 920 times

Re: Set firstbar for Owner-draw indicator

PostPosted: Fri Mar 03, 2017 6:06 am
by Apprentice
PF_SOURCE.lua
(23.51 KiB) Downloaded 931 times

I introduced LookBack period.

Re: Set firstbar for Owner-draw indicator

PostPosted: Fri Mar 03, 2017 7:57 am
by Gidien
Sorry, but this is not a solution. This is not what i was looking for. You can do the same thing with my indicator by changing the "Date From" parameters. Its the same thing. Maybe my english is to bad to explain what i want.

Your solution or changing the "date from" parameter will only reduce the size of the source data bars from which the point and figure bars are calculation. At the end we will have only some point and figure bars(columns). BUT you cannot go back in the time to see what happens earlier in the point and figure chart.

best

Guido

Re: Set firstbar for Owner-draw indicator

PostPosted: Mon Mar 06, 2017 6:59 am
by Apprentice
U can introduce "to".
Use renco candles as a reference.
Or u can use Left/Rigth LookBack Period.
PF_SOURCE.lua
(23.92 KiB) Downloaded 876 times