stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Indicator Request
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=4019
Page 1 of 7
Author:  Reaper [ Mon Dec 29, 2014 3:59 pm ]
Post subject:  Indicator Request

Hey all,

What I need is an indicator that can detect the Highest High (for a pair in a downtrend) in X number of bars. It will then highlight every Y number of bars forward to the current bar (and beyond)..

So we can input

X = 300
Y = 10

it will check back 300 bars and locate the bar with the Highest High. It will highlight every 10th bar from that bar onwards..

There's more to the indi that I need, but I'll be happy with that for now. Can anyone help me with this please?

Cheers

Merry XMAS and HNY everyone :xm:
Author:  milanese [ Tue Dec 30, 2014 12:04 pm ]
Post subject:  Indicator Request

Hi,

I coded some weeks ago for an user a simil simple indicator, it shows the HighestHigh/LowestLow from a user selected Bar LookBack, maybe it is a help for you..
simpleHighestHLowestL.mq4
Cheers :)

Tommaso
Author:  Reaper [ Tue Dec 30, 2014 2:03 pm ]
Post subject:  Indicator Request

Yes that is definitely helpful, thank you!
Author:  milanese [ Tue Dec 30, 2014 4:06 pm ]
Post subject:  highestHigh/lowestLow ecc.. Indicator

Angat » Tue Dec 30, 2014 2:03 pm wrote:Yes that is definitely helpful, thank you!
the attached one should do, whatt you requested in your post, I modified a bid, now showing drawLineEveryXBars the highestHigh and the lowestLow I hope this one is helpfull for your, use showHighLowLookBack to select how many bars you want use for the calculations..
simpleHighestHLowestL_mod.mq4
Cheers :)

Tommaso
Author:  Reaper [ Tue Dec 30, 2014 6:47 pm ]
Post subject:  Indicator Request

1. I needed the highest high identified in the lookback range. A vertical line draw across the bar with the highest high.
2. Then I need a vertical line drawn on every 10th bar for the timeframe I'm on using that initial line as the reference point.



Thank you for your efforts for both indicators. I'll try and modify and combine. I think I can do it to achieve what I need.

Much appreciated.

:clap:
Author:  Reaper [ Tue Dec 30, 2014 10:05 pm ]
Post subject:  Indicator Request

Angat » Tue Dec 30, 2014 6:47 pm wrote:1. I needed the highest high identified in the lookback range. A vertical line draw across the bar with the highest high.
2. Then I need a vertical line drawn on every 10th bar for the timeframe I'm on using that initial line as the reference point.



Thank you for your efforts for both indicators. I'll try and modify and combine. I think I can do it to achieve what I need.

Much appreciated.

:clap:
I have managed to do number 1 by amending your code slightly and adding some extra bits. Thank you very much. I'm off the ground! :yahoo:

However I can't get the line to print irrespective of what timeframe I'm viewing. If I change TFs on Empty4 the line changes bars completely. This works fine in your code. I'm not sure what it could be.
Angat_VLines.mq4
It's like Timeframe is hardcoded to 0. But its set as a extern and I change it to 60 in Empty4. I have even tried hardcoding it to 60. No change. It must be to do with my highest bar code at the top.

Any help would be greatly appreciated :)
Author:  milanese [ Tue Dec 30, 2014 10:40 pm ]
Post subject:  Indicator Request

Angat » Tue Dec 30, 2014 10:05 pm wrote:
Angat » Tue Dec 30, 2014 6:47 pm wrote:1. I needed the highest high identified in the lookback range. A vertical line draw across the bar with the highest high.
2. Then I need a vertical line drawn on every 10th bar for the timeframe I'm on using that initial line as the reference point.



Thank you for your efforts for both indicators. I'll try and modify and combine. I think I can do it to achieve what I need.

Much appreciated.

:clap:
I have managed to do number 1 by amending your code slightly and adding some extra bits. Thank you very much. I'm off the ground! :yahoo:

However I can't get the line to print irrespective of what timeframe I'm viewing. If I change TFs on Empty4 the line changes bars completely. This works fine in your code. I'm not sure what it could be.



It's like Timeframe is hardcoded to 0. But its set as a extern and I change it to 60 in Empty4. I have even tried hardcoding it to 60. No change. It must be to do with my highest bar code at the top.

Any help would be greatly appreciated :)

Code: Select all

int highest_bar = iHighest(NULL,TimeFrame,MODE_HIGH,Lookback,0);
int lowest_bar = iLowest(NULL,TimeFrame,MODE_HIGH,Lookback,0);
makes no sense as iHighest and iLowest are double values, I have no idea what you want the indicator to show..

Code: Select all

void DrawVLineHigh(string name,double price,color col,int style,int width)
  {

   ObjectDelete(name);

   ObjectCreate(name,OBJ_VLINE,0,Time[highest_bar],price);
   ObjectSet(name,OBJPROP_COLOR,col);
   ObjectSet(name,OBJPROP_STYLE,style);
   ObjectSet(name,OBJPROP_WIDTH,width);

  }





void DrawVLineLow(string name,double price,color col,int style,int width)
  {

   ObjectDelete(name);

   ObjectCreate(name,OBJ_VLINE,0,Time[lowest_bar],price);
   ObjectSet(name,OBJPROP_COLOR,col);
   ObjectSet(name,OBJPROP_STYLE,style);
   ObjectSet(name,OBJPROP_WIDTH,width);

  }
makes too no sense...
If you could explain what exactly you want to modify on the first version, I can help you and code it..
Cheers :)

Tommaso
Author:  SteveHopwood [ Tue Dec 30, 2014 10:49 pm ]
Post subject:  Indicator Request

Angat, you will have to forgive me for being a bit befuddled here. I am in my usual post tea state of a bit under the affluence of incohol.

I cannot provide the whole solution, is what I am saying because I cannot work it out. I can perhaps point you in the right direction.

I wrestled with a similar problem early on in SHF's days and this snippet forms a part of all my shell codes:

Code: Select all

Code from George, to detect the shift of an order open time
int shift = iBarShift(NULL,Period(),OrderOpenTime(), false);
This provides the shift on any time frame I am investigating, of the open time of a trade. So, the trade might have opened at x on the H4, but the code will provide the shift on any other time frame should I need it. The trade opened on the last H4 candle and I do not want another opening within the next x M15 candles, the iBarShift allows me to calculate whether a trade on the M15 can open.

So, you need to know the candle open time identified by your
double HH_price=iHigh(NULL, TimeFrame, iHighest(NULL, TimeFrame, MODE_HIGH,Lookback,0));

So, if datetime CandleTime = <the open time of the candle identified by your previous code> and SomeTimeFrame = your chosen time frame

then

int shift = iBarShift(NULL,SomeTimeFrame,CandleTime, false); will give you the shift you need to draw the vertical line correctly on any chart time frame.

Sorry if this does not make a lot of sense - perhaps someone unpished can step in and explain it a tad more clearly. I am still enjoying the joysh of Christshmush. hic. I hope enough of it makes sense to point you in the right direction.

I would say that I will have another look in the morning, but it would be a miracle if I even remember that I posted this.

Fantastic to see you getting your sleeves rolled up into the, um, unintricacies of crapql4. It is something that all retail forex traders should do.

Cheershh

hic

:xm:
Author:  Reaper [ Wed Dec 31, 2014 9:23 am ]
Post subject:  Indicator Request

milanese » Tue Dec 30, 2014 10:40 pm wrote:

Code: Select all

int highest_bar = iHighest(NULL,TimeFrame,MODE_HIGH,Lookback,0);
int lowest_bar = iLowest(NULL,TimeFrame,MODE_HIGH,Lookback,0);
makes no sense as iHighest and iLowest are double values, I have no idea what you want the indicator to show..

Code: Select all

void DrawVLineHigh(string name,double price,color col,int style,int width)
  {

   ObjectDelete(name);

   ObjectCreate(name,OBJ_VLINE,0,Time[highest_bar],price);
   ObjectSet(name,OBJPROP_COLOR,col);
   ObjectSet(name,OBJPROP_STYLE,style);
   ObjectSet(name,OBJPROP_WIDTH,width);

  }

void DrawVLineLow(string name,double price,color col,int style,int width)
  {

   ObjectDelete(name);

   ObjectCreate(name,OBJ_VLINE,0,Time[lowest_bar],price);
   ObjectSet(name,OBJPROP_COLOR,col);
   ObjectSet(name,OBJPROP_STYLE,style);
   ObjectSet(name,OBJPROP_WIDTH,width);

  }
makes too no sense...
If you could explain what exactly you want to modify on the first version, I can help you and code it..
Cheers :)

Tommaso
Not sure how else to say it:

1. I needed the highest high identified in the lookback range. A vertical line draw across the bar with the highest high.


So what you did in the first version was to identify the highest high and draw a horizontal line at that price.

I want don't want a horizontal line, I want a vertical line. I want to find the exact bar that made that high and for us to draw a vertical line on that bar.

Then I would like that vertical line to be persistent if extern timeframe != 0.

E.G. User selects 60 timeframe in the indicator settings with a 1000 bar lookback range.

The indicator will search back 1000 bars, find the highest high on the 60 bar TF and print a vertical line on that bar.

Lets say for arguments say it searches back to the 2nd December at 14:00. It determines that the 14:00 on this day had the highest high so it draws the vertical line on this bar.

If the user then selects 30M in Empty4, the vertical line would be still printed on 2nd December at 14:00.



That's the 1st part of the indicator.

The 2nd part is draw a repeating vertical line every Nth number.

You know how you get sessions with vertical lines breaking that up? That's probably one of the most commonest indicators about.

I don't want sessions, I need to be able to select a number e.g. 10 and have vertical lines printed at every 10th bar from the primary vertical bar on the 2nd December 14:00.


So if we had a clean chart with the above settings we would have the following vertical lines

2nd December 14:00 - primary vertical line
3rd December 00:00 - 2nd vertical line
3rd December 10:00 - 3rd vertical line
3rd December 20:00 - 4th vertical line
4th December 6:00 - 5th vertical line
..
and so on going forward.

Many thanks, sorry if this comes across rushed or abrupt, just woke up. Hope this makes sense.
Author:  Reaper [ Wed Dec 31, 2014 9:26 am ]
Post subject:  Indicator Request

SteveHopwood » Tue Dec 30, 2014 10:49 pm wrote:Angat, you will have to forgive me for being a bit befuddled here. I am in my usual post tea state of a bit under the affluence of incohol.

I cannot provide the whole solution, is what I am saying because I cannot work it out. I can perhaps point you in the right direction.

I wrestled with a similar problem early on in SHF's days and this snippet forms a part of all my shell codes:

Code: Select all

Code from George, to detect the shift of an order open time
int shift = iBarShift(NULL,Period(),OrderOpenTime(), false);
This provides the shift on any time frame I am investigating, of the open time of a trade. So, the trade might have opened at x on the H4, but the code will provide the shift on any other time frame should I need it. The trade opened on the last H4 candle and I do not want another opening within the next x M15 candles, the iBarShift allows me to calculate whether a trade on the M15 can open.

So, you need to know the candle open time identified by your
double HH_price=iHigh(NULL, TimeFrame, iHighest(NULL, TimeFrame, MODE_HIGH,Lookback,0));

So, if datetime CandleTime = <the open time of the candle identified by your previous code> and SomeTimeFrame = your chosen time frame

then

int shift = iBarShift(NULL,SomeTimeFrame,CandleTime, false); will give you the shift you need to draw the vertical line correctly on any chart time frame.

Sorry if this does not make a lot of sense - perhaps someone unpished can step in and explain it a tad more clearly. I am still enjoying the joysh of Christshmush. hic. I hope enough of it makes sense to point you in the right direction.

I would say that I will have another look in the morning, but it would be a miracle if I even remember that I posted this.

Fantastic to see you getting your sleeves rolled up into the, um, unintricacies of crapql4. It is something that all retail forex traders should do.

Cheershh

hic

:xm:
Cheers Steve, I think that relates, but you overestimate my MQL4 ability. I'm kinda hitting and hoping here.
All times are UTC Page 1 of 7