MQL4 first step - page 2

 

HA...I managed to get an iCustom instruction / function to pull the value from a Moving Average indicator and see the value in the little window where you copy the name and run the script and see the value...

Who is your Master programmer! ;)

A few other questions which are not clear for me based on my reading, please if I may:

1. I notice there is a section on the EA which says onTick and then OnTimer...is the understanding between the two ultimately that if the EA construct is to be triggered based on price movement then onTick is the preference whereas if the construct is based on the chart timing i.e M1 bar open and close then to use the onTimer section of the program?

2. With the iCustom and other built in i[indicators] when the indicator has more than one input do I reference all the additional inputs in the same one line function or do I have to replicate the function same number of times their are inputs for eg. Stochastic Indicator which has kPeriod, dPeriod etc?

3. If my understanding of No1 is correct then can I synchornise my indicator to start with the chart timer i.e if I load the EA which looks at first 5 secs and last 5 seconds of the bar duration, at the chart time of 42secs left on a M1, can I synchronise my EA to run as such or does it just do that automatically?

Thanks guys!


MW

 
MUZZLE_ZA:

1. I notice there is a section on the EA which says onTick and then OnTimer...is the understanding between the two ultimately that if the EA construct is to be triggered based on price movement then onTick is the preference whereas if the construct is based on the chart timing i.e M1 bar open and close then to use the onTimer section of the program?


As yet I have not encountered a single situation where I have needed to use OnTimer.

A bar cannot close and a new one open until a new tick comes in. So if you need to check for a new bar (new bar means the previous must have closed) do it in OnTick 

 
MUZZLE_ZA:

2. With the iCustom and other built in i[indicators] when the indicator has more than one input do I reference all the additional inputs in the same one line function or do I have to replicate the function same number of times their are inputs for eg. Stochastic Indicator which has kPeriod, dPeriod etc?

I do not understand the question
 

Morning Gumrai,

Thanks for your reply. I am now confused on the definition of OnTick. My understanding was that on OnTick is a price change i.e fluctuation of the FXrate independent of time?

MQL reference: Tick is an event characterized by a new price for a symbol at some moment.

Based on the above my initial thought was if a price does not move for a period of 10secs then there is no Tick event for that duration?

Perhaps more clarity is required?

With regards to question 2 I managed to self medicate so happy on that with goal achieved ! - Thank you.

Your turn. :)


MW

 
MUZZLE_ZA:

Morning Gumrai,

Thanks for your reply. I am now confused on the definition of OnTick. My understanding was that on OnTick is a price change i.e fluctuation of the FXrate independent of time?

MQL reference: Tick is an event characterized by a new price for a symbol at some moment.

Yes, you are correct.

Imagine on the M1 chart

a bar opens at 12:01:00

the last tick of the bar comes in at 12:01:59 

at that time we do not know that it is the last tick, there is still time for 1 or more additional ticks

but

the next tick comes in at 12:02:05 and that is the time that the new bar opens and the old one closes. Because there was a 6 second period with no ticks, it is impossible to detect the start of a new bar until a tick comes in. So test for a new bar in OnTick

 

I think I understand what you are telling me.

Then begs the question what is the OnTimer part of the EA for?

If my primary was to look at a period of time and then the action that occurred within that period of time do I not chose the OnTimer then?

In other words I am more interested in what happens between 12:01:00 and 12:02:00: The result could be price increase, price drop or no price action during that period of time?

Hope that makes sense?

 

Morning folks,

I managed to get a programmer friend to help me with the basic ruleset logic after I managed to call all the relevant graphs indicator functions.

The issue now is when I load the EA onto a graph it returns a numerous amount of stochastic alerts instead of the required alert...

I'm not sure if the EA alert is working properly because when I ran it on the strategy tester nothing came back when I know some rulesets should have triggered an alert.

How do I validate that the EA fired an event?

I notice that the EA has a frown face on the chart which if I understand is still fine because I am not interested in allowing live trading?

If I am not doing live trading from the EA and I run the EA on the strat tester should it fire an alert while testing and stop or does it not offer that feature in the tester?

Thanks,


M

 
You do not get pop-up alerts in the strategy tester, but they will be listed in the journal
 

Hey GumRai...

Hope you had a good weekend.

Ok so I opened up the indicator code in the editor and changed the alert values to false so now I don't get spammed the alerts from the stochs divergence when I load the EA. - I hope this doesn't effect my EA adversely.

When I try run the indicator on a M1 chart over 2 days and watch the journal the entries state Custom Indicators xyz: removed - Does this sound like expected behaviour when code is in the OnTick block of program?

Banging head... :)

 

Hi guys,

Is there EA lag of any sort...i.e a few seconds delay in processing the EA?

If my system time differs to the chart time and an alert pops up, which alert time is this, based on my local time or the charts time?

The MqlTick function which brings back the last_tick.bid is this the most recent latest bid tick price?

When I use the OPEN(0) is this the open price of the current candle the ticker is in?

Reason: