Experts: SuperForex V2

 

SuperForex V2:

Working with RSI on Daily chart. Has StopLoss, TakeProffit and trailing stop.

Author: Rafael Maia de Amorim

 

Hi Rafael MAia de Amorim, thanks for sharing your code.



What is your broker ? I don't get the same result on Alpari UK.

 
funyoo:

Hi Rafael MAia de Amorim, thanks for sharing your code.



What is your broker ? I don't get the same result on Alpari UK.


i use LiteForex

[Deleted]  

thxs for sharing, but don't have win with your EA, what are your best settings, please

 
kinonen:

thxs for sharing, but don't have win with your EA, what are your best settings, please

What Symbol do you use, timeframe and spread of your broker?

[Deleted]  

Hi Rafael,

What settings did you use on your back test? and What year and months did you backtest on?

Thanks for sharing your EA.

John

 
johnfilo:


Hi Rafael,

What settings did you use on your back test? and What year and months did you backtest on?

Thanks for sharing your EA.

John

optimize 1 month and two years backtest

i use this setting

Autor=Rafael Maia de Amorim
Desc1=If you make money with this EA, please help me to start..
Desc2=alertpay or paypal: rdamorim@click21.com.br
Desc3=Thanks a lot
TakeProfit=109.00000000
TakeProfit,F=0
TakeProfit,1=6.00000000
TakeProfit,2=1.00000000
TakeProfit,3=150.00000000
StopLoss=9.00000000
StopLoss,F=0
StopLoss,1=6.00000000
StopLoss,2=1.00000000
StopLoss,3=50.00000000
Lots=0.30000000
Lots,F=0
Lots,1=0.10000000
Lots,2=0.00000000
Lots,3=0.00000000
Pos=90.00000000
Pos,F=0
Pos,1=50.00000000
Pos,2=1.00000000
Pos,3=100.00000000
Neg=10.00000000
Neg,F=0
Neg,1=0.00000000
Neg,2=1.00000000
Neg,3=50.00000000
SET=2
SET,F=1
SET,1=2
SET,2=1
SET,3=20
TrailingStop=4
TrailingStop,F=1
TrailingStop,1=1
TrailingStop,2=1
TrailingStop,3=80
NumeroMagico=1000
NumeroMagico,F=0
NumeroMagico,1=1000
NumeroMagico,2=0
NumeroMagico,3=0
MaxLots=5000
MaxLots,F=0
MaxLots,1=100
MaxLots,2=0
MaxLots,3=0

[Deleted]  

Nice results, thanks for sharing.

[Deleted]  

my first ea am building a expert advisor and i need to introduce the indicator ( TrendRSI_v3 ) in expert.

please someone help me in the conditions of the buy and sell

i did it this way but not working

double TrendRsi_Up = iCustom(NULL,0,"TrendRSI_v3",RSIPeriod,EMAPeriod,ATRPeriod,K,1,0);
double TrendRsi_Dn = iCustom(NULL,0,"TrendRSI_v3",RSIPeriod,EMAPeriod,ATRPeriod,K,2,0);

//----------------------------conditions of the sell----------//

if(OrdersTotalMagicbuy(Magicsell)<1)
{


if( TrendRsi_Up == 1){


if(martingale == false){
orderclosebuy(ticketbuy);
}


SellValue = 1;
}

}

//----------------------------conditions of the buy----------//

if(OrdersTotalMagicsell(Magicbuy)<1)
{
if(TrendRsi_Dn == 2){

if(martingale == false){
orderclosesell(ticketsell);
}

BuyValue = 1;

}

}

//-------------------indicator TrendRSI_v3--------------------------//

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Silver
#property indicator_color2 LightBlue
#property indicator_color3 Tomato
//---- input parameters
extern int RSIPeriod=14;
extern int EMAPeriod= 5;
extern int ATRPeriod=14;
extern double K=4.236;//2.618

//---- buffers

double RSIindex[];
double UpTrend[];
double DnTrend[];
double RSIBuffer[];
double smin[];
double smax[];
double trend[];

int MAPeriod=1;
int Price=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- 2 additional buffers are used for counting.
IndicatorBuffers(7);
//---- indicator line
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,RSIindex);
SetIndexStyle(1,DRAW_ARROW);
SetIndexBuffer(1,UpTrend);
SetIndexStyle(2,DRAW_ARROW);
SetIndexBuffer(2,DnTrend);
SetIndexArrow(1,159);
SetIndexArrow(2,159);
SetIndexBuffer(3,RSIBuffer);
SetIndexBuffer(4,smin);
SetIndexBuffer(5,smax);
SetIndexBuffer(6,trend);


//---- name for DataWindow and indicator subwindow label
short_name="TrendRSI("+RSIPeriod+","+EMAPeriod+","+ATRPeriod+","+DoubleToStr(K,3)+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
SetIndexLabel(1,"UpTrend");
SetIndexLabel(2,"DownTrend");
//----

SetIndexDrawBegin(0,RSIPeriod+EMAPeriod+ATRPeriod);
SetIndexDrawBegin(1,RSIPeriod+EMAPeriod+ATRPeriod);
SetIndexDrawBegin(2,RSIPeriod+EMAPeriod+ATRPeriod);
//----
return(0);
}
//+------------------------------------------------------------------+
//| TrendRSI_v3 |
//+------------------------------------------------------------------+
int start()
{
int i,limit,counted_bars=IndicatorCounted();
double rel;
//----

if ( counted_bars < 0 ) return(-1);
if ( counted_bars ==0 ) limit=Bars-1;
if ( counted_bars < 1 )

for( i=1;i<RSIPeriod+EMAPeriod+ATRPeriod;i++)
{
RSIindex[Bars-i]=0.0;
UpTrend[Bars-i]=0.0;
DnTrend[Bars-i]=0.0;
}

if(counted_bars>0) limit=Bars-counted_bars;
limit--;

for( i=limit; i>=0; i--)
{
double sumn=0.0,sump=0.0;
for (int k=RSIPeriod-1;k>=0;k--)
{
rel=iMA(NULL,0,MAPeriod,0,MODE_SMA,Price,i+k)-iMA(NULL,0,MAPeriod,0,MODE_SMA,Price,i+k+1);
if(rel>0) sump+=rel; else sumn-=rel;
}
double pos=sump/RSIPeriod;
double neg=sumn/RSIPeriod;

if(neg==0.0) RSIBuffer[i]=100.0;
else
RSIBuffer[i]=100.0-100.0/(1.0+pos/neg);

RSIindex[i]=RSIindex[i+1]+2.0/(1.0+EMAPeriod)*(RSIBuffer[i]-RSIindex[i+1]);


double AvgRange=0;
for ( k=ATRPeriod-1;k>=0;k--)
AvgRange+=MathAbs(RSIindex[i+k]-RSIindex[i+k+1]);

double Range = AvgRange/ATRPeriod;

smax[i]=RSIindex[i]+K*Range;
smin[i]=RSIindex[i]-K*Range;

trend[i]=trend[i+1];
if (RSIindex[i]>smax[i+1]) trend[i]=1;
if (RSIindex[i]<smin[i+1]) trend[i]=-1;

if(trend[i]>0)
{
if (smin[i]<smin[i+1]) smin[i]=smin[i+1];
UpTrend[i]=smin[i];
DnTrend[i]=EMPTY_VALUE;
}
else
{
if(smax[i]>smax[i+1]) smax[i]=smax[i+1];
UpTrend[i]=EMPTY_VALUE;
DnTrend[i]=smax[i];
}
}
//----
return(0);
}
//+------------------------------------------------------------------+

[Deleted]  
ruiamor:

my first ea am building a expert advisor and i need to introduce the indicator ( TrendRSI_v3 ) in expert.

please someone help me in the conditions of the buy and sell

i did it this way but not working

double TrendRsi_Up = iCustom(NULL,0,"TrendRSI_v3",RSIPeriod,EMAPeriod,ATRPeriod,K,1,0);
double TrendRsi_Dn = iCustom(NULL,0,"TrendRSI_v3",RSIPeriod,EMAPeriod,ATRPeriod,K,2,0);

//----------------------------conditions of the sell----------//

if(OrdersTotalMagicbuy(Magicsell)<1)
{


if( TrendRsi_Up == 1){


if(martingale == false){
orderclosebuy(ticketbuy);
}


SellValue = 1;
}

}

//----------------------------conditions of the buy----------//

if(OrdersTotalMagicsell(Magicbuy)<1)
{
if(TrendRsi_Dn == 2){

if(martingale == false){
orderclosesell(ticketsell);
}

BuyValue = 1;

}

}

//-------------------indicator TrendRSI_v3--------------------------//

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Silver
#property indicator_color2 LightBlue
#property indicator_color3 Tomato
//---- input parameters
extern int RSIPeriod=14;
extern int EMAPeriod= 5;
extern int ATRPeriod=14;
extern double K=4.236;//2.618

//---- buffers

double RSIindex[];
double UpTrend[];
double DnTrend[];
double RSIBuffer[];
double smin[];
double smax[];
double trend[];

int MAPeriod=1;
int Price=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- 2 additional buffers are used for counting.
IndicatorBuffers(7);
//---- indicator line
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,RSIindex);
SetIndexStyle(1,DRAW_ARROW);
SetIndexBuffer(1,UpTrend);
SetIndexStyle(2,DRAW_ARROW);
SetIndexBuffer(2,DnTrend);
SetIndexArrow(1,159);
SetIndexArrow(2,159);
SetIndexBuffer(3,RSIBuffer);
SetIndexBuffer(4,smin);
SetIndexBuffer(5,smax);
SetIndexBuffer(6,trend);


//---- name for DataWindow and indicator subwindow label
short_name="TrendRSI("+RSIPeriod+","+EMAPeriod+","+ATRPeriod+","+DoubleToStr(K,3)+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
SetIndexLabel(1,"UpTrend");
SetIndexLabel(2,"DownTrend");
//----

SetIndexDrawBegin(0,RSIPeriod+EMAPeriod+ATRPeriod);
SetIndexDrawBegin(1,RSIPeriod+EMAPeriod+ATRPeriod);
SetIndexDrawBegin(2,RSIPeriod+EMAPeriod+ATRPeriod);
//----
return(0);
}
//+------------------------------------------------------------------+
//| TrendRSI_v3 |
//+------------------------------------------------------------------+
int start()
{
int i,limit,counted_bars=IndicatorCounted();
double rel;
//----

if ( counted_bars < 0 ) return(-1);
if ( counted_bars ==0 ) limit=Bars-1;
if ( counted_bars < 1 )

for( i=1;i<RSIPeriod+EMAPeriod+ATRPeriod;i++)
{
RSIindex[Bars-i]=0.0;
UpTrend[Bars-i]=0.0;
DnTrend[Bars-i]=0.0;
}

if(counted_bars>0) limit=Bars-counted_bars;
limit--;

for( i=limit; i>=0; i--)
{
double sumn=0.0,sump=0.0;
for (int k=RSIPeriod-1;k>=0;k--)
{
rel=iMA(NULL,0,MAPeriod,0,MODE_SMA,Price,i+k)-iMA(NULL,0,MAPeriod,0,MODE_SMA,Price,i+k+1);
if(rel>0) sump+=rel; else sumn-=rel;
}
double pos=sump/RSIPeriod;
double neg=sumn/RSIPeriod;

if(neg==0.0) RSIBuffer[i]=100.0;
else
RSIBuffer[i]=100.0-100.0/(1.0+pos/neg);

RSIindex[i]=RSIindex[i+1]+2.0/(1.0+EMAPeriod)*(RSIBuffer[i]-RSIindex[i+1]);


double AvgRange=0;
for ( k=ATRPeriod-1;k>=0;k--)
AvgRange+=MathAbs(RSIindex[i+k]-RSIindex[i+k+1]);

double Range = AvgRange/ATRPeriod;

smax[i]=RSIindex[i]+K*Range;
smin[i]=RSIindex[i]-K*Range;

trend[i]=trend[i+1];
if (RSIindex[i]>smax[i+1]) trend[i]=1;
if (RSIindex[i]<smin[i+1]) trend[i]=-1;

if(trend[i]>0)
{
if (smin[i]<smin[i+1]) smin[i]=smin[i+1];
UpTrend[i]=smin[i];
DnTrend[i]=EMPTY_VALUE;
}
else
{
if(smax[i]>smax[i+1]) smax[i]=smax[i+1];
UpTrend[i]=EMPTY_VALUE;
DnTrend[i]=smax[i];
}
}
//----
return(0);
}
//+------------------------------------------------------------------+

[Deleted]  

Hi Rafael,

thanks for sharing this EA, but I get an error while backtesting it: SuperForexV2 EURUSD,Daily: OrderSend error 131

Does this error occure only on my account? How can I solve this?

Thanks