Creating timer to capture indicator values at intervals

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #170093 quote
    IG_CFD_Trader
    Participant
    Average

    Hello All,

    I have created an indicator (intraday only) that returns a number value that gets drawn on the chart (via drawtext). The number is dynamic and continuously changes from start of timeframe to end of timeframe (say 15mins) and then freezes on bar and starts again for fresh new bar.

    My question is:

    • Is it possible to set up a timer (say a 15 mins timer) and then capture the running value every 1 min interval and save that value in a separate variable to then draw it on the bar?
    • Is it possible to lookback across the intraday bars and locate the highest high bar and then capture the value that is shown on that bar so that I can draw it on Barindex[1] for example as an easy reminder?

    Thank you in advance

    #170738 quote
    robertogozzi
    Moderator
    Master

    Can you make an example?

    #170756 quote
    IG_CFD_Trader
    Participant
    Average

    Thank you Roberto. The example could be really simple. Let’s assume I have basic indicator that is simply returning the “Price” of the current live bar. The time frame is 15 mins. Obviously the “Price” will fluctuate up and down for the duration of the time frame (i.e. 15 mins) and then closes at the end of the 15th minute and a new bar opens and so on…

    Now if I open a 1 min chart, I can simply observe the closing price at the end of each 1 min but I don’t want to do that.

    Instead, I want to write a code and apply it to the 15mins chart that does exactly what the 1 min chart does, i.e. capture the price of the bar at the end of each minute (therefore will capture 15 price values) and then DRAWTEXT each value on the chart.

    Should be simple with dynamic array variable I think 🙂

    Thanks

    #170766 quote
    Vonasi
    Moderator
    Master

    G_CFD_Trader – Please follow the forum rules. I have deleted your double post in another topic… and the reply that I wasted time giving to it. Here is the forum rule:

    • Do not double post. Ask your question only once and only in one forum. All double posts will be deleted anyway so posting the same question multiple times will just be wasting your own time and will not get you an answer any quicker. Double posting just creates confusion in the forums.
    #170767 quote
    IG_CFD_Trader
    Participant
    Average

    Not a problem my friend. Please accept my apology.

    My regards,

    Walid

    #170775 quote
    robertogozzi
    Moderator
    Master

    There you go:

    Timeframe(15 minute,UpdateOnClose)
    Close15 = close
    //
    Timeframe(default)
    DrawText(“#Close15#”,BarIndex,high+range,SansSerif,Bold,16) coloured(0,128,0,155)
    Return
    #170776 quote
    robertogozzi
    Moderator
    Master

    I forgot to add this very first line:

    Defparam DrawOnLastBarOnly = true

    Should you want the text plotted at its actual  position, just replace high+range with Close15.

    #170781 quote
    IG_CFD_Trader
    Participant
    Average

    thanks Roberto but I think the code you have suggested above will draw on the chart only 1 value (the close at the end of the 15th minute). I don’t want that.

    I want it to draw 15 closes (1 close every 1 minute)

    #170784 quote
    robertogozzi
    Moderator
    Master

    To draw the close every one minute you don’t need any TF other the 1-minute:

    MyClose = close
    //
    //DrawText(“#MyClose#”,BarIndex,high+range,SansSerif,Bold,16) coloured(0,128,0,155)  //every tick
    //
    DrawText(“#MyClose[1]#”,BarIndex,high+range,SansSerif,Bold,16) coloured(0,128,0,155)  //when the candle closes
    Return
    #170789 quote
    IG_CFD_Trader
    Participant
    Average

    I need to draw the close every one minute on a 15 min chart?

    #170792 quote
    IG_CFD_Trader
    Participant
    Average

    As I previously mentioned, “close” is just an example. In reality I have an indicator that returning a live dynamic number that is changing continuously from bar open through to bar close (therefore similar to Close so that’s why I gave Close as example).

    So I need to capture the closing value of my indicator every 1 minute that elapses and draw it on chart (so in total I need to capture and draw 15 readings, minute1, minute2, minute 3………minute 15)

    #170794 quote
    robertogozzi
    Moderator
    Master

    You cannot draw every minute on the 15-minute chart.

    You can use the above code, choosing the line that suits you best, every tick or after closing.

    #170796 quote
    IG_CFD_Trader
    Participant
    Average

    Isn’t it possible with dynamic array? Define a dynamic array that can store 15 values (1 value every 1 minute). Then convert the array variables back to standard variables in order to draw each value on the chart. Not possible?

    #170798 quote
    robertogozzi
    Moderator
    Master

    No, it isn’t.

Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.

Creating timer to capture indicator values at intervals


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
IG_CFD_Trader @wnakhoul Participant
Summary

This topic contains 13 replies,
has 3 voices, and was last updated by robertogozzi
4 years, 8 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 05/21/2021
Status: Active
Attachments: No files
Logo Logo
Loading...