Coding help - page 555

 
mntiwana:
Dearest MLADEN,

thanks boss,so in this case,code might be like this ? please correct me,

regards

===================================================================

original "simple MA cross EA" code

//

#define _doNothing 0

#define _doBuy 1

#define _doSell 2

int start()

{

int doWhat = _doNothing;

double diffc = iMA(NULL,0,Ma1Period,0,Ma1Method,Ma1Price,BarToUse) -iMA(NULL,0,Ma2Period,0,Ma2Method,Ma2Price,BarToUse);

double diffp = iMA(NULL,0,Ma1Period,0,Ma1Method,Ma1Price,BarToUse+1)-iMA(NULL,0,Ma2Period,0,Ma2Method,Ma2Price,BarToUse+1);

if ((diffc*diffp)<0)

if (diffc>0)

doWhat = _doBuy;

else doWhat = _doSell;

if (doWhat==_doNothing) return(0);

//

================================================

altered this way

#define _doNothing 0

#define _doBuy 1

#define _doSell 2

int start()

{

int doWhat = _doNothing;

double diffc = iCustom(NULL,0,"Hull parabolic 2.1",PERIOD_CURRENT,Ma1Period,Ma1Price,2,0 ,0,BarToUse)

-iCustom(NULL,0,"Hull parabolic 2.1",PERIOD_CURRENT,Ma2Period,Ma2Price,2,0 ,0,BarToUse);

double diffp = iCustom(NULL,0,"Hull parabolic 2.1",PERIOD_CURRENT,Ma1Period,Ma1Price,2,0 ,0,BarToUse==2)

-iCustom(NULL,0,"Hull parabolic 2.1",PERIOD_CURRENT,Ma2Period,Ma2Price,2,0 ,0,BarToUse==2);

if ((diffc*diffp)<0)

if (diffc>0)

doWhat = _doBuy;

else doWhat = _doSell;

if (doWhat==_doNothing) return(0);

//

=====================================

mntiwana

Replace this :

double diffp = iCustom(NULL,0,"Hull parabolic 2.1",PERIOD_CURRENT,Ma1Period,Ma1Price,2,0 ,0,BarToUse==2)

-iCustom(NULL,0,"Hull parabolic 2.1",PERIOD_CURRENT,Ma2Period,Ma2Price,2,0 ,0,BarToUse==2);[/PHP]

with this :

[PHP]double diffp = iCustom(NULL,0,"Hull parabolic 2.1",PERIOD_CURRENT,Ma1Period,Ma1Price,2,0 ,0,BarToUse+1)

-iCustom(NULL,0,"Hull parabolic 2.1",PERIOD_CURRENT,Ma2Period,Ma2Price,2,0 ,0,BarToUse+1);
 

ADX Filter help

Hi Pro-Coders,

I would like to implement an ADX filter which shall filter sideways choppy market conditions.

If the ADX is below 25 it should not open trades, I have coded this simple filter:

extern int ADXPeriod=14;

double CurrentADX = iADX(Symbol(),0,ADXPeriod,PRICE_CLOSE,MODE_MAIN,0);

double PreviousADX = iADX(Symbol(),0,ADXPeriod,PRICE_CLOSE,MODE_MAIN,1);

bool ADXfilter=false;

if(CurrentADX>25&&PreviousADX<25)

{

ADXfilter=true;

}

if(ADXfilter=true)

{

BUY();

.

.

SELL();

}

[/CODE]

For some reason the filer is not working. I have put the ADX filter before placing the buy / sell order.

Also putting it to the entry conditions signal is not working.

[CODE]

if(ADXfilter=true && MAFIB=="true" && BUY=="true")

Could someone please advise? Thank you in advance!

 
tfi_markets:
Hi Pro-Coders,

I would like to implement an ADX filter which shall filter sideways choppy market conditions.

If the ADX is below 25 it should not open trades, I have coded this simple filter:

extern int ADXPeriod=14;

double CurrentADX = iADX(Symbol(),0,ADXPeriod,PRICE_CLOSE,MODE_MAIN,0);

double PreviousADX = iADX(Symbol(),0,ADXPeriod,PRICE_CLOSE,MODE_MAIN,1);

bool ADXfilter=false;

if(CurrentADX>25&&PreviousADX<25)

{

ADXfilter=true;

}

if(ADXfilter=true)

{

BUY();

.

.

SELL();

}

[/CODE]

For some reason the filer is not working. I have put the ADX filter before placing the buy / sell order.

Also putting it to the entry conditions signal is not working.

[CODE]

if(ADXfilter=true && MAFIB=="true" && BUY=="true")

Could someone please advise? Thank you in advance!

tfi_markets

Your condition will work only when adx crosses level 25 on a current bar

Use simply this instead :

if(CurrentADX>25) ADXfilter=true;

 
mladen:
mntiwana

Replace this :

double diffp = iCustom(NULL,0,"Hull parabolic 2.1",PERIOD_CURRENT,Ma1Period,Ma1Price,2,0 ,0,BarToUse==2)

-iCustom(NULL,0,"Hull parabolic 2.1",PERIOD_CURRENT,Ma2Period,Ma2Price,2,0 ,0,BarToUse==2);[/PHP]

with this :

[PHP]double diffp = iCustom(NULL,0,"Hull parabolic 2.1",PERIOD_CURRENT,Ma1Period,Ma1Price,2,0 ,0,BarToUse+1)

-iCustom(NULL,0,"Hull parabolic 2.1",PERIOD_CURRENT,Ma2Period,Ma2Price,2,0 ,0,BarToUse+1);

Dearest MLADEN,

again thanks,that portion is done with your kind help,can you please advise what to add/replace in EXTERN (MA1,MA2 method) ,i pointed out in picture.

regards

Files:
10.png  128 kb
 
mntiwana:
Dearest MLADEN,

again thanks,that portion is done with your kind help,can you please advise what to add/replace in EXTERN (MA1,MA2 method) ,i pointed out in picture.

regards

mntiwana

You can delete the ma methods from there. They are not needed any more at all

 
mladen:
mntiwana You can delete the ma methods from there. They are not needed any more at all

Dearest MLADEN,

so much thanks BOSS,for today lesson and improvement it is more than enough,

regards

 

Dear All,

I am looking for the sigmoid function in mql4.This is what I found so far:

//--------------------------- sigmoid() ---------------------------------

// 1/(1+exp(-x))

double sigmoid(double x)

{

if (x>50) return (1);

if (x<-50) return (0);

return (1.0/(1.0+MathExp(-x)));

}//sigmoid()

https://www.mql5.com/en/code/9002 and this debate neural network - Fast sigmoid algorithm - Stack Overflow

Can anyone help?Thanks.

 
nevar:
Dear All,

I am looking for the sigmoid function in mql4.This is what I found so far:

//--------------------------- sigmoid() ---------------------------------

// 1/(1+exp(-x))

double sigmoid(double x)

{

if (x>50) return (1);

if (x<-50) return (0);

return (1.0/(1.0+MathExp(-x)));

}//sigmoid()

https://www.mql5.com/en/code/9002 and this debate neural network - Fast sigmoid algorithm - Stack Overflow

Can anyone help?Thanks.

nevar

one was used here : https://www.mql5.com/en/forum/179686/page13

 

hi mladen ....wowww its better than my indicator.....you are the best..many thanks your help.....many many thank you very much.....sincerely...

 

HI mladen,

did you guys find the bug in my code?

Thanks