Need help with arrays to count highs and lows with conditions

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #153777 quote
    jebus89
    Participant
    Master

    Im not sure if its correct to make a request for help here or to use niclas’ thread so please move my post if you feel like it mods.

    Im fairly new with PRT v11 arrays and im trying to wrap my head around it. Would love to get some help.
    I wanna start with something fairly simple. Please look at attached screenshot for details.

    So for starters i want to do 2 things:

    1. Count as explained in the photo. Count the amount of highs and count the amount of lows, seperatly.
    2. I want to be able to use the price of the different levels. Lets for example say that my system demands a count higher than 3, and i want to buy if low closes under point 2.

    And im not begging for the code here, a walkthrough on how to do it would be amazing, so i dont have to bother you guys forever 🙂 Teach a man to fish etc!

     

    Edit: btw the photo is daily candles on amazon in end of July month 2020

    Edit2: If im wrong about the numbers in the index its because i dont quite understand it yet! Or i might have botched a copy paste 🙂 in other words, i might be wrong

    highlow.jpg highlow.jpg
    #153795 quote
    Nicolas
    Keymaster
    Master

    Firstly, are you able to code the conditions you describe to detect the counts? (before using arrays to store them).

    #154496 quote
    jebus89
    Participant
    Master

    i assume i would need to start with

    if high crosses over highest[period1](high[1]) then

    This would be the trigger to start the count. As long as there is no higher high then that point then the count continues. I would also need to stop the count if it breaks to the downside. I think that point would have to be low crosses under lowest[period2] from the highest high point.

    After that i would code in the lower low/higher highs

    If low crosses under lowest[period](low[1]) and low > lowest-low-period-before-highest-high-that-started-count then
    
    if high crosses over highest[period](high[1]) and high < highest-high-that-started-count then
    newpic.png newpic.png
    #154498 quote
    jebus89
    Participant
    Master

    I ment to say in the pictures last text: “New highest high, count is now reset”

    #154808 quote
    jebus89
    Participant
    Master

    Maybe this will help with showing what level of understanding im at..

    a1 = 0
    b1 = 0
    c1 = 0
    d1 = 0
    abcd = 0
    
    $var[0] = highest[50](high[1]) // highest high past 150 bars
    $var[1] = highest[30](high)[15] //highest high past 50 bars from 30 bars ago
    $var[2] = highest[15-1](high)[1] //highest high past 30 bars
    
    $varlow[0] = lowest[80](low) // highest high past 150 bars
    $varlow[1] = lowest[30](low)[15] //highest high past 50 bars from 30 bars ago
    $varlow[2] = lowest[15-1](low)[1] //highest high past 30 bars
    
    
    a = $var[0] > $var[2]
    b = $var[1] > $var[2]
    c = $varlow[0] < $varlow[1] and $varlow[0] < $varlow[2]
    d = $varlow[1] > $varlow[2]
    
    if a then 
    a1 = 1
    endif
    if b then
    b1 = 1
    endif
    if c then
    c1 = 1 
    endif
    if d then
    d1 = 1
    endif
    
    if a and b and c and d then
    abcd = 2
    endif
    
    return a1 as "a" ,b1 as "b" ,c1 as "c" ,d1 as "d", abcd as "abcd down!"
    #154867 quote
    Vonasi
    Moderator
    Master

    You don’t really need to use arrays if you just want to record the last highest high and last lowest low and perhaps the ones before that. Think of arrays as a big filing cabinet that you can store lots of information in to later search through easily. If you only have a couple of bits of paper to store then you don’t need to use a filing cabinet – a couple of envelopes will do.

    #154873 quote
    jebus89
    Participant
    Master

    yea i get that Vonasi, im just trying to understand this using a practical example that i can do.. i guess i picked a bad example tho. Im not sure how the lastset stuff and looping work.

    #157665 quote
    Nobody
    Participant
    Veteran

    Some of the best most useful threads in PRC are the ones with tumbleweeds imo  . Post an uber optomised no logic curve and the crowd flocks in .  Never ceases to amaze me  .

     

    Profit is onto something with his ” count ” imo   .  Add some volatility filter  and  couple more simple parameters and you got a ” thing ”

     

    rock on  and yeah its cryptic

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

Need help with arrays to count highs and lows with conditions


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
jebus89 @jebus89 Participant
Summary

This topic contains 7 replies,
has 4 voices, and was last updated by Nobody
5 years, 1 month ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 12/15/2020
Status: Active
Attachments: 2 files
Logo Logo
Loading...