Trend Indi for levels

Post Reply
User avatar
McNish
Trader
Posts: 227
Joined: Tue Nov 06, 2012 3:56 pm

Trend Indi for levels

Post by McNish »

Hello Everyone,

I want to request a trend indicator to show up trend or down trend based on round numbers on a 5 digit broker. By round numbers i mean the full, half and quarter levels of price. For EU they would be something like 1.22000 (full), 1.22250 or 1.22750 (quarter), 1.22500 (half).

For example if the last round number that EU touched was 1.23500 and prior to that the round number that it touched was 1.23750, the trend would be Down. That means EU travelled from 1.23750 to 1.23500, thus the trend is Down.
Similarly, if the last RN touched was 1.23250 and the RN touched before that was 1.23000, the trend would be up. That means the EU travelled from 1.23000 to 1.23250, thus the trend is UP.

This is an element for an idea for possiable automation. I have the shell EA and the code for other elements. Hopefully some will lend a helping hand. Much Obliged.

Cheers, Max. :D
User avatar
SteveHopwood
Owner
Posts: 9904
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Trend Inid for levels

Post by SteveHopwood »

McNish » Tue Feb 06, 2018 8:59 pm wrote:Hello Everyone,

I want to request a trend indicator to show up trend or down trend based on round numbers on a 5 digit broker. By round numbers i mean the full, half and quarter levels of price. For EU they would be something like 1.22000 (full), 1.22250 or 1.22750 (quarter), 1.22500 (half).

For example if the last round number that EU touched was 1.23500 and prior to that the round number that it touched was 1.23750, the trend would be Down. That means EU travelled from 1.23750 to 1.23500, thus the trend is Down.
Similarly, if the last RN touched was 1.23250 and the RN touched before that was 1.23000, the trend would be up. That means the EU travelled from 1.23000 to 1.23250, thus the trend is UP.

This is an element for an idea for possiable automation. I have the shell EA and the code for other elements. Hopefully some will lend a helping hand. Much Obliged.

Cheers, Max. :D
I am not, absolutely not preventing indi coders from stepping in here and helping out. Please do, if you feel so inclined indi coders.

Fact is Max, that this is the sort of post they would have reacted favourably to back when SHF started. Not so any more.

SHF has moved so far from its origination that it is sometimes hard to believe it is still the same forum.

In many ways, it is not. So many ways.

Nowadays, you have to offer coders a reason to code the indi/EA you want i.e. show some evidence of successful manual trading using your method before the coders will step in and generate what you want.

Give this some thought.

:xm:
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.

To see The Weekly Roundup of stuff you guys might have missed Click here

My special thanks to Thomas (tomele) for all the incredible work he does here.
User avatar
McNish
Trader
Posts: 227
Joined: Tue Nov 06, 2012 3:56 pm

Trend Inid for levels

Post by McNish »

Sire, :hi:

Thank you for the forum, once again. :good:

I get your point very well. I'll do the code today.

Cheers & Regards, Max :D
User avatar
McNish
Trader
Posts: 227
Joined: Tue Nov 06, 2012 3:56 pm

Trend Indi for levels

Post by McNish »

Your Highness,

Have managed to put together sembelance of a code, but it freezes the platform when i put it on a chart.
Can i upload the code file here with a request to be looked into it and rectified?

:D
User avatar
tomele
Administrator
Posts: 1208
Joined: Tue May 17, 2016 3:40 pm
Location: Germany, Forest of Odes, Defending the Limes

Trend Indi for levels

Post by tomele »

Dont ask, just do. Doesnt mean I will look into it, but there are enough coders here.
Happy pippin, Thomas :-BD

It ain't what you don't know that gets you into trouble.
It's what you know for sure that just ain't so.
(Mark Twain)

Keep the coder going: Donate
User avatar
renexxxx
Trader
Posts: 860
Joined: Sat Dec 31, 2011 3:48 am

Trend Indi for levels

Post by renexxxx »

Max,

I have provided hereby some utility code in a script to help you work out the round number problem.

The issue is this: When does price touch a round number? This needs to be defined in order to create code for it. One might say: price touches a round number, if the candle encompasses a round number between the LOW and the HIGH. The highest level of resolution of historical prices is on the M1 timeframe. So, we can iterate over the M1 candles starting at candle 0 and working our way back, to find two candles that encompass a round number. But what if a M1 candle encompasses two or more round numbers? This might not happen a lot, but it does happen. In that case we have no option to discard that candle.

The attached code provides some snippets and the main function (getRoundNumberTrend) that you can use to your hearts content.

Have fun.
You do not have the required permissions to view the files attached to this post.
User avatar
McNish
Trader
Posts: 227
Joined: Tue Nov 06, 2012 3:56 pm

Trend Indi for levels

Post by McNish »

Thanks Tomaso, :)

Hello Rene,
Yes, u are right about the issues you pointed out. I had to bang my head for the limited knowledge i have for coding. Then i wrote the logic down on paper and tried to find a starting point.

The solution i developed works like this.

I will start with a starting point, LookBackBars. Have locked it at 250. Also u r bang on about the timeframe & i too reached the same conclusion about the 1M TF.

So i start at 250 bars behind the current bar on 1M TF. Of that bar, i take the close prie as the anchor price to start with. Taking that anchor price, i look for the fork of the price web, i,e next RN above and below anchor price. Then i start to see if price touched either of the fork prices by checking the high and low of the 1m on every subsequent bar. When that happens, initial trend is established & i reset the anchor point as the RN that was just touched. This is the initial iteration with break call.

Next is the main iteration where the NewAnchorPrice derived from the RN just touched is taken as reference and New Forks of RN are derived and set. Also, this time, the lookback bars are re-set to the bar on which the price touched the RN Fork. So with the new Forks of RN and new value of LookBackBars, i go forward with the same excercise of looking if Low or High of subsquent bars touched either of fork of RN. And when that happens, trend is determined.

Last night when i finished the code and put it on the chart, nothing happened and the chart froze. Today when i did the same, the trend arrow draws on the RHS of the chart but still the chart freezes.

Thus am uploading the code here if you or others want to have a look at it and suggest edits. BTW, the code of finding the RN fork is not mine, rest everything else is. And the Mini Me that i am for code, i was quite delighted by myself that i could actually phantom the logic and put it in the form of code and complie without errors. :clap:

Please suggest the edits required. Your guidance and assistance is always valuable to me, and am sure to many others as well.

Cheers & Regards, Max, :D
You do not have the required permissions to view the files attached to this post.
heart1010
Trader
Posts: 56
Joined: Wed Mar 30, 2016 8:33 pm

Trend Indi for levels

Post by heart1010 »

renexxxx » Fri Feb 09, 2018 3:42 am wrote:Max,

I have provided hereby some utility code in a script to help you work out the round number problem.

The issue is this: When does price touch a round number? This needs to be defined in order to create code for it. One might say: price touches a round number, if the candle encompasses a round number between the LOW and the HIGH. The highest level of resolution of historical prices is on the M1 timeframe. So, we can iterate over the M1 candles starting at candle 0 and working our way back, to find two candles that encompass a round number. But what if a M1 candle encompasses two or more round numbers? This might not happen a lot, but it does happen. In that case we have no option to discard that candle.

The attached code provides some snippets and the main function (getRoundNumberTrend) that you can use to your hearts content.

Have fun.
Thanks for that rennexxxx :good:
Post Reply

Return to “Coders Hangout”