I need MQL to MQL4 code transformation

 

Hello,

Can somebody "translate" this code from MQL to MQL4 ?

This is the MT3 indicator and I would like to use it on MT4.

Please post the indicator here(the code or the mq4 file).

Thank you.

/*[[

Name := Inverse Fisher Transform of RSI

Link :=

Separate Window := Yes

First Color := Chartreuse

First Draw Type := Line

First Symbol := 217

Use Second Data := Yes

Second Color := DimGray

Second Draw Type := Line

Second Symbol := 218

]]*/

Inputs:

HiTrigger(0.5), // default=0.5

LoTrigger(-0.5), // default=-0.5

RsiBars(5), // default=5

WmaBars(9), // default=9

info(0), // default=0

;

Variables: // Generic

shift(0),

loopbegin(0),

is_First(True),

prevbars(0),

count(0),

;

Variables: // Specific

Name(\"InvFisher RSI\"),

Value2(0),

IFish(0),

// For manual calc. RSI

SumUp(0),

SumDn(0),

AvgUp(0),

AvgDn(0),

Delta(0),

RSI(0),

// For calc. WMA

WmaNumerator(0),

WmaDenominator(0),

LastTime(0),

PrevAvgUp(0),

PrevAvgDn(0),

cntdown(0),

;

Arrays:

// For calc. generic WMA (weighted moving average)

Value1[40](0),

;

SetLoopCount(0);

//--------------------------------------------------------

// Usage

if info Then Begin

Alert(\"See Terminal>Journal Tab for usage of \\n\",Name);

Print(\"|___________________\");

Print(\"|* \",Name,\" *\");

Print(\"| \",\"Sell: cross under HiTrigger (or under LoTrigger if no prior cross under HiTrigger)\");

Print(\"| \",\"Buy: cross over LoTrigger (or over HiTrigger if no prior cross over LoTrigger)\");

Print(\"|* \",Name,\" *\");

Print(\"|```````````````````\");

End;

//--------------------------------------------------------

// Check Inputs

If 0>HiTrigger or HiTrigger>1 Then Begin

Alert(\"Input Error: must be 0< HiTrigger <1, Cannot=\",HiTrigger);

Exit;

End;

If -1>LoTrigger or LoTrigger>0 Then Begin

Alert(\"Input Error: must be -1< LoTrigger <0, Cannot=\",Lotrigger);

Exit;

End;

If 0>RsiBars or RsiBars>50 Then Begin

Alert(\"Input Error: must be 0< RsiBars <50, Cannot=\",RsiBars);

Exit;

End;

//--------------------------------------------------------

// Check for additional bars loading or total reloadng.

If Bars1 Then is_First=True;

prevbars=Bars;

//--------------------------------------------------------

// Pre-Loop setup

// loopbegin prevents counting of previously plotted bars excluding current Bars

if is_First Then Begin

loopBegin=Bars-1-1;// BarIndexNumber=Shift=Bars-1...0

// Compute the initial AvgUp & AvgDn for RSI

For shift=loopBegin DownTo loopBegin-RsiBars Begin

Delta=C[shift]-C[shift+1];

SumUp=SumUp+max(0,Delta);

SumDn=SumDn-min(0,Delta);

End;

AvgUp=SumUp/RsiBars;

AvgDn=SumDn/RsiBars;

loopBegin=loopBegin-RsiBars;

End;

//--------------------------------------------------------

// loop from loopbegin to current bar (shift=0)

if not is_First Then {

if (Time[0]LastTime) Then {

PrevAvgUp = AvgUp;

PrevAvgDn = AvgDn;

AvgUp = 0;

AvgDn = 0;

For count=WmaBars-1 Downto 1 Begin

Value1[count]=Value1[count-1];

End;

LastTime = Time[0];

}

} Else {

cntdown = 1;

}

For shift=loopbegin Downto cntdown Begin

// Calc RSI manually

Delta=Close[shift]-Close[shift+1];

if is_First Then {

AvgUp=((RsiBars-1)*AvgUp+Max(0,Delta))/RsiBars;

AvgDn=((RsiBars-1)*AvgDn-Min(0,Delta))/RsiBars;

} Else {

AvgUp=((RsiBars-1)*PrevAvgUp+Max(0,Delta))/RsiBars;

AvgDn=((RsiBars-1)*PrevAvgDn-Min(0,Delta))/RsiBars;

}

RSI=100-100/(1+AvgUp/AvgDn);

// Then scale RSI to between -5 and +5

/* Do not use iRSI fctn because it\'s too slow

Value1=0.1*(iRSI(RsiBars,shift)-50); */

Value1[0]=0.1*(RSI-50);

// Use weighted moving average to smooth Value1.

// Ehler suggests could also use EMA, which would be simpler coding at the expense of Alpha.

WmaNumerator=0;

WmaDenominator=0;

For count=WmaBars DownTo 1 Begin

WmaNumerator=WmaNumerator+count*Value1[WmaBars-count-1];

WmaDenominator=WmaDenominator+count;

End;

Value2=WmaNumerator/WmaDenominator;

IFish=(Exp(2*Value2)-1)/(Exp(2*Value2)+1);

SetIndexValue(shift,IFish);

// SetIndexValue(shift,RSI);

// Plot dual-value Trigger Line

If IFish >0 then

SetIndexValue2(shift,HiTrigger)

Else

SetIndexValue2(shift,LoTrigger);

//--------------------------------------------------------

// Update arrays. This technique minimizes array storage and thus allows more signal bars.

If is_First Then For count=WmaBars-1 Downto 1 Begin

Value1[count]=Value1[count-1];

End;

//--------------------------------------------------------

End;

is_First = False;

cntdown = 0;

loopbegin = 0;
 

convert mql to mq4

I will try to knock it out for you this weekend.

What does it do?

 
 

RSI versus other signals

I will give it a run after prime time today; the two are not that different.

I just have a SDJ (stupid day job) right now.

I do almost all MQ4 now, it is really a huge improvement (IMHO) in capability.

I walked away from a great alligator system just because my broker forced me to change.

The biggest question about your really sweet chart is the same question for a lot of great looking charts, do they perfrom in real time as signals occur or they always map in past hindsight perfectly and then get all squirrelly in the tick by tick of the present? I can give lots of indys that map out great looking charts (try the LSMA for example)

Maybe you got something here, it never hurts to run it up the flag and see how she flys, its why they made virtual accounts...

 

Real time

It doesn't "re-paint" the past. That is a real nasty thing made by useless indicators. I remeber the first time I've encountered an indicator that re-painted the past... I got so excited looking at the past signals and then - a massive dissapointment when I saw that in realtime it's useless.

This one works in real time! I'm sure about that.

I can't wait to put it at work. Don't forget to post it here .

Have a nice weekend.

 

Have you finished this indicator?

Hi Roguewave

Have you finished this indicator? Please post it here.

Thanks.

 

Here is my conversion. I am not sure it is correct as I could not compile the code you posted above in the MT3 editor.

 

It looks good to me!

Thanks treberk!

I don't think it's incorrect. It looks good to me!

Good luck and good trades!

 

Hello cucurucu,

In the script (mql for mt3, post 1 ), there are errors :

28;9;1;42;unknown token - token "\"

28;9;1;18;variable init expression error - token "\"

.

 

Hi BrunoFX

I have never used this indicator for MT3 (that particular code I've posted) so it might contain errors. That code is copied from a website.

However, I have seen the Inverse Fisher Transform of RSI on some charts before(different platforms) and I'm glad that this one posted by treberk looks as it should. It has only one minor flaw: the +/- 0.5 levels (HiTrigger & LoTrigger) are not drawn. Instead, is drawn a 0 line. This one can be fixed by adding those levels from the indicator properties window.

Thank you anyway for your info.

Please take a look at the article attached.

 

Hello,

Thank you for this answer and this document. Do you use this indicator? if so, which osnt your rules of exits?

Reason: