Coding help - page 554

 

Mntiwana, on Bar to Use if you put zero it will be taking signals on the still opened bar(dangerous for an EA, IMHO) if greater than zero the EA will be getting signals from closed bars back from the open bar, so if you have BarToUse = 2, then your EA will be checking 2 bars back.

 

hi mladen....please help me....ı was posted but ı guess you cant see...ok...ı have a got indicator ...ı need histo version.thank you very much

Files:
trend.ex4  9 kb
trend.mq4  2 kb
 
aress:
hi mladen....please help me....ı was posted but ı guess you cant see...ok...ı have a got indicator ...ı need histo version.thank you very much

aress

Do you have the original (non-decompiled) source code of the indicator? If yes, please post the original mq4 file so that it can be worked on

_________________

PS: you can also check this https://www.mql5.com/en/forum/174961/page4 As far as I see that is it

 

HI guys,

Please take a look into my code.

This indicator calls another indicator with the icustom function.

The problem i'm having is that, sometimes,even when conditions for signals are not met,

this indicator still produces false sound alerts and these false alerts do not display arrows.

I don't know where the problem is. I've tried ( with my limited knowledge) but without success.

How to make sure that the false alert stop? How do i ensure that the sound alert only comes if there is an arrow?

Please help.

Thanks.

int start()

{

int counted_bars=IndicatorCounted();

//----

if(counted_bars>0) counted_bars--;

int limit=Bars-counted_bars;

int j;

for(int i=limit; i>=0; i--)

{

arr_up = EMPTY_VALUE; arr_dn = EMPTY_VALUE;

j=i;

double var1 = 0;

double var2 = 0;

for (j = i; j <= i + 9; j++) var2 += MathAbs(High[j] - Low[j]);

var1 = var2 / 10.0;

double sellprevious = iCustom(NULL,0,"MA-Repaint", FastEMA,SlowEMA,SlowEMA,signal,price,0,i);

double buyprevious = iCustom(NULL,0,"MA-Repaint", FastEMA,SlowEMA,SlowEMA,signal,price,1,i);

static datetime LastAlert;

datetime curbar = Time[0];

if (buyprevious !=EMPTY_VALUE )

{

arr_up=iLow(Symbol(),0,i) - (var1/2);

DrawLine("EntryLine11",iHigh(Symbol(),0,i+1),EntryLineColor);

if ( LastAlert != curbar && !upalert){

Alert (Symbol()," ",Period(),"BUY");

upalert=true;

downalert=false;

LastAlert =curbar;

}

}

else if(sellprevious !=EMPTY_VALUE )

{

arr_dn=iHigh(Symbol(),0,i) + (var1/2);

DrawLine("EntryLine11",iLow(Symbol(),0,i+1),EntryLineColor);

if ( LastAlert != curbar && !downalert){

Alert (Symbol()," ",Period(),"SELL");

downalert=true;

upalert=false;

LastAlert = curbar;

}

}

}

 
luffy:
HI guys,

Please take a look into my code.

This indicator calls another indicator with the icustom function.

The problem i'm having is that, sometimes,even when conditions for signals are not met,

this indicator still produces false sound alerts and these false alerts do not display arrows.

I don't know where the problem is. I've tried ( with my limited knowledge) but without success.

How to make sure that the false alert stop? How do i ensure that the sound alert only comes if there is an arrow?

Please help.

Thanks.

int start()

{

int counted_bars=IndicatorCounted();

//----

if(counted_bars>0) counted_bars--;

int limit=Bars-counted_bars;

int j;

for(int i=limit; i>=0; i--)

{

arr_up = EMPTY_VALUE; arr_dn = EMPTY_VALUE;

j=i;

double var1 = 0;

double var2 = 0;

for (j = i; j <= i + 9; j++) var2 += MathAbs(High[j] - Low[j]);

var1 = var2 / 10.0;

double sellprevious = iCustom(NULL,0,"MA-Repaint", FastEMA,SlowEMA,SlowEMA,signal,price,0,i);

double buyprevious = iCustom(NULL,0,"MA-Repaint", FastEMA,SlowEMA,SlowEMA,signal,price,1,i);

static datetime LastAlert;

datetime curbar = Time[0];

if (buyprevious !=EMPTY_VALUE )

{

arr_up=iLow(Symbol(),0,i) - (var1/2);

DrawLine("EntryLine11",iHigh(Symbol(),0,i+1),EntryLineColor);

if ( LastAlert != curbar && !upalert){

Alert (Symbol()," ",Period(),"BUY");

upalert=true;

downalert=false;

LastAlert =curbar;

}

}

else if(sellprevious !=EMPTY_VALUE )

{

arr_dn=iHigh(Symbol(),0,i) + (var1/2);

DrawLine("EntryLine11",iLow(Symbol(),0,i+1),EntryLineColor);

if ( LastAlert != curbar && !downalert){

Alert (Symbol()," ",Period(),"SELL");

downalert=true;

upalert=false;

LastAlert = curbar;

}

}

}

luffy

Can you please post the called indicator too, so that it can be tested?

 
mrtools:
Mntiwana, on Bar to Use if you put zero it will be taking signals on the still opened bar(dangerous for an EA, IMHO) if greater than zero the EA will be getting signals from closed bars back from the open bar, so if you have BarToUse = 2, then your EA will be checking 2 bars back.

Dearest MLADEN and MRTOOLS,

thanks for kind helps,so sorry for taking much of your time,asking so much ....... .......so in the case of this EA,what is more best and suitable,which Bar should be added.....i want when the slow MA line crossed completely by fast MA line (either way) ......... on second next Bar,trade should be executed,can we code this way that after crossing,how many Bars later trade might be executed,for example after crossing on first Bar,after crossing on second or third Bar ? pictures are attached for better explain the question , thanks

regards

Files:
7.png  35 kb
8.png  38 kb
 

Here are the indicators.

Thanks.

Files:
 
mrtools:
Mntiwana, on Bar to Use if you put zero it will be taking signals on the still opened bar(dangerous for an EA, IMHO) if greater than zero the EA will be getting signals from closed bars back from the open bar, so if you have BarToUse = 2, then your EA will be checking 2 bars back.

Dear MRTOOLS,

did you means .... bar to use = 2 ...... 2 bar after crossing...not 2 N bars , when you write Bars BACK, i confused,my fault....please correct me . thanks.

regards

 
mntiwana:
Dear MRTOOLS,

did you means .... bar to use = 2 ...... 2 bar after crossing...not 2 N bars , when you write Bars BACK, i confused,my fault....please correct me . thanks.

regards

mntiwana

No, but when bars to use == 2, then the crossing will be checked 2 bars from the current bar - it will not check crossing at the current bar. So, with a 2 bars delay

 
mladen:
mntiwana No, but when bars to use == 2, then the crossing will be checked 2 bars from the current bar - it will not check crossing at the current bar. So, with a 2 bars delay

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);

//

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

Files:
9.png  108 kb
Reason: