Please fix this indicator or EA - page 2

 

Indicator from 1st post is repainting...

But im not sure.

 

.

not only it repaints...it places signal one or two bars behind:)))...that's insane...

 

just 4 info- also ind. 3MA_Cross_AlertWarnSigL_NegShift (mladen) here:https://www.mql5.com/en/forum

 

Need Help adding an filter

I am testing attached artificial intelligence on EUR/USD 15 min After optimising Get good results Fixed stop loss, Trailing Stop & Reverse orders are excellent However The number of losing trades is high Can Somebody add a filter to reduce the number of losing trades I am also attaching another EA which is self optimising Maybe both of them can be combined

 

Ea wil not trade

Hi Codersguru,

Someone has helped me build my own EA, works fine in back test but will not trade on demo or live account, what should I look for or change in the script.?

Thanks, your help is appreciated

Kind Regards

Win

 

Need help to write a simple EA

I presently use a indicator called riskyachtar and would like someone to create an EA for me where if its red and its value is at or below -0.030 it would trigger a sell signal (or close a previous buy if there was one)and if its green and it is at or above 0.030 it would trigger a buy signal (closing the previous sell). I am new to using EA's. I am using the mt4 platform and would also like to know how to add the EA to it and use it

 

Stop Loss Code needed to add to EA

Hi All,

I am attempting to backtest an EA, however in order to do so efficiently I need to add a stop loss sunction.

Can anyone please provide me with some code to add to my EA? I do have money management EA's, but I cannot run them simultaneously iwith my EA during backtesting.

Many Thanks,

Rich.

P.S. The EA code is at (https://www.mql5.com/en/code/mt4)

 

Problem with my EA

Hello,

I'm working on an EA that retrieves the closing price of the last closed bar i.e. bar[1] using the hour timeframe. My initial assumption was that once the hour changed lets say from 11:59:59 to 12:00:00 close price of the bar would be the opening price of the next bar unless a new tick came in. That assumption was obviously wrong as the new doesn't update until a new tick comes in. What a stupid idea that was.

Timing on this EA is critical and I need to tally up the close price for the last closed bar for each pair asap after the new bar opens. The problem is if I'm reading say bar[1] for gbpusd at 12:00:00 but a new tick doesn't come in until say 12:00:05, then I'm getting data from what should now be bar[2].

So I Created a function that that gets the current server time and the open time for bar[0] then use the hour (12) for each to compare. If the server time hour is 12 and the open time hour for bar[0] is 12 then I assume the bar has updated. If not, I use the bid price for bar[0] to plug in as the close price for bar[1]. Most of the time this works fine.

But every so often, the times for the comparison are not updating even though the bar on the chart has clearly updated. Here is the code that checks to see of the bar has updated.....

My EA doesn't use the 1 minute window but I coded it in for debugging so I don't have to wait an hour for a bar to close.

Also, this EA does not use the start() function. All of the code is called from the init() function so it runs continuously regardless of ticks.

Can anyone shed some light on why this would occasionally fail?

bool bHasBarUpdated(string sSymbolName)

{

datetime tCurrentBarOpenTime, tCurrentServerTime, tPreviousBarOpenTime;

int iCurrentBarOpenTime, iCurrentServerTime, iPreviousBarOpenTime, iDifference;

RefreshRates();

tPreviousBarOpenTime=iTime(sSymbolName,iTimeFrame,iBar_Shift);

tCurrentBarOpenTime =iTime(sSymbolName,iTimeFrame,0);

tCurrentServerTime=TimeCurrent();

switch(iTimeFrame) //extract the hour from the time to make the comparison

{

case 1: //minute TF

iCurrentBarOpenTime = StrToInteger(StringSubstr(TimeToStr(tCurrentBarOpenTime,TIME_DATE|TIME_SECONDS),14,2));

iCurrentServerTime = StrToInteger(StringSubstr(TimeToStr(tCurrentServerTime,TIME_DATE|TIME_SECONDS),14,2));

break;

case 60: //1 hour TF

iCurrentBarOpenTime = StrToInteger(StringSubstr(TimeToStr(tCurrentBarOpenTime,TIME_DATE|TIME_SECONDS),11,2));

iCurrentServerTime = StrToInteger(StringSubstr(TimeToStr(tCurrentServerTime,TIME_DATE|TIME_SECONDS),11,2));

break;

default:

Print("Time Frame Not Supported");

return(TRUE);

}

iDifference=iCurrentServerTime-iCurrentBarOpenTime;

if(iDifference==0)

return(true);

return(False);

}

 

buggy indicator

hello

i have this indicator but the sound and the indicator don't work. If you compile it has an error.

Part of the code with a problem is as follows

here is the code as well as the indicator.....I would be very grateful for your time as well as your solution.

int start()

{

double thisCCI;

double lastCCI;

int counted_bars = IndicatorCounted();

if (counted_bars < 0) return (-1);

if (counted_bars > 0) counted_bars--;

int limit = Bars - counted_bars;

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

{

thisCCI = iCCI(NULL, 0, CCI, PRICE_TYPICAL, shift);

lastCCI = iCCI(NULL, 0, CCI, PRICE_TYPICAL, shift + 1);

if (thisCCI >= 0 && lastCCI < 0) bufferUp[shift + 1] = bufferDn[shift + 1];

if (thisCCI 0) bufferDn[shift + 1] = bufferUp[shift + 1];

if (thisCCI >= 0)

{

bufferUp[shift] = Low[shift] - iATR(NULL, 0, ATR, shift);

if (bufferUp[shift] < bufferUp[shift + 1])

bufferUp[shift] = bufferUp[shift + 1];

}

else

{

if (thisCCI <= 0)

{

bufferDn[shift] = High[shift] + iATR(NULL, 0, ATR, shift);

if (bufferDn[shift] > bufferDn[shift + 1])

bufferDn[shift] = bufferDn[shift + 1];

}

}

}

//---- signals

shift=limit-1;

while(shift>=0)

{

if (Signals==true)

{

if (bufferUp < bufferDn && bufferUp[shift] < bufferDn[shift + 1] && TurnedUp==false);

if (bufferUp > bufferDn && bufferUp[shift] > bufferDn[shift + 1] && TurnedUp==true);

// if (ind_buffer2a=ind_buffer1a) ind_buffer3=ind_buffer2a-0.0001;

// if (ind_buffer2a>ind_buffer1a && ind_buffer2a<=ind_buffer1a) ind_buffer4=ind_buffer2a+0.0001;

// if (ind_buffer3[0]==ind_buffer2a[0]-0.0001 && TurnedUp==false)

{

Alert("Trend Magic Buy: ",Symbol()," - ",Period()," at ", Close[0]," - ", TimeToStr(CurTime(),TIME_SECONDS));

TurnedDown = false;

TurnedUp = true;

}

// if (ind_buffer4[0]==ind_buffer2a[0]+0.0001 && TurnedDown==false)

{

Alert("Trend Magic SELL: ",Symbol()," - ",Period()," at ", Close[0]," - ", TimeToStr(CurTime(),TIME_SECONDS));

TurnedUp = false;

TurnedDown = true;

}

}

shift--;

}

//---- done

return (0);

Files:
 
reddy:
Hi All,

I am attempting to backtest an EA, however in order to do so efficiently I need to add a stop loss sunction.

Can anyone please provide me with some code to add to my EA? I do have money management EA's, but I cannot run them simultaneously iwith my EA during backtesting.

Many Thanks,

Rich.

P.S. The EA code is at (21hour.mq4 - MQL4 Code Base)

I suppose it should be something like in attach.

Files:
Reason: