|
|||||||
| Register in Forex TSD! | |
|
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information |
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Metastock to MT4
MetaStock code for creating the PFE indicator:
Polarized Fractal Efficiency Mov(If(C,>,Ref(C,-9),Sqr(Pwr(Roc(C,9,$),2) + Pwr(10,2)) / Sum(Sqr(Pwr(Roc(C,1,$),2)+1),9),- Sqr(Pwr(Roc(C,9,$),2) + Pwr(10,2)) / Sum(Sqr(Pwr(Roc(C,1,$),2)+1),9))*100,5,E) CAN ANY ONE TRY TO CODIT FOR META TRADER 4 THANKS |
|
|||
|
Metastock to MT4
Hi.
I found this indicator in Metastock and MT3 formats and is very useful to set the stop point . If anybody know Mq4 programming change it into Mq4 I will be appreciated .The Metastock and MT3 codes and description are as below: /*[[ Name := SafeZone Stop Author := Copyright ?2004, MetaQuotes Software Corp. Link := http://www.metaquotes.net/ Separate Window := No First Color := Cyan First Draw Type := Symbol First Symbol := 159 Use Second Data := No Second Color := Red Second Draw Type := Line Second Symbol := 218 ]]*/ Inputs: LookBack(10), StopFactor(3), EMALength(13); Variables: Pen(0), Counter(0), SafeStop(0), EMA0(0), EMA1(0), EMA2(0); Variables: first(True), prevbars(0), loopbegin(0), shift(0), value1(0), PreSafeStop(0); SetLoopCount(0); // Initial checkings If LookBack < 1 or EMALength < 1 Then Exit; If Bars < prevbars Or Bars - prevbars > 1 Then first = True; prevbars = Bars; If first Then Begin loopbegin = Bars - LookBack - 3; If loopbegin < 0 Then Exit; // not enough bars first = False; End; loopbegin = loopbegin + 1; For shift = loopbegin DownTo 0 Begin EMA0 = iMA(EMALength,MODE_EMA,shift); EMA1 = iMA(EMALength,MODE_EMA,shift+1); EMA2 = iMA(EMALength,MODE_EMA,shift+2); PreSafeStop = GetIndexValue(shift+1); Pen = 0; Counter = 0; If EMA0 > EMA1 Then Begin For value1=0 to LookBack Begin If Low[shift+value1] < Low[shift+value1+1] Then Begin Pen = Low[shift+value1+1] - Low[shift+value1] + Pen; Counter = Counter + 1; End; End; If Counter <> 0 Then SafeStop = Close[shift] - (StopFactor * (Pen/Counter)) Else SafeStop = Close[shift] - (StopFactor * Pen); If SafeStop < PreSafeStop and EMA1 > EMA2 Then SafeStop = PreSafeStop; End; If EMA0 < EMA1 Then Begin For value1=0 to LookBack Begin If High[shift+value1] > High[shift+value1+1] Then Begin Pen = High[shift+value1] - High[shift+value1+1] + Pen; Counter = Counter + 1; End; End; If Counter <> 0 Then SafeStop = Close[shift] + (StopFactor * (Pen/Counter)) Else SafeStop = Close[shift] + (StopFactor * Pen); If SafeStop > PreSafeStop and EMA1 < EMA2 Then SafeStop = PreSafeStop; End; PreSafeStop = SafeStop; loopbegin = loopbegin - 1; SetIndexValue(shift,SafeStop); End; I have it on Metastock as well, not sure if it'd be of any use : Quote: ================================ Trailing Stop - Elder's SafeZone ================================ ---8<--------------------------- {Dr Alexander Elder's SafeZone trailing stop v3} { SafeZone types: [1] Uses upside/downside penetration days as suggested by Dr Elder in his book; [2] Uses up/down days (instead of upside/downside penetration days) to match book's companion spreadsheet.} { Triggers: Long (+1) & Short (-1) signals at crossover of user-defined trailing stops.} { ©Copyright 2003-2005 Jose Silva } { For personal use only } { http://www.metastocktools.com } { User inputs } coefficient:=Input("SafeZone coefficient", 0,10,2.5); bkpds:=Input("Lookback periods",1,260,10); pds:=Input("Trend EMA periods",2,260,21); adv:=Input("plot: [1]Today's SafeZone, [2]Tomorrow's stop",1,2,1)-1; type:=Input("SafeZone type: [1]Book, [2]Spreadsheet",1,2,1); plot:=Input("SafeZone: [1]Stop, [2]Long+Short, [3]Signals",1,3,1); { Downside penetrations } DwSidePen:= If(type=1,Mov(C,pds,E)>Ref(Mov(C,pds,E),-1),1) AND L<Ref(L,-1); DwSideDiff:=If(DwSidePen,Ref(L,-1)-L,0); DwPenAvg:=Sum(DwSideDiff,bkpds) /Max(Sum(DwSidePen,bkpds),.000001); StLong:=Ref(L-DwPenAvg*coefficient,-1); StopLong:=If(C<PREV,StLong,Max(StLong,PREV)); { Upside penetrations } UpSidePen:= If(type=1,Mov(C,pds,E)<Ref(Mov(C,pds,E),-1),1) AND H>Ref(H,-1); UpSideDiff:=If(UpSidePen,H-Ref(H,-1),0); UpPenAvg:=Sum(UpSideDiff,bkpds) /Max(Sum(UpSidePen,bkpds),.000001); StShort:=Ref(H+UpPenAvg*coefficient,-1); StopShort:=If(C>PREV,StShort,Min(StShort,PREV)); { Stop signals } entry:=Cross(C,Ref(StopShort,-1)); exit:=Cross(Ref(StopLong,-1),C); { Clean signals } Init:=Cum(IsDefined(entry+exit))=1; bin:=ValueWhen(1,entry-exit<>0 OR Init, entry-exit); entry:=bin=1 AND (Alert(bin<>1,2) OR Init); exit:=bin=-1 AND (Alert(bin<>-1,2) OR Init); { Plot on price chart } If(plot=1,Ref(If(bin=1,stopLong,stopShort), -1+adv),If(plot=2,Ref(stopLong,-1+adv),0)); If(plot=1,Ref(If(bin=1,stopLong,stopShort), -1+adv),If(plot=2,Ref(stopShort,-1+adv), entry-exit)) ---8<--------------------------- http://www.metastocktools.com Description: Quote: 'SafeZone measures market noise and places stops at a multiple of noise level away from the market. We may use the slope of a 22-day EMA to define the trend. You need to choose the length of the lookback period for measuring noise level. It has to be long enough to track recent behaviour but short enough to be revelent for current trading. A period of 10 to 20 days works well, or we can make our lookback period 100 days or so if we want to average long-term market behaviour. If the trend is up, mark all downside penetrations during the look-back period, add their depths, and divide the sum by the number of penetrations. This gives you the Average Downside Penetration for the selected lookback period. It reflects the average level of noise in the current uptrend. Placing your stop any close would be self-defeating. We want to place our stops farther away from the market than the average level of noise. Multiply the Average Downside Penetration by a coefficient, starting with two, but experiment with higher numbers. Subtract the result from yesterday's low, and place your stop there. If today's low is lower than yesterday's, do not move your stop lower since we are only allowed to raise stops on long positions, not lower them. Reverse these rules in downtrends. When a 22-day EMA identifies a downtrend, count all the upside penetrations during the lookback period and find the Average Upside Penetration. Multiply it by a co-efficient, starting with two. When you go short, place a stop twice the Average Upside Penetration above the previous day's high. Lower your stop whenever the market makes a lower high, but never raise it. I anticipate that SafeZone will be programmed into many software packages, allowing traders to control both the lookback period and the multiplication factor. Until then, you will have to do your own programming or else track SafeZone manually. Be sure to calculate it separately for uptrends and downtrends. Also I have a version of this in Mq4 but it doesn’t work properly(the attached file). Thank for your help in advance |
|
||||
|
A code of the MT3
I coded this from the MT3 code above. It is different than the one that you've posted - that one came from a russian forum as I understand it and isn't based on the MT3 code.
I don't have MT3 to test this for validity - do you? If so, I'd love to know if this does what you are looking for. ![]() Cheers, CS
__________________
Join the MultiBroker M1 and TICK Data Bank Project Imagine 90-99% modeling quality in MT4 back testing with free data from your broker! Come see our current list of covered brokers. |
|
|||
|
The code below is metastock format, Can someone help to convert to MT4 ? with option mov preriods change.
It's trend following oscillator, it's can use with break out strategies like price chanel or price chanal with ATR adjusted to make trading system. (see attached picture for a sample system) Bull Power/Bear Power Histogram r1:=If(Ref(C,-1)<O,Max(O-Ref(C,-1),H-L),H-L); r2:=If(Ref(C,-1)>O,Max(Ref(C,-1)-O,H-L),H-L); bull:=If(C=O, If(H-C=C-L, If(Ref(C,-1)>O, Max(H-O,C-L), r1), If(H-C>C-L, If(Ref(C,-1)<O, Max(H-Ref(C,-1),C-L), H-O), r1)), If(C<O, If(Ref(C,-1)<O, Max(H-Ref(C,-1),C-L), Max(H-O,C-L)), r1)); bear:=If(C=O, If(H-C=C-L, If(Ref(C,-1)<O, Max(O-L,H-C), r2), If(H-C>C-L, r2, If(Ref(C,-1)>O, Max(Ref(C,-1)-L,H-C), O-L))), If(C<O, r2, If(Ref(C,-1)>O, Max(Ref(C,-1)-L,H-C), Max(O-L,H-C)))); BB:=Mov(bull-bear,30,S); { need option mov preriods change} slowBB:= mov(BB,89,s); { need option mov preriods change} fastBB:= mov(BB,13,s); { need option mov preriods change} Thank you |
|
||||
|
Hi,
It's so-called Bull And Bear Balance Indicator by Vadim Gimelfarb. And looks very similar to MACD. Igor
__________________
Let's improve trade skills together http://finance.groups.yahoo.com/group/TrendLaboratory |
|
||||
|
correct setup to Metastock (METASTOCK, NOT METATRADER) to backtest
there is not forum for this, but i know that many respected traders like Igor uses Metastock saying that is far more reliable than Metatrader.
so what is the correct setup to do that? if is it correct that Metastock is really reliable, so i think that this topic would be very useful. sorry for my very poor English. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Reliable feeds - Metastock etc | pip-gandalf | Metatrader 4 | 6 | 09-07-2007 09:18 AM |
| link between metatrader and metastock | chartist | Tools and utilities | 0 | 03-06-2007 03:33 PM |
| Moving average from Metastock | maniek | Indicators - Metatrader 4 | 2 | 06-05-2006 11:13 AM |