Arrays & Same Candle Programming

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

    Hi All,

    I though I would ask one last time if the below is possible in current version of ProBuilder.

    If IsLastBarUpdate is true then

    1. store price and say average[20] value of current candle in an array variable.

    Then when IsLastBarUpdate is true again then

    1. there is nothing to compare since array above only has 1 price and 1 average[20] value
    2. just store the second reading of price and second reading of average[20] value in the same array above

    Then when IsLastBarUpdate is true again then

    1. Check price against the prices stored in array above
    2. if there is a match then compare the average[20] value of this reading with the average[20] value of the matched price in the array then continue storing the two new values in the array
    3. If there is not a price match, then just store the values in the array as usual.

    Continue doing the above whilst IsLastUpdate continues to be true until close of the current Bar.

    Can current version of Probuilder handle the above or not yet?

    Many thanks

    #232444 quote
    druby
    Participant
    New

    hi… see if this is getting anywhere!

    druby

     

    // !!! default timeframe 1 minute
    
    
    timeframe(20minute, updateonclose)  // update only every 20 minutes
    close20m = close                    // 20minute close
    barIndex20m = barindex              // 20minute barindex
    
    
    timeframe(1minute )                 // 1minute timeframe
    close1m = close                     // 1minute close
    
    
    if barIndex20m <> barIndex20m[1]then           // end of 20minute bar!
    drawvline(barindex[20])style(dottedline,1)  // denote with vertical line
    
    // calculate the 20minute bar average based on last 20 1minute bars
    avg1m = average[20](close1m)   
    // display this average over the relative 15minute bar width            
    drawsegment(barindex,avg1m,barindex[20],avg1m)style(dottedline,2)coloured("blue")
    
    // table variables
    print(close20m[1]) //  this [1] aligns up  20m close with the avg1m value
    print(avg1m)       //  in table 
    print(barindex20m)
    endif
    
    return close20m coloured("red")as"20m Close",close1m coloured("lime")as"1m close"
    #232481 quote
    robertogozzi
    Moderator
    Master

    Can you make an example with some data?

    In addition, what would you like to do with the array containing those data?

    #232504 quote
    IG_CFD_Trader
    Participant
    Average

    Hi Roberto,

    Drubi did a good job above but unfortunately he had to use multi timeframes strategy (like a trick) which gives rise to two issues:

    1. I have to apply the code to the lower timeframe which is a multiple of the higher timeframe
    2. Perhaps Prorealcode is not ready yet or cannot handle capturing data from a current Bar directly on any timeframe once chooses.

    I will try to re-explain with an example as you asked:

    • Assume I am looking at a 1 hr time frame.
    • I have a current Bar obviously with price (close) moving up and down during market session (or assume after 10am i.e. after market open)
    • Assume also I have an indicator running (RSI, MACD, VWAP, etc…) which also registers a reading every time the current bar price moves up and down

    Now given the above:

    • Can prorealcode use an expression like (if islastbarupdate then) or any other expression for that matter to
      • Capture both the price and the indicator reading value and store them as fixed values somewhere for later use?
      • Capture the next price and indicator reading everytime the bar updates and store them next to the first readings above
      • Keep on capturing and storing price and indicator readings for as long as the current bar is updating?
      • The above has to be done directly to the current bar on the one timeframe itself without the need to resort to a lower timeframe as a trick to get around the issue

    Whilst the code is continually storing, I just want to for example Print the data and maybe print or display the cumsum or summation of the data from open time of the Bar (say 10am) etc which should not be hard to do. The hard part is the live continual capture and storing of the data as I described above.

    Tnx

    #232517 quote
    pableitor
    Participant
    Master

    I tried to do like you said but AFAIK theres no way to store tick data in any array or variables, much less use them to trade in higher timeframes. You just can  view it if you previously declare <defparam drawonlastbaronly = true>

    Please someone correct me if I am wrong.

    Iván González thanked this post
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Arrays & Same Candle Programming


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
IG_CFD_Trader @wnakhoul Participant
Summary

This topic contains 4 replies,
has 4 voices, and was last updated by pableitor
1 year, 9 months ago.

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