taste? statgey taster?
There are two alternatives for renko/range bars.
- Use a derivative of the period converter to generate an offline chart. EA must be modified to use the original pair/period not Symbol()/Period() when trading. Not sure you can use the strategy tester at all.
- Use a regular chart and convert internally. EA must be modified to calculate ALL indicators internally, but the ST is fine.
Renko internal:
//+------------------------------------------------------------------+ //| Renko Bars | //+------------------------------------------------------------------+ int bars.renko, indicator.counted; // Export to OnTickIndicators int bars.counted; void OnInitRB(){ bars.renko = 0; bars.counted=0; indicator.counted = 0; } double high.renko[], low.renko[], close.renko[]; datetime time.renko[]; void ResizeRenko(){ if (bars.renko > 1000){ // Drop old bars. bars.renko -= 900; indicator.counted -= 900; if (indicator.counted < 0) indicator.counted = 0; ArrayResize( high.renko, bars.renko); ArrayResize( low.renko, bars.renko); ArrayResize(close.renko, bars.renko); ArrayResize( time.renko, bars.renko); } bars.renko++; // Shift bars left. ResizeBuffer( high.renko, bars.renko); ResizeBuffer( low.renko, bars.renko); ResizeBuffer( close.renko, bars.renko); ResizeBufferDt( time.renko, bars.renko); } void OnTickRenkoUpdate(double P, datetime& T){ double renkoSize = Rekno.Size.Pips * pips2dbl; if (bars.renko > 0){ while(P + Point_2 > high.renko[0]){ // at or above low.renko[0] = high.renko[0] - renkoSize; // Low = open close.renko[0] = high.renko[0]; // close = high ResizeRenko(); time.renko[0] = T; T++; high.renko[0] = high.renko[1] + renkoSize; // New bar low.renko[0] = low.renko[1] - renkoSize; // limits. } while(P - Point_2 < low.renko[0]){ // at or below high.renko[0] = low.renko[0] + renkoSize; // high = open close.renko[0] = low.renko[0]; // close = low ResizeRenko(); time.renko[0] = T; T++; high.renko[0] = high.renko[1] + renkoSize; low.renko[0] = low.renko[1] - renkoSize; } } else{ ResizeRenko(); time.renko[0] = T; T++; high.renko[0] = P + renkoSize/2.; low.renko[0] = P - renkoSize/2; } } void OnTickRenko(){ double renkoSize = Rekno.Size.Pips * pips2dbl; for(int iBar = Bars - 1 - bars.counted; iBar >= 0; iBar--){ // Handle double Hi = High[iBar], Cl = Close[iBar], // disconnection Lo = Low[iBar], Op = Open[iBar]; // and initial datetime T = Time[iBar]; static datetime TimeLast; // creation. if (TimeLast != T){ TimeLast = T; // Process a new bar static double lastHi; lastHi = Op; static double lastLo; lastLo = Op; OnTickRenkoUpdate(Op, T); T++; // Handle gaps here. } else if (iBar == 0) T = TimeCurrent(); // Same bar new tick else T = time.renko[0]+1; // Missed some ticks // On new UP bar, go down to low first, then high, then close. if (lastLo > Lo && Cl > Op){ OnTickRenkoUpdate(Lo, T); lastLo = Lo; } if (lastHi < Hi){ OnTickRenkoUpdate(Hi, T); lastHi = Hi; } if (lastLo > Lo){ OnTickRenkoUpdate(Lo, T); lastLo = Lo; } OnTickRenkoUpdate(Cl, T); Polyline("rHi",high.renko[1],Orange,iBar); Polyline("rLo", low.renko[1],Orange,iBar); } // iBar lastHi = High[0]; lastLo = Low[0]; bars.counted = Bars - 1; CallAgain(high.renko[0]-Point,"rH"); // At or above, CallAgain( low.renko[0]+Point,"rL"); // the limit. } // OnTickRenko double adx.fract[2], // Export NewOrder tsl.ma.value, tsl.std.value, // \ Export to atr.value; // / SetStops void OnTickIndicators(){ if (indicator.counted < 1) indicator.counted = 1; // Look back (TR/pdm) int limit = bars.renko - 1 - indicator.counted; if (limit > 0){ // All bars but zero. indicator.counted = bars.renko - 1; tsl.ma.value = iMAOnArray(close.renko,0,TSL.MA.Length, 0, TSL.MA.Mode, 1); tsl.std.value = iStdDevOnArray(close.renko,0,TSL.MA.Length, TSL.MA.Mode, 0, 1); double atrAlpha = 2.0/(1+ATR.Length), adxAlpha = 2.0/(1+ADX.Length); for (int iBar = limit; iBar > 0; iBar--){ // Don't process bar zero! double TR = MathMax(high.renko[iBar], close.renko[iBar+1]) // True - MathMin( low.renko[iBar], close.renko[iBar+1]); // range atr.value += atrAlpha*(TR - atr.value); // I use EMA for simplicity, mql4 ATR uses SMA. if (TR > 0) { double // Directional movement. pdm = MathMax(0, high.renko[iBar+1] - high.renko[iBar+2]), ndm = MathMax(0, low.renko[iBar+2] - low.renko[iBar+1]); if (pdm<ndm) pdm=0; // Only the largest else if (ndm<pdm) ndm=0; // Movement is counted. // The ADX/DMI use a 0-100 range. I use 0-1.00 for efficiency static double pDMId, nDMId; pDMId += adxAlpha*(pdm/TR - pDMId); nDMId += adxAlpha*(ndm/TR - nDMId); double DMId = pDMId-nDMId; // Average Directional Index double div = pDMId+nDMId; if (div>0) { // averages from DMI double tmp = MathAbs(DMId)/div; adx.fract[1] = adx.fract[0]; // Save previous Renko value adx.fract[0] += adxAlpha*(tmp - adx.fract[0]); } } } // iBar } Polyline("sma", tsl.ma.value,White); }Rest of my code here.
taste? statgey taster?
There are two alternatives for renko/range bars.
- Use a derivative of the period converter to generate an offline chart. EA must be modified to use the original pair/period not Symbol()/Period() when trading. Not sure you can use the strategy tester at all.
- Use a regular chart and convert internally. EA must be modified to calculate ALL indicators internally, but the ST is fine.
Renko internal:
Rest of my code here.
ok thnks for reply
but i also got now another method for this renko back _taste
http://www.forexfactory.com/showthread.php?t=204485 :)
Q: How to back test using off-line charts?
A: MetaTrader allows for back testing only on standard time frames like 1-5-15-30-60...
Therefore you need a following trick to do it:
1. go to the c:\Program Files\MetaTrader\history folder. You should see subfolders with
trading servers feeds.
2. make a new subfolder with the name CRB
3. go to one of your trading servers folders ( folder should be in history\xxxx_server) and
copy the following files into history\CRB folder:
- symbols.raw
- symbols.sel
- symgroups.raw
- ticks.raw
- 1 min data, e.g. EURUSD1.hst, GBPUSD1.hst, USDCHF1.hst, etc
4. start MetaTrader and manually log in into account but write CRB in the server field, off
course there will be no connection.
5. restart MetaTrader to clean its preloaded data (you should see Waiting for update on all
charts except 1 min).
6. drop CRB script on 1 min chart but now select a standard TimeFrame to generate, for
example 5 min.
7.
I followed this a few days back. Although I couldn't figure out how to do the backtest, at least I can generate the offline chart in Renko look.
I try to do the same today but I can't get the offline chart again. Is it because it's weekend now and there is no live data to tick the live chart and EA and so no offline data/chart could be generated?
Many thanks for your advice!
ok thnks for reply
but i also got now another method for this renko back _taste
http://www.forexfactory.com/showthread.php?t=204485 :)
Q: How to back test using off-line charts?
A: MetaTrader allows for back testing only on standard time frames like 1-5-15-30-60...
Therefore you need a following trick to do it:
1. go to the c:\Program Files\MetaTrader\history folder. You should see subfolders with
trading servers feeds.
2. make a new subfolder with the name CRB
3. go to one of your trading servers folders ( folder should be in history\xxxx_server) and
copy the following files into history\CRB folder:
- symbols.raw
- symbols.sel
- symgroups.raw
- ticks.raw
- 1 min data, e.g. EURUSD1.hst, GBPUSD1.hst, USDCHF1.hst, etc
4. start MetaTrader and manually log in into account but write CRB in the server field, off
course there will be no connection.
5. restart MetaTrader to clean its preloaded data (you should see Waiting for update on all
charts except 1 min).
6. drop CRB script on 1 min chart but now select a standard TimeFrame to generate, for
example 5 min.
7.
I try to do the same today but I can't get the offline chart again. Is it because it's weekend now and there is no live data to tick the live chart and EA and so no offline data/chart could be generated?
Figure it out, by giving a manual tick the chart that your renko generator is placed to. You can use this script to make a tick (dll-s must be enabled):
I can generate a 2-min offline data but can't generate a 5-min one after following step 1-7 above. When I arrive at step 5, I don't see "Waiting for update on all
charts except 1 min". All charts just stay there. Is it because I am in weekend again?
Anyway, I continue to run the 'Tick' given by Erzo but it doesn't help. Still the 5-min 'EURUSD5.hst' remains unmodified. Even if I delete the EURUSD5.hst in the 'CRB' folder, I don't see it being re-created.
Any hint why nothing seems could be created?
Anyway, I continue to run the 'Tick' given by Erzo but it doesn't help. Still the 5-min 'EURUSD5.hst' remains unmodified. Even if I delete the EURUSD5.hst in the 'CRB' folder, I don't see it being re-created.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use