Finding the nearest horizontal line of indicator. (Complex question)
-
Hi ladies and gentlemen,
I have a question.
I want to use a custom indicator that draws multiple horizontal lines at different levels.
See picture below for example. (the 1 pink vertical line I drew myself, such that further on in this post we can assume that currently price is at that vertical line)
The questions:
I want the EA (to be built in FXDreema) to find the nearest horizontal line (above current price), and also find the nearest horizontal line (below current price).
(Note that the lines have their own codename or something like that)I want the EA (to be built) to find NOT the horizontal line above current price, but 1 extra level above that. So basically, I want the EA to find the 2nd horizontal line above current price level.
(and with some other part of the code I want to find the 3rd horizontal line above current price level).- When the lines under #1 and #2 are found, I need to store them somewhere in FXDreema, to also help find the associated price levels of those horizontal lines (and store those as well).
=============================================================================
I will donate a symbolic 20 USD to a charity as means of paying forward the good karma, in return for good help, if any.
-
This thread can be useful.
https://fxdreema.com/forum/topic/7463/distance-between-two-objects
Simply catch all lines you want and put each level into a different variable. Then you can compare each value as you wish.
-
Thank you for the heads up. It sure is appreciated.
I saw that thread before.
Since the indicator plots like 100 of such lines (over a very big price range), it seems it will be a crazy huge task to fetch all lines. However, now thinking of it, I might be able to let the indicator plot only lines in a narrow price range, and hence require less lines to be 'fetched'.But here's where I am expecting problems:
The indicator that draws the lines draws, let's say 5 specific lines in the nearest 400 pip range, with each line its own name, BUT the indicator does the exact same thing for the next upper and lower 400 pip price ranges, so they end up having the same names for the lines. Than how does FXdreema know how to fetch the correct (nearest) line?
This is why my question was specifically on finding the NEAREST lines (from the indicator) above and below current price.Another, not so ideal solution could be to use parts of the indicator code to store values into the EA for the nearest X number of lines, and use those. Still, I believe there should be a way to find the nearest line above (and below) current price.
Another option is:
I am missing the point of the thread you suggested
-
to guide you what to do:
- consider custom code block
- use an array variable big enough to all the lines
- find an increment how the name is changed
- using for loop you can fill this array with each value from all the lines
- create another loop which will loops through the array of values, use a condition inside the loop to find the position of price, when the condition is true, break this loop and finally you have the "i" increment from the loop ... based on this increment you have the position of your desired values from the array ...
this is an example based on the steps + in addition it plots the lines (from which it gets the values, for you it is done with indicator, so change the functions accordingly)
https://fxdreema.com/shared/qfIGAMlVc


this is only for drawing lines:



a tolerance should be added (to eliminate price fluctuations around the line, but this is the task where you can play :D)
...
by the way, the whole code can be converted into blocks, but it takes a longer clicking time and I don't have it ... moreover, in my past replies about working with loops is covered almost everything
-
Someone can play and convert it into blocks, other users can benefit from it

-
Thank you Miro!! Much appreciated.
In 2 weeks time I will continue this project. Reading what you wrote, I think I will get quite far with your explanation.
From my understanding, I could even use some MQ4 code from my indicator and put it straight into FXDreema....
I'll have to do some trial-and-error testing
Thanks again!!
I will uphold my end of the bargain, and pay it forward
-
@miro1360 i get errors when i download this and convert it to mt5