molanis.com/forum - Tools for MetaTrader : The place to ask about the best expert advisor builder, expert advisor downloads, and expert advisor programming

AFTER YOU REGISTER SEND US AN EMAIL TO ACTIVATE YOUR ACCOUNT - Before posting:-1- Please read the user guide -2- Try the examples -3- Search in the forum
It is currently Sun Apr 28, 2024 5:14 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 30 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: building custom indicator to show a different TF
PostPosted: Wed Nov 28, 2012 12:23 pm 
Offline

Joined: Fri Feb 04, 2011 9:48 pm
Posts: 114
Location: Canada
Hello

I am trying to build a custom indicator to show a different time frame other than the current one. For example I want to value of a moving average to show the daily value but on a 1 HR chart. On the 1 HR chart it shows a flat line across the period seperator (one day). This way, I can determine what my daily indicator shows while viewing a 1 HR chart. How do I build this please?

I have attached a screen shot from another forum to show you what i mean. The top screen shows what it looks like on a daily window. The bottom chart shows you what it looks like on an hourly chart. Ignore the J2JMA identification as this is just the name of this particular custom indicator.

Can I do this with the current Molanis Custom Indicator software? Thanks for your help.

Attachment:
Screen Shot 2012-11-28 at 9.59.15 AM.png
Screen Shot 2012-11-28 at 9.59.15 AM.png [ 187.17 KiB | Viewed 11345 times ]

_________________
Building a future with automated trading


Top
 Profile  
 
 Post subject: Re: building custom indicator to show a different TF
PostPosted: Wed Nov 28, 2012 12:36 pm 
Offline

Joined: Sun Jun 19, 2011 9:38 pm
Posts: 270
I know of no way to build a stepped MTF indi straight from TIB. Also, if you only change the TF code, you will wind up with something like an interpolated indi (display based on the current chart TF).

Do some mql4 research re: declaring variables, iBarShift, and iTime; and then hardcode it.

_________________
I'm not a programmer, but I play one on TV.


Top
 Profile  
 
 Post subject: Re: building custom indicator to show a different TF
PostPosted: Thu Nov 29, 2012 12:26 am 
Offline

Joined: Fri Feb 04, 2011 9:48 pm
Posts: 114
Location: Canada
Well I may have to do some research like that, but I am thinking of a much easier solution: Just go in the coding and change the TF from 'current' to 'daily'. problem solved, right>?

_________________
Building a future with automated trading


Top
 Profile  
 
 Post subject: Re: building custom indicator to show a different TF
PostPosted: Thu Nov 29, 2012 9:31 am 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
By default the indicator builder create indicators that work on any time frame - the time frame is taken from the chart.
If you want to create indicators for mt4 with a fixed time frame you need to add an extra step:
-first create the custom indicator for any timeframe
-then create a new indicator, click on indicators and select custom indicators. Import the first indicator
You will see something like iCustom(NULL,0,"indicator name", variables,0,i), manually you can set the timeframe, change the code to iCustom(NULL,PERIOD_D1,"indicator name", variables,0,i)
PERIOD_D1 forces the indicator to use the daily timeframe


Top
 Profile  
 
 Post subject: Re: building custom indicator to show a different TF
PostPosted: Thu Nov 29, 2012 4:28 pm 
Offline

Joined: Sun Jun 19, 2011 9:38 pm
Posts: 270
molanisfx wrote:
By default the indicator builder create indicators that work on any time frame - the time frame is taken from the chart.
If you want to create indicators for mt4 with a fixed time frame you need to add an extra step:
-first create the custom indicator for any timeframe
-then create a new indicator, click on indicators and select custom indicators. Import the first indicator
You will see something like iCustom(NULL,0,"indicator name", variables,0,i), manually you can set the timeframe, change the code to iCustom(NULL,PERIOD_D1,"indicator name", variables,0,i)
PERIOD_D1 forces the indicator to use the daily timeframe


Nice! Ye ol indi of an indi trick. I like it. I have more of these than I care to admit.

I just remembered, there is a free #MTF_MovingAverage indi out there. It's made from a template that includes instructions in the comments. It's bascially an indi of an array, which isn't too different from an indi of indi. Biggest difference is it's self contained.

_________________
I'm not a programmer, but I play one on TV.


Top
 Profile  
 
 Post subject: Re: building custom indicator to show a different TF
PostPosted: Thu Nov 29, 2012 5:19 pm 
Offline

Joined: Fri Feb 04, 2011 9:48 pm
Posts: 114
Location: Canada
Hi Molanis

Well I hate to burst your bubble, but that didn't work.
Yes it showed the daily values on the 4 hr chart, but.... it forgot to count 6 candles ( in the 4H Time Frame) for every one daily candle from where it originally gets it value from. In other words for each 4H candle, it assigns the same value on the chart as if it were a daily candle. So the only TF it shows correctly is Daily.
Because lower time frames show a much narrower price scale, the result is values that go all over the place and off the chart.
This indicator doesn't know that it is in a different time frame and assigns the daily value to each candle. If you were to put it on a 15 minute or 5 minute chart for example you wouldn't even see it at all, unless by chance the indicator value happened to be the same or very nearly the same as the price.

Have you got a solution to this?

_________________
Building a future with automated trading


Top
 Profile  
 
 Post subject: Re: building custom indicator to show a different TF
PostPosted: Thu Nov 29, 2012 10:32 pm 
Offline

Joined: Sun Jun 19, 2011 9:38 pm
Posts: 270
If I may...

I didn't realize you were try to make a dual mode MTF indi. There are single mode MTF indi's--show D1 on current TF for example. Then there are show H4 and D1 on current TF for example.

If you really want to avoid coding, try setting up 3 indicators: 1 manually edited D1 indi, 1 manually edited H4 indi, and 1 standard current TF indi that imports the other 2 indi's--this indi doing the importing must have 2 indicator blocks--one for each import.

If you want a current TF mode to show on the current TF, just add a 3rd indicator block to that 3rd indi and leave it set to the current TF (default).

Note that each import creates an iCustom call, and each MA reference creates an iMA call, so I have no idea what all this will use in terms of CPU resources.

_________________
I'm not a programmer, but I play one on TV.


Top
 Profile  
 
 Post subject: Re: building custom indicator to show a different TF
PostPosted: Fri Nov 30, 2012 7:14 am 
Offline

Joined: Fri Feb 04, 2011 9:48 pm
Posts: 114
Location: Canada
Hi rjo

No, I only want a single mode cust indi. This is an MA that I want to show Daily on current TF. I followed Molanis Instructions, and it doesn't show correctly on the chart as in my prev post. I never thought of dual mode indi's. That might be cool too.

But after reading your post, I think I got my answer. I will just change the indi to show in a seperate window instead of on the chart. That way there is no candles involved and the window automatically scales the lines. I can show two windows too - one for daily and one for 4hour. (But not both in the same window because the scaling wouldn't show the daily very well).

Come to think of it, maybe this is what Molanis meant -- His programming is only set up to show in a seperate window. I will let you know....

This is now 3 minutes later -- nope that didn't work either. It shows up in a seperate window, but the indicator doesnt' change display to co-incide with the new dates/times in the lower time frame. Same original problem, so I have to wait until Molanis gets back to me.

Meanwhile I will post the code and Molanis file here. Cheers,


Attachments:
LWMA 3 SHOWS DAILY.moi [2.28 KiB]
Downloaded 857 times
LWMA 3 SHOWS DAILY.mq4 [5.76 KiB]
Downloaded 856 times

_________________
Building a future with automated trading
Top
 Profile  
 
 Post subject: Re: building custom indicator to show a different TF
PostPosted: Fri Nov 30, 2012 10:20 am 
Offline

Joined: Sun Jun 19, 2011 9:38 pm
Posts: 270
AlGer wrote:
Hi rjo

No, I only want a single mode cust indi. This is an MA that I want to show Daily on current TF. I followed Molanis Instructions, and it doesn't show correctly on the chart as in my prev post. I never thought of dual mode indi's. That might be cool too.

But after reading your post, I think I got my answer. I will just change the indi to show in a seperate window instead of on the chart. That way there is no candles involved and the window automatically scales the lines. I can show two windows too - one for daily and one for 4hour. (But not both in the same window because the scaling wouldn't show the daily very well).

Come to think of it, maybe this is what Molanis meant -- His programming is only set up to show in a seperate window. I will let you know....

This is now 3 minutes later -- nope that didn't work either. It shows up in a seperate window, but the indicator doesnt' change display to co-incide with the new dates/times in the lower time frame. Same original problem, so I have to wait until Molanis gets back to me.

Meanwhile I will post the code and Molanis file here. Cheers,


This is what I meant by interpolation versus steps. Again, I don't see a way out of doing SOME BASIC CODING in this case. I will assume you are reluctant to Google a prefab template, so I'm attempting to forcefeed it to you. ;) This will give you steps.


Attachments:
#MTF_MovingAverage.mq4 [4.39 KiB]
Downloaded 817 times

_________________
I'm not a programmer, but I play one on TV.
Top
 Profile  
 
 Post subject: Re: building custom indicator to show a different TF
PostPosted: Fri Nov 30, 2012 12:15 pm 
Offline

Joined: Fri Feb 04, 2011 9:48 pm
Posts: 114
Location: Canada
Hi rjo

Okay got the steps and it is pretty cool. I ddin't know how available these were through searching etc, but yup, that was easy to put in place and I can search for others should I need them. Thanks for the push.

I was actually after a re-calculation on every bar, rather than steps. Since other indicators calculate every bar, this one should be able to as well. There must be a way to change that part as well. Do you know of any? I may have to go searching.... but i am going to take a closer look at the steps, they might work for what i want too.

The reason I wanted it to be continous (recalculate every bar) and not steps is because on a 1 hour chart for example, it would give me 24 different positiions of the LWMA 3 (close) (based on daily values) and I use that value as my open/close to the trade. The unique thing about this MA is that it jumps forward (or back) at the beginning of each new daily candle, thus locking in your profits for the previous day (on an uptrend). If the trend reverses, then price goes ahead of the indicator quite fast (even on a real time basis), and the next day, again, you have locked in profits. It's a very unique concept. It works well on 4 hour and Daily values because 4H and D TF tend to trend more. I think.

The other really cool thing about this indicator is that, on the 1 HOUR chart for example, price can fluctuate and range trade all it wants and it won't trigger multiple enter and exits like other indicators...... as long as it is still in a Daily trend. It doesn't have to be in an hourly trend. The only time you would get range trading trades is at the end of the daily trend or if price came back down to the exact same position as the indicator value. So this is my next quest may be to add a filter for that, but I don't think i could find an effective one. What i do in the meantime, is monitor my trades manually and if they look like they are at an exit point I just exit the trade, lock in my profits, and look for another trade.

Cheers,,,,

_________________
Building a future with automated trading


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 30 posts ]  Go to page 1, 2, 3  Next

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by Molanis © 2009