You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
where the "..." are in the iCustom() call (before the last two parameters) you can pass the values that would normally used as manual inputs (in the order that they appear on the Inputs dialog).
So, in your indicator use an input like extern int CallFromExpert= 0; and then put a value of 1 into the iCustom() call where the dots are.
Markus
In addition I have suggestion for Slawa,
Can you adopt a system where MetaQuotes would take response like one made by Markus here and simply cut and paste it into the manual. In this case into iCustom() description where "...." existing explanation is.
Slawa,
May be you should have something like "Cut & Paste" response section in this forum where the responder would make response in cut & paste form into MT4 manual.
Just suggestion.
I am sure that there will be repeated questions about unclear matters.
-Stan
where the "..." are in the iCustom() call (before the last two parameters) you can pass the values that would normally used as manual inputs (in the order that they appear on the Inputs dialog).
So, in your indicator use an input like extern int CallFromExpert= 0; and then put a value of 1 into the iCustom() call where the dots are.
Markus
Markus,
Is this suppose to work every time the iCustom() is executed or only once during the initialization.
-Stan
Markus
I am working in M1 frame and there may be 1 to 20 or more ticks before a bar is done. So a finished bar is [i+1] and current bar is [i]. The data may drastically change with any tick so I would like to know at which tick the expert visited my Indicator.
Maybe I do not understand MT4 concept but here is my dilemma.
Bars: |111111111|0000000000|
Tick: |555555555|54_3_2_1_0|
Trade:.....................^
So lets say that during the bar "0" there are 6 tick 5-0 and at the tick 3 my indicator will calculate the optimum condition which I want to trade. However, if I place order based on tick 3 and then bar is shifted to "1" the bar "1" will have close value of tick 5, open value of tick 0, and High/Low during any tick 5-0.
So if I will back test I do not know which value to use close, open, high,low? So the test results will be always different.
FAQ1: Which tick is best to use?.... Tick 0 (open) or Tick 5 (close)
FAQ2: At which tick the Ask/Bid values are generated?..... Tick 0 (open) or Tick 5 (close)
FAQ3: Is expert fired every tick?.... so iCustom() is executed every tick?
the following is more by assumption, but still quite likely: When you run an indicator on live trading (outside the backtester), it will get called on every tick. Calling IndicatorCounted() will tell you that most of the bars are already computed (e.g. 999 of 1000 bars on the chart) so you know that you'll only need to compute Bar[0] (unless you have something like ZigZag where the current value may change previous values). This is also the reason why many badly written indicators who always compute all the bars eat up so much cpu. So usually you do something like: limit= Bars - IndicatorsCounted(); and run a for loop from limit (or limit+1) down to zero.
For each tick, the High[0], Low[0] and Close[0] will be updated ... Open[0] will remain the same. All these values are computed on Bid alone(!).
The backtester does (should do) the same. Your first call to iCustom() will attach the indicator to a virtual chart on which the backtest runs. Then the backtester feeds it's ticks (or the Bid of each tick) into the indicator and will then call your start() function on each tick. Your iCustom() will then simply read the line buffers (or histograms buffers, or arrow buffers) from the indicator.
The decision on how to use it is up to your Expert. Many experts only trade on full bars. If you put something like if (Volume[0]>1) return (0); into the start function, it will return without action on anything but the first tick of a bar. You usually then check indicators for Bar[1] which is the just completed bar. This is useful to avoid too much jitter. For example, on a tick series of {5,4,3,2,1,2,3,4,3,2,4,5} you may experience a two buy signals in between (on the values below 3) where non remains at the closing of the bar. Other experts may want to get an early entry and trade every tick, e.g. to take advantage of {5,4,3,2,1,0} and enter at 3 already, not missing the pips from 3 to 0 (where entering at full bar will enter at zero, three pips after your first signal). Depending on the ticks and system sometimes it either can be better. (Important: When trading full bars, you always look at shift=1 (last bar, Close[1], iCuston(....,1), etc.), when trading ticks, you look at shift= 0).
To verify this, do the following:
In your indicator, before returning put a Print statement, e.g. Print(TimeToString(Time[0]), "INDIE: Sig1[0]= ", Sig1Buffer[0], ", Sig2[0]= ", Sig2Buffer[0]); (whatever signals and buffers you use ... just print the index 0 value).
In the Expert, after calling iCustom, do a print of the values you get there, e.g.
Print(TimeToString(Time[0]), "EXPERT: rc1= ", retsig1, " rc2= ", retsig2, " Bid= ", Bid, " , Ask=", Ask);
Now in life testing look at the Expert tab in the Terminal pane, in backtesting look at the Journal tab of the tester. You should see output from the indicator an expert, and that is a couple of ticks for the same bar with changing values and matching your changing Bid price.
Then you can decide if you just want to trade full bars (by checking Volume[0]==1) or every tick.
Hope this makes sense.
Markus
Markus
Absolutely it does Markus, and I am thankful to you for your gracious effort not only relating to this issue but your effort at all at this forum!
So there is more unknown as I am sliding from a development of the ultimate indicator into the ultimate expert.
FAQ: Can I back test on the tick level or only on the bar level?
-Stan
P.S. Never mind I got it.
Markus
Glad to have been of help ;-)
Markus
Markus,
Taking in consideration all of the above, I am still unclear on iCustom(....,1) and iCustom(....,0)
FAQ1: Can I detect bar 1 or 0 in my indicator?
I am using internally some calculations based on bar 1 when current bar is 0;
So when iCustom(....,1) comes it does not passes "1" to my indicator variables.
Actually I even do not want iCustom(....,1) to do any recalculations since the value is already in the indicator buffer and does not need to be recalculated .
FAQ2: Can I just pick-up indicator-buffer[1] without any recalculations?
-Stan
double iCustom( string symbol, int timeframe, string name, ... , int mode, int shift)
The first three are symbol, timeframe, name ... the last two are mode and shift. Whatever extra values are there are passed as input.
To see how exactly what is requested for recalculation you will need to put some Print commands into your indicator (e.g. inside the loop, or to output the loop variables). This will appear in your expert output.
Markus