How can I write an mt4 indicator that draws a rectangle and horizontal lines over first 6 hours of hourly candles - mql4

I am a quite new to mql4 coding. I would like to know how I write an indicator that does the following, based on the image below:
Draw a rectangle over the current day hour chart that covers the highest and lowest price points of the first 6 hours (candles)
Draw two horizontal lines along the highest and lowest points found 1.
Please note that 1. and 2. should be based strictly on the hourly period and shouldn't vary with the selected period.
I believe I'm suppose to be using ObjectCreate() with OBJ_RECTANGLE and OBJ_HLINE but the whole concept is quite new to me. I would really appreciate some assistance.

Related

How to look back a certain number of days for an indicator and how to only calculate logic upto the last complete bar (i.e. not the current bar)

I'm relatively new to Pine and was having trouble with a couple of things.
So I've got a indicator that I want to look back for the last 5 full days of activity, however not each stock trades in the premarket/afterhours so I want to be able to look back say 5 days and then calculate the number of bars on the time frame (i.e. for a 5 min or hourly resolution). That way I can calculate the number of bars present on the current ticker for that time frame and adjust my indicator length (instead of just having a constant figure of 80 bars or whatever).
The second thing I want to do is only have the indicator update on the completion of a full bar (for example the hourly resolution). So I want it to only calculate up to x-1 bars. Right now I'm finding that it's updating on each new tick. ( I was able to figure this one out, just changed it from i= 0 to length -1 to i=1 to length).
Any help is greatly appreciated.
Thanks,
A

How To Find Remaining Distance To Move UIView Between 2 Points

SCENARIO
I am working on an application that keeps track of blood glucose levels into a graph. On the graph there are "markings" (ex: -200mg) going in vertical order along the y axis on the right side of the screen and "hours" (ex: -12:00 PM) will be along the x axis on the bottom of the graph. I have to plot out little 'dots' to display what the blood glucose level was throughout the way.
ISSUE
I am trying to calculate how to position the 'dots' in the correct time and mg level and I'm having difficulty calculating the positions. I can access the "markings" and retrieve it's marking.center.x to indicate which 'Time Slot' (x axis) and the marking.center.y to indicate which 'MG Level' the 'dot' needs to go into. Problem is it isn't always exactly 12:00 PM or 200mg where it will need to be placed. In fact that would be very rare.
WHAT I NEED
Based on the following variables:
dot.mgLevel
The dot will already know where it needs to go based on the information retrieved from the medical device. It will know the time and mgLevel to assign itself.
marking.mgLevel
The markings will each have evenly distributed values that such as -100mg, -200mg, -300mg ect...
timemarking.timeslot
Each time marking on the bottom will each have evenly distributed times allocated every 30 min. Such as -12:00PM, -12:30PM, -1:00PM ect...
If the dot has a mg Level of 330mg and the closest marking on the mg Level is 300mg, then I need to be able to calculate how much further up the dot needs to move from 300 going towards the 400mg marker.
SO...
If the distance between the markings are 100pt and the dot's mgLevel is 330mg, then I know that I need to move the dot from the 300mg marking toward the 400mg marking by exactly 30pt. That's because it's simple math because the distance between the markings is 100. But in real life it isn't 100, so I need to be able to calculate this.
MY ULTIMATE QUESTION
Say distance between markings is 241 and each marking represents multiples of a hundred. Say my dot has a mgLevel of 412. How do I calculate how far I need to move the dot so that it will be in the correct place?
I THINK?
I think I need to make 241 equal 100%. But I need help.
Distance between markings is 241pt
Markings are multiples of 100mg
1mg will occupy 2.41pt. So 412mg will occupy (2.41 * 412) pt. To know how much to move for the next dot, take the difference in mg and multiply by 2.41.
In general, if distance between 2 markings in points is d, markings are multiples of m, and desired accuracy is k decimal places, 1mg will occupy g:
let divisor = pow(10.0, Double(k))
let g = round((d/m)*divisor) / divisor

Controlling shown y-axis labels?

So I am using the Charts framework (formerly ios-charts) for a couple of charts.
One of them in a bar chart where the y-axis is duration in seconds - that I then convert into readable minute:second notation with a formatter.
But the selected interval of labels bugs me a little. I would like to control them so they are only shown at intervals that makes sense for this - like say every half or full minute. But I can't seem to find a way to do that for that axis. Only the x-axis seems to have options for that?
So am I missing something here? Or it is not in the framework?
Whoops. Never mind. I found the 'granularity' property on the axis right after asking. And it seems to do what I need.

Changing the viewport to only show certain intevals of ios-charts linechart

I'm using the ios-charts library and I have a LineChart View that has x values that are dates from every weekday of this year. On the y-axis I have values between 0 and 25.
I would like to zoom in on different intervals on the LineChart View.
For example only show Data for week X one time and later change to show data for three months, etc etc.
I did not find anything in the documentation on how to do this. I used the "zoom" function with out any success.
(Example : Zoom and show the last 20 days on the x axis or zoom and show the last three months)
Has someone does this before?
It's a tough question and very advanced control. I guess you need to read carefully about the code, focusing on moveViewToX, and the logic and functions in ChartTransformer. Combining some tricks and calculations, you may find a way to fine-grainedly controll what you want to display.
Also, there is a property:
/// the maximum number of entried to which values will be drawn
internal var _maxVisibleValueCount = 100
may also help you.

multiple points with UIBezierPath in UIView , what formula to apply?

I'm working on an app on IOS with Xcode (objective-c)
Here is the problem :
I'm working on a new way to show some statistics based on some frequency in a day, every hours.
Here is what i'm trying to achieve:
What you see is sort of clock on a 24 hour basis (top = 0 o'clock, each 15 degrees is an hour)
Each hour i have a distance from the center of the circle.
Those values are known, what I have hard time to achieve, is the curves themselves !
Indeed, In an UIView, I think i need to use UIBezierPath to draw the curves, but i have no clue on what formula I need to apply in order to make the graph passing through all the points ?
I hope I am clear with this question. Don't hesitate to ask me to clarify myself !
Thanks again, and see ya later !

Resources