Indicator for identifying peaks and lows
Forums › ProRealTime English forum › ProBuilder support › Indicator for identifying peaks and lows
- This topic has 11 replies, 6 voices, and was last updated 7 years ago by Copperwave.
-
-
05/08/2017 at 8:40 PM #34862
Hi Nicholas.
I have an indicator that identifies candle sequences – ascending sequences, and descending sequences.I really want to continue his action.
And on the information obtained from it, create an indicator that identifies peak and low points.Could you please direct me how to do this?
Here’s how it works –
The example is a peak search.
. On Sunday the sequence started to rise
. On Wednesday the rising sequence broke – and a descending sequence began
As soon as the descending sequence begins, the indicator searches between them for the candle with the highest peak of all the candles and marks it as a peak point – with a gray or black arrow down. (Above the candle)
I attach the existing code.
(When the full code is ready, I’d be happy to share it and what you can get from it extensively – with our community members)12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849// find the highest value from squenceif highSeq < high[1] and dec = 0 thenhighSeq = high[1]HBlow = low[1] // Low of highest bar in sequence//Re-set the high of lowest barLBHigh = 10000000000/PIPSizeendif// find the highest value from squenceif lowSeq > low[1] and inc = 0 thenlowSeq = low[1]LBhigh = high[1]// High of lowest bar in sequence//Re-set the Low of highest barHBlow = 0endif// Check if close is higher than high of lowest bar on the sequanceif LBhigh < Close and inc = 0 then// If condition meet, make incremental as true or 1 and decrimental as 0 or falseinc = 1dec = 0// Re-sets decremental sequencelowseq = 10000000000/PIPSize// Darw arrow up when chart is shifted from incremental to decrimentalDRAWARROWUP(barindex, low - ArrowDistance*Pipsize) COLOURED(UpArrowRValue,UpArrowGValue,UpArrowBValue)endif// Check if close is lower than low of highest bar on the sequanceif HBlow > Close and dec = 0 thendec = 1inc = 0// Re-sets incremental sequencehighseq = 0// Darw arrow up when chart is shifted from incremental to decrimentalDRAWARROWDOWN(barindex, high+ArrowDistance*Pipsize) COLOURED(DownArrowRValue,DownArrowGValue,DownArrowBValue)endif// Only for drawing line on the chartif inc = 1 and ShowMA thenDRAWSEGMENT(barindex[1],low[1],barindex,low[0]) COLOURED(0,255,0)endifif dec = 1 and ShowMA thenDRAWSEGMENT(barindex[1],high[1],barindex[0],high[0]) COLOURED(255,0,0)endifreturn //Nothing will be returned because it has to be shown in priceEdited by moderator to make “PRT code” format appear, please use “insert PRT code” button
I very much beg your help – and thank you in advance.
05/09/2017 at 11:07 AM #3491705/09/2017 at 8:00 PM #34982HI Balance
You invited me to work on this on Freelancer.com. Better to do it here can help you for free then.
When you first posted it to me I was looking at the Bill Williams Fractals as a possible solution.https://www.prorealcode.com/prorealtime-indicators/bill-williams-fractals/
This Identifies the pivot points.
05/10/2017 at 9:47 PM #35134Hi Nicholas,
Hope I understood your question correctly.Sequences are not dependent on peaks and lows, but on other conditions.
For example – the condition for a rising sequence is – as long as the closing price of the current candle does not fall below the lowest of the highest candle in the rising sequence.In fact, the peak can only be determined after the ascending sequence has ended, because if I understand correctly, you can not delete arrows after they have already been marked in the graph
05/10/2017 at 10:25 PM #35138Hi StantonR
First of all thank you for your kindness.
And the proposal to use the indicator you mentioned.But, after looking at him, he seemed to have a real flood of arrows.
It seems to me that according to my proposal there will be far fewer (each sequence can have only one point of peak or low)Am I not right? Please write me what you think.
(By the way, you are still invited to accept my invitation.) What is your FREELANCER username?
05/11/2017 at 9:17 AM #35164So let’s try this code and give us your feedbacks about it. Just a rough code, because I’m busy this morning 🙂
12345678910111213141516171819if close>close[1] and close>hightrough then//low of current peaklowpeak = lowendifif close<close[1] and (close<lowpeak or lowpeak=0) then//high of current toughhightrough = highendifif hightrough>hightrough[1] thendrawarrowdown(barindex[1],high[1])coloured(200,0,0)endifif lowpeak<lowpeak[1] thendrawarrowup(barindex[1],low[1])coloured(0,200,0)endifreturn05/12/2017 at 5:23 PM #3534805/12/2017 at 9:14 PM #35364You should use this code instead and get the values of the “up” and “down” variables in your own automated trading strategy:
12345678910111213141516171819202122232425if close>close[1] and close>hightrough then//low of current peaklowpeak = lowendifif close<close[1] and (close<lowpeak or lowpeak=0) then//high of current toughhightrough = highendifif hightrough>hightrough[1] thendrawarrowdown(barindex[1],high[1])coloured(200,0,0)down=1elsedown=0endifif lowpeak<lowpeak[1] thendrawarrowup(barindex[1],low[1])coloured(0,200,0)up=1elseup=0endifreturn up, down05/14/2017 at 9:36 AM #35470Hi Nicholas,
Thanks for the code you submitted. He looked great.
But I have some comments on it to improve,1. There are lots of high and low points, making it difficult to filter.
2 are often not placed in an exact place – for example, you can see in the attached screenshot – a number of low points located in the middle of the rise …According to the definition I raised at the beginning of the topic – there will be far fewer points on the graph.
I have attached two examples. You can see in them that there is a huge difference (75%) in the number of arrows on the graph compared to what is currently there.
So what are you saying ? What do you think ?
Could you please help develop something like this?As mentioned above, I have attached two examples. One – of the results of the code at the moment. And the second – of the desired results according to the definitions I wrote above.
Thanks again.
And a wonderful week.chaim (balance)
05/14/2017 at 9:38 AM #3547205/15/2017 at 11:15 PM #35651If anybody is interested I made a Strategy out of Nicolas Code.
Seemed rude not to! 🙂
GraHalDax 1 Day and I just realised the results below are over only 1000 Days, Oops! It was just a ‘curiosity exercise’ anyway.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859//https://www.prorealcode.com/topic/indicator-for-identifying-peaks-and-lows///Nic HighsLows Dax 1DDEFPARAM CUMULATEORDERS = Falseif close>close[1] and close>hightrough then//low of current peaklowpeak = lowendifif close<close[1] and (close<lowpeak or lowpeak=0) then//high of current toughhightrough = highendifif hightrough>hightrough[1] then//drawarrowdown(barindex[1],high[1])coloured(200,0,0)down=1elsedown=0endifif lowpeak<lowpeak[1] then//drawarrowup(barindex[1],low[1])coloured(0,200,0)up=1elseup=0endifIf Up=1 and Chandle[20](close) > -45 ThenBuy at MarketEndifIf Down=1 and Chandle[20](close) < 35 ThenSellShort at MarketEndif//Alternative Exit//If LongonMarket and Close < ExponentialAverage[190](close) Then//Sell at Market//endif////If ShortonMarket and Close > ExponentialAverage[150](close) Then//Exitshort at Market//endifIf LongonMarket ThenSET TARGET PPROFIT 425SET STOP PTRAILING 725EndifIf ShortonMarket ThenSET TARGET PPROFIT 175SET STOP PTRAILING 400Endif//return up, down05/24/2017 at 6:46 PM #36587Hi – I have been looking into this and while the concept is good, it is asking too much of price action behaviour to work reliably…unless I’m missing something in your signal definitions. The indicator Nicolas prototyped does what you ask. Where it fails, (in terms of too many false positives) is because that is what price action does. Price chop you will get multiple triggers. I think filtering those out requires some sort of lookback comparison in which case then you might as well use a variation of Fractals.
For what its worth I made a small tweak to Nicolas’s code (I added [1] to the high/low statements in the draw sections) that reduces the false positives by about 50% but I think the basic concept is flawed. It will work fine if candles appear in an organised uptrend/downtrend but this rarely happens. It looks good in static analysis but will fail in realtime use – I think 🙂 Still nice idea – but my coding isn’t good enough.
12345678910111213141516171819if (close>close[1]) and (close>hightrough) then//low of current peaklowpeak = lowendifif (close<close[1]) and (close<lowpeak) then//high of current troughhightrough = highendifif hightrough>hightrough[1] thendrawarrowdown(barindex[1],high[1])coloured(200,0,0)hightrough = high[1]endifif lowpeak<lowpeak[1] thendrawarrowup(barindex[1],low[1])coloured(0,200,0)lowpeak = low[1]endifreturnBest
//copperwave
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on