Smart money indicator (using Arrays)

Forums ProRealTime English forum ProBuilder support Smart money indicator (using Arrays)

Viewing 15 posts - 1 through 15 (of 18 total)
  • #217792

    Kindly requesting help with my code. I’m trying to create a smart money indicator similar to the ones found on the marketplace.

    My goal is to use it for automated trading strategies, so I attempted to make one myself so i can customise it.

    Basically, I want to draw rectangles on the chart to mark the gaps.eg where the low is lower than the previous two lows, and vice versa for the highs.

    I’m struggling to get anything to show up on the chart. Its always blank.

    Beyond the basic Conditional IFs, im a noob with arrays and loops. Ive been trying to learn arrays from the material on the forum. Tried chatgpt aisstance as well.

    Here’s what I’ve got so far:

     

    Appreciate any help

    #217801

    Replace (empty) line 33 with:

     

    1 user thanked author for this post.
    #217832

    Thank you Roberto. I add the line of code and it started showing some drawings but not exactly what I wanted.

    I still dont understand the logic behind it, if you could explain it I would be very grateful. I have no prev coding knowledge and really want to understand how it works.

    Regarding the code. Its drawing the rectangles well before the intended start. Please see attached screenshot.

    Greatly appreciate the time you are taking to help me.

     

     

    #217836

    It’s because of LastSet, which allows you to add new elemets to an arry without caring about how many elements have already been creted. With that instruction, lines 5-16 are useless, as they build the first 51 elelements, so that when you start adding elemnts they will start from the 52nd, i.e. element 51.

    Since you loop through the first 51 elemts in lines 35-59, you will only scan the empty elements created in lines 5-16.

    My addition will check what is the highest number of elemnts, so that ALL elements are scanned.

    Actually line 35 could be written as:

    just to skip the first unused elements (or you can get rid of lines 3-16.

    I have never used LastSet myself, as I always keep track of how many elements I have created. And I usually prefer using a fixed number of elements.

    To keep a fixed number of elements tou would need to change the code quite a lot, to store new elements when need,, but, BEFORE adding a new one you should always shift the last N-1 elelents one place, to make room for the new one.

    If you need only the last 50 elements, then create (as you have done) ALL those 50 elements at the very first bar, then use elemenbt 50 as the current one, but before replacing the old data with the new one in element 50, you should shift the first 49 elemnts one place, so that element 2 is copied to element 1 (thus losing the oldest elelemt) until you finish copying elelent 50 to element 49. At that point you can set element 50 with the new datum.

    When you scan the whole arrayto be plotted, you will allways plot 50 elements.

     

     

     

    #217838

    You are right, i didnt need to initialise the array.

    What is the advantage to not using LASTSET. It seems like a lot of work to keep rearranging the array. I believe i read somewhere on the forum the array can hold 1million values.

    If its computation can i just not use – DEFPARAM CalculateOnLastBars

    My goal is to first develop the indicator. Than i can try to get the array values eg lowest low in the last 200 bars thats not been filled or something along those lines to develop a strategy.

    I think my current code isnt save the barindex on which the value gap is detected. Its drawing the rectangle well into the previous bars.

    Any advice how i can can get it too look like this ? ( attached picture)

    #217842

    This is as far as i got.

    Its racking my brains.

    I managed to get the lower gaps to somewhat work. But the highgaps isnt working at all.

    No idea on how to make the boxes smooth.

     

    #217857

    Spent a few hours but i managed to make something that sort of resembles what I wanted.

    I cant waste anymore time or brain power on this. Im gonna shelf it for the time being and work on it another time.

    Please if any expert coders could help me out. This indicator is a useful leanring exp for anyone starting and could be a good addition to the library.

    Any help greatly appreciated.

    #217882

    I guess nobody wanted to help me with the coding in this. Curious if its because its a conflict of interest as there is a smart money indicator selling on the marketplace??

    But anyway, i’m proud to say i’ve managed to crack this indicator (i think) by myself.

    Here it is for free. Saves you paying 50-100 bucks for it on the marketplace. PLUS you can easily in coperate it into your auto trading, customise it etc.

     

    Next step is to make it multi timeframe (for another day, unless someone whats to work on it with me?)

     

    3 users thanked author for this post.
    #217979

    No, it’s because you are not the only one needing help!

    #217984

    No, it’s because you are not the only one needing help!

    I know :p , I meant it purely in jest.

    I do appreciate all the help you give in this forum though.

    This indicator is quite slow, do you think theres anything to make it faster? or a more optimum way to code it?

    1 user thanked author for this post.
    #217991

    I tried to make a System / Algo out of it, but gave up as it took too long to run when trying anything … even when fixed values were entered, it still took far too long to load / display (for me anyway).

    Pity, as you have put a lot of work into it, so it would be good to see it make money?

    #217993

    If you backtest it, it loops through the array each bar. As the array gets bigger the loop gets bigger.

    I think this is the issue. Wild guess , as i dont fully understand how arrays work.

    It might make it faster if we could reset the array after the price has been filled. So it only loops through unfilled arrays. Unset($array) dosent work.

    I am unable to conceptulise the process.

    You could probably replicate the indicator by just using loops. But then i dont know how you would save the values so we can build strategies on it.  Thats a whole different code.

    Hopefully the more experienced coders here can advise us.

    #217994

    You could try this and see if it makes it any faster.

    I havent started coding any strategy yet so cant test on backtest

    I dont think we would need more than the last 50 values of the array

    1 user thanked author for this post.
    #217998

    You are right, i didnt need to initialise the array. What is the advantage to not using LASTSET. It seems like a lot of work to keep rearranging the array. I believe i read somewhere on the forum the array can hold 1million values.

    I think you understand very well what the issue is hence what needs to be solved in order to get some speed into it. But I can tell you, for someone like me (call me a die hard coder) the way to deal with arrays in PRT is so much against any nature I am used to, that I simply can’t wrap my brains around it.
    The solution should be something like working with chunks of past data (shift that each 100 bars or so), so that it remains fast and independent of the size of the backtest. But instead of focusing on the functional solution, all we’d do is (indeed) rack our brains on the technical solution because of how PRT (-coding) works. This is just not for me at all.

    Meanwhile a hats of to you for how far you got with it.

     

    PS: I never saw a solution in the forum, working with arrays which was workable – always for the same reason : it is infinitely too slow. Arrays in PRT are too slow to begin with, but the solutions with them always depict huge redundancy in the processing. You saw that very correctly …

    2 users thanked author for this post.
    #218004

    Ditto, Monochrome has done well!!

    PRT is good but has limited support and programming has it’s own challenges.

Viewing 15 posts - 1 through 15 (of 18 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login