Stop Loss Code needed to add to this 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 EA needs stop loss

 
gangsta1:
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.

your code may look like this:

add this line after "extern int TP = 200;"

extern double SL = 20.0; //your sellstop

next lines past after this statement

"if (TimeHour(TimeCurrent())==ChasStart && TimeMinute(TimeCurrent())==0)"

double price_buy = Bid+Step*Point;

double price_sell = Ask-Step*Point;

double slipage = 100;

double stoploss_buy = price_buy - SL*Point;
double stoploss_sell = price_sell + SL*Point;

double takeprofit_buy = price_buy + TP*Point;

double takeprofit_sell = price_sell - TP*Point;

OrderSend(Symbol(),OP_BUYSTOP,Lots,price_buy,slipage,stoploss_buy,takeprofit_buy,"",12321,0,Green);

OrderSend(Symbol(),OP_SELLSTOP,Lots,price_sell,slipage,stoploss_sell,takeprofit_sell,"",12321,0,Red);

 

Hi, Here I am posting url here, It will definitely works for you.

All the best

SVOS Multi-Indicator EA - MQL4 Code Base

 

Dear Nexxua,

Good day.

I have been FT this EA and apparently it is giving good results. It is giving an average of 25-30 USD daily. The problem is that it is also having around 1-2 positions that goes above 18USD negative killing the profit it had made. This EA doesnt have MM or SL, and its TP i have no clue how it works. I did try this week to add, but as i am no coder i tried to get a sample from others EAs codes which had this features. When compiling it showed no error, but

eventhough it appeared the SL to be placed it never worked.

My idea is to place a SL so the negative position would not reach a level to compromise the profit. As i said, I also dont understand its rules for closing positions (i have had -0,50USD closed, but it didnt close the -18USD as to TP working in the same way) ..but my main problem is with SL. Maybe it would be good to add a new TP with the decision to enable it or not...

Could you guys kindly help me with it?

Also, if you have the knowlegde of an EA that perfoms this type of profit I would love to get their names.

Thanks a lot!!!

Nexxua:
your code may look like this: add this line after "extern int TP = 200;" extern double SL = 20.0; //your sellstop next lines past after this statement "if (TimeHour(TimeCurrent())==ChasStart && TimeMinute(TimeCurrent())==0)" double price_buy = Bid+Step*Point; double price_sell = Ask-Step*Point; double slipage = 100; double stoploss_buy = price_buy - SL*Point;
double stoploss_sell = price_sell + SL*Point;
double takeprofit_buy = price_buy + TP*Point; double takeprofit_sell = price_sell - TP*Point; OrderSend(Symbol(),OP_BUYSTOP,Lots,price_buy,slipage,stoploss_buy,takeprofit_buy,"",12321,0,Green); OrderSend(Symbol(),OP_SELLSTOP,Lots,price_sell,slipage,stoploss_sell,takeprofit_sell,"",12321,0,Red);
Files:
Reason: