specify time with iHighest ect

 

Hi all,

I am using iHigh and iHighest etc with no major problem in a script. It seems time can only be referenced relative to the current time. (shifting) I realize I can program around this by testing current time to the times that I want to do whatever.

Is there no way of specifying a range of time for iHighest? ie iHighest from 07:00 yesterday to 07:00 today. ... If not, it's ok; what I have is working as long as I run it just after 07:00. I'm adding a time test and have it figured out I think. Testing the test soon.


my working code is:

DoubleToStr(iHigh("USDCHF",PERIOD_H1,(iHighest("USDCHF", PERIOD_H1, MODE_HIGH, 24, 0))),5)

I might have to adjust it a bit, but you get the idea. I'm using it on 12 pairs and OHLC. I'll have it output to a csv file. That file I will copy and paste into a Excel file that contains my "EA". I am not the author of the "EA". It will take a while for either of us to get it properly into a real EA. In the meantime it works and I can really keep an eye on it.


Thanks

 
Baliguy: Is there no way of specifying a range of time for iHighest? ie iHighest from 07:00 yesterday to 07:00 today.
Of course there is. Find the bar corresponding to 7 yesterday and the bar corresponding to 7 today. Length is difference+1
 

Isn't that what I am already doing? Shorter than my code above??? Also I don't want to "find the bar...". I have been doing that manually on the chart and it has gotten old. I am looking for something simpler than what I use. I have to trade at the same time everyday, so what I have is right unless I get there early an am not paying attention. I am wondering why the timing spec for iHighest can't also be used with a explicit time and not a time offset. I get frustrated when a command or syntax doesn't work in an obviously greatly useful way.

If my personal trading day start time was the same as the server day start time, the daily chart would work perfectly and this would be so simple.


I'm still new at this, so thanks for the input. It is entirely possible this is just going over my head at the moment.

Thanks

 
Baliguy:

Isn't that what I am already doing? Shorter than my code above??? Also I don't want to "find the bar...". I have been doing that manually on the chart and it has gotten old. I am looking for something simpler than what I use. I have to trade at the same time everyday, so what I have is right unless I get there early an am not paying attention. I am wondering why the timing spec for iHighest can't also be used with a explicit time and not a time offset. I get frustrated when a command or syntax doesn't work in an obviously greatly useful way.

If my personal trading day start time was the same as the server day start time, the daily chart would work perfectly and this would be so simple.


I'm still new at this, so thanks for the input. It is entirely possible this is just going over my head at the moment.

Thanks

You find a bar number from a bar start time using iBarShift() if you know the datetime for midnight then you just add PERIOD_H1 * 7 * 60 to it to get 7 am today and then subtract PERIOD_H1 * 24 * 60 from that to get 7am yesterday, then you have your 2 datetimes, then you can get your bar numbers then you can get your iHighest()

This is Midnight: Midnight

 

Thanks. I'll use that if I get more into it. Right now that is not the one line of code that I am seeking.

Basically I was asking if there is a line of code simpler than:

DoubleToStr(iHigh("AUDCAD",PERIOD_H1,(iHighest("AUDCAD", PERIOD_H1, MODE_HIGH, 24, 1))),5);



I am guessing by the responses that the answer is "NO".

 
Baliguy:


I am guessing by the responses that the answer is "NO".

Why would you want simpler in preference to correct ?
 

Mine is correct for me, for what I'm doing, for now. Simple and correct is best! I asked if iHighest could take a explicit time argument or had to be given a shifted time. No one seems to be able to use the word "NO".



Mind you I do appreciate the help and input even though I seem to be nitpicking. :) Whatever issues I am having with conversations on this forum are do to my coding skills being at a 0.1 and your skills being at somewhere near 100, at least from my point of view.

 
Baliguy:

Thanks. I'll use that if I get more into it. Right now that is not the one line of code that I am seeking.

Basically I was asking if there is a line of code simpler than:

DoubleToStr(iHigh("AUDCAD",PERIOD_H1,(iHighest("AUDCAD", PERIOD_H1, MODE_HIGH, 24, 1))),5);

I am guessing by the responses that the answer is "NO".

"Simpler" is relative to each individual. Some may find that line of code very simplistic; on the other hand, others may find it harder to read or comprehend (for example, maybe due to combination of three functions or the number of parenthesis).

When I look for simplicity, I try to break the code down into smaller parts. For example:

// The following code compiles, but was not tested

int _shift = 0; double _hightest = 0;                           // variable declarations
_shift = iHighest("AUDCAD", PERIOD_H1, MODE_HIGH, 24, 1);       // get the bar index for the bar which has the highest high for the previous 24 bars
_hightest = iHigh("AUDCAD", PERIOD_H1, _shift);                 // get the high price for the bar which has the highest high
Print (DoubleToStr(_hightest, 5));                              // convert the price to a string with 5 decimal places and print string to the log/journal

But, again, "simple" is in the eye of the beholder.

I asked if iHighest could take a explicit time argument or had to be given a shifted time. No one seems to be able to use the word "NO".

Just to respond - the answer is: No. Review the documentation on iHighest(). IHighest() cannot take an explicit time argument. If you are looking to find a bar that encompasses a particular time, use iBarShift().

 
Baliguy:

Mine is correct for me, for what I'm doing, for now. Simple and correct is best! I asked if iHighest could take a explicit time argument or had to be given a shifted time. No one seems to be able to use the word "NO".



Mind you I do appreciate the help and input even though I seem to be nitpicking. :) Whatever issues I am having with conversations on this forum are do to my coding skills being at a 0.1 and your skills being at somewhere near 100, at least from my point of view.

My code is far from complex, IMO, and my coding skills still have a lot of room to grow, I like to keep things simple. If what you have works for you then that is good, just bear in mind it might not if you switch broker to one that has a different timezone.
 
shift = iHighest("AUDCAD", PERIOD_H1, MODE_HIGH, 24, 1);

There are not 24 H1 bars in a day. On GMT broker Sunday has only one or two hours, and Friday has 21 or 22.

If you want 24 bars fine. If you want days - code it that way.

But don't ask for one thing, so something else and complain when you get corrected.

 

I wasn't corrected by anyone WHRoeder. Obviously I wasn't understood. Even so I wouldn't rewrite my first post/question any different. You all mostly understand my question enough now. I do have my answer and then some!!


I am really sorry to put anyone out about this. I feel bad because you spend your time here helping people and then deal with an ass like me. I've seen some of your coding WHRoeder and I doubt I will ever get to that level.


Thanks

Reason: