Download MetaTrader 5

Parabolic sar based ea

To add comments, please log in or register
silumancumi
69
silumancumi  

Hi everyone,

I'm just a newbie in EA realm... and i'm sorry for my english.. i'm from Indonesia.

i'd like to ask for help in this great forum... i made this EA a couple weeks ago.. it's based on Parabolic SAR in multi time frame.. but i need to change the rule...

In previous rule, the EA waits for all PSAR in all time frame to be the same in direction and the signal for OP comes from direction change in smallest Time Frame.

In current rule, the EA still wait for all PSAR in all time frame to be the same in direction BUT the signal for OP come from any Time Frame. Meaning: Whenever All the PSAR has same direction the EA will take position.

You may want to take a look at my thread of this EA HERE

The EA needs to be changed because current rule will be more promising. Could somebody please help check my code in post #3 bellow? I have forward tested but no OP at all, i don't know what's wrong.

PSAR_EA_02 (Feb05) is coded with previous rule

EA PASAR CUMI v.2 is with current rule (but i'm sure there's something wrong in my coding)

Thanx in advance.

silumancumi
69
silumancumi  

These are screenshots to ilustrate the logic behind the CURRENT RULE, i'm sorry if it's too big.

The green-red bar is Par SAR, take position whenever all the bars have same colour.

silumancumi
69
silumancumi  

EA PASAR CUMI V.2 (current rule), could somebody please tell me what's wrong?

extern double Lots=1;

extern int StopLoss=40;

extern int TakeProfit=20;

extern string txComment="Order PSAR";

extern int MagicNumber=12345;

extern int Slippage=3;

extern int MaxOrders=5;

//Parameter TF0

extern string note1 = "--- Parameter PSar 1 ---";

extern int TF0 = 1;

extern double step0 = 0.005;

extern double maximum0 = 0.2;

//end

//Parameter TF1

extern string note2 = "--- Parameter PSar 2 ---";

extern int TF1 = 5;

extern double step1 = 0.005;

extern double maximum1 = 0.2;

//end

//Parameter TF2

extern string note3 = "--- Parameter PSar 3 ---";

extern int TF2 = 15;

extern double step2 = 0.005;

extern double maximum2 = 0.2;

//end

//Parameter TF3

extern string note4 = "--- Parameter PSar 4 ---";

extern int TF3 = 30;

extern double step3 = 0.005;

extern double maximum3 = 0.2;

//end

//Parameter TF4

extern string note5 = "--- Parameter PSar 5 ---";

extern int TF4 = 60;

extern double step4 = 0.005;

extern double maximum4 = 0.2;

//end

//Parameter TF5

extern string note6 = "--- Parameter PSar 6 ---";

extern int TF5 = 240;

extern double step5 = 0.005;

extern double maximum5 = 0.2;

//end

/*

Minor update by metropolis:

Trailing stop function

5 digits broker issues fixed

one signal for one position

*/

extern int TrailingStop =0;

///////////////////////////////////////

datetime bartime=0;

int tiket;

//+------------------------------------------------------------------+

//| expert initialization function |

//+------------------------------------------------------------------+

int init()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| expert deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| expert start function |

//+------------------------------------------------------------------+

int start()

{

////////////////////////////// 1st Previous Trend ; 1 means Bullish ; 0 means Bearish ///////////////////////////

//// Bullish ////

if (iSAR(NULL,TF0,step0,maximum0,1)<Close[0]) {int TrendP1_0 = 1; string TrendP1_0s="Bullish";}

if (iSAR(NULL,TF1,step1,maximum1,1)<Close[0]) {int TrendP1_1 = 1; string TrendP1_1s="Bullish";}

if (iSAR(NULL,TF2,step2,maximum2,1)<Close[0]) {int TrendP1_2 = 1; string TrendP1_2s="Bullish";}

if (iSAR(NULL,TF3,step3,maximum3,1)<Close[0]) {int TrendP1_3 = 1; string TrendP1_3s="Bullish";}

if (iSAR(NULL,TF4,step4,maximum4,1)<Close[0]) {int TrendP1_4 = 1; string TrendP1_4s="Bullish";}

if (iSAR(NULL,TF5,step5,maximum5,1)<Close[0]) {int TrendP1_5 = 1; string TrendP1_5s="Bullish";}

//// Bearish ////

if (iSAR(NULL,TF0,step0,maximum0,1)>Close[0]) {TrendP1_0 = 0; TrendP1_0s="Bearish";}

if (iSAR(NULL,TF1,step1,maximum1,1)>Close[0]) {TrendP1_1 = 0; TrendP1_1s="Bearish";}

if (iSAR(NULL,TF2,step2,maximum2,1)>Close[0]) {TrendP1_2 = 0; TrendP1_2s="Bearish";}

if (iSAR(NULL,TF3,step3,maximum3,1)>Close[0]) {TrendP1_3 = 0; TrendP1_3s="Bearish";}

if (iSAR(NULL,TF4,step4,maximum4,1)>Close[0]) {TrendP1_4 = 0; TrendP1_4s="Bearish";}

if (iSAR(NULL,TF5,step5,maximum5,1)>Close[0]) {TrendP1_5 = 0; TrendP1_5s="Bearish";}

///////////////////////////////// 2nd Previous Trend ; 1 means Bullish ; 0 means Bearish /////////////////////////

//// Bullish ////

if (iSAR(NULL,TF0,step0,maximum0,2)<Close[0]) {int TrendP2_0 = 1;}

if (iSAR(NULL,TF1,step1,maximum1,2)<Close[0]) {int TrendP2_1 = 1;}

if (iSAR(NULL,TF2,step2,maximum2,2)<Close[0]) {int TrendP2_2 = 1;}

if (iSAR(NULL,TF3,step3,maximum3,2)<Close[0]) {int TrendP2_3 = 1;}

if (iSAR(NULL,TF4,step4,maximum4,2)<Close[0]) {int TrendP2_4 = 1;}

if (iSAR(NULL,TF5,step5,maximum5,2)<Close[0]) {int TrendP2_5 = 1;}

//// Bearish ////

if (iSAR(NULL,TF0,step0,maximum0,2)>Close[0]) {TrendP2_0 = 0;}

if (iSAR(NULL,TF1,step1,maximum1,2)>Close[0]) {TrendP2_1 = 0;}

if (iSAR(NULL,TF2,step2,maximum2,2)>Close[0]) {TrendP2_2 = 0;}

if (iSAR(NULL,TF3,step3,maximum3,2)>Close[0]) {TrendP2_3 = 0;}

if (iSAR(NULL,TF4,step4,maximum4,2)>Close[0]) {TrendP2_4 = 0;}

if (iSAR(NULL,TF5,step5,maximum5,2)>Close[0]) {TrendP2_5 = 0;}

string Signal = "NONE";

static string LastSignal = "NONE";

///////////////////////////// 1st previous Signal ////////////////////////////

if (TrendP1_0==1 && TrendP1_1==1 && TrendP1_2==1 && TrendP1_3==1 && TrendP1_4==1 && TrendP1_5==1)

{int TrendP1=1;} //All 1st prev Bullish

else if (TrendP1_0==0 && TrendP1_1==0 && TrendP1_2==0 && TrendP1_3==0 && TrendP1_4==0 && TrendP1_5==0)

{TrendP1=0;} //All 1st prev Bearish

///////////////////////////// 2nd previous Signal ////////////////////////////

if (TrendP2_0==1 && TrendP2_1==1 && TrendP2_2==1 && TrendP2_3==1 && TrendP2_4==1 && TrendP2_5==1)

{int TrendP2=1;} //All 2nd prev Bullish

else if (TrendP2_0==0 && TrendP2_1==0 && TrendP2_2==0 && TrendP2_3==0 && TrendP2_4==0 && TrendP2_5==0)

{TrendP2=0;} //All 2nd prev Bearish

////////////////////////////// Open Position /////////////////////////////

if (OrdersTotal()<MaxOrders && bartime != Time[0])

{if (TrendP1==1 && TrendP2!=0 && TrendP2!=1) /// if 1st previous ALL bullish, and 2nd previos NOT ALL same signal

{Signal = "LONG (BUY)";

LastSignal = Signal;

tiket = OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Ask-StopLoss*pointt(),Ask+TakeProfit*pointt(),txComment,MagicNumber,0,Green);

if(tiket>0) bartime = Time[0];}

else if

(TrendP1==0 && TrendP2!=0 && TrendP2!=1) /// if 1st previous ALL bearish, and 2nd previous NOT ALL same signal

{Signal = "SHORT (SELL)";

LastSignal = Signal;

tiket = OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,Bid+StopLoss*pointt(),Bid-TakeProfit*pointt(),txComment,MagicNumber,0,Red);

if(tiket>0) bartime = Time[0];}

}

Comment("n",

"n EA PASAR CUMI V.2",

"n",

"n"," Broker time= ",TimeToStr(TimeCurrent()),

"n",

"n"," Trend TF ",(TF0)," M = ",(TrendP1_0s),

"n"," Trend TF ",(TF1)," M = ",(TrendP1_1s),

"n"," Trend TF ",(TF2)," M = ",(TrendP1_2s),

"n"," Trend TF ",(TF3)," M = ",(TrendP1_3s),

"n"," Trend TF ",(TF4)," M = ",(TrendP1_4s),

"n"," Trend TF ",(TF5)," M = ",(TrendP1_5s),

"n"," Last Signal = ",(LastSignal),

"n"," Current Signal = ",(Signal),

"n",

"n"," Equity = ",AccountEquity());

//////////Trailing Stop is here//////////////

for (int i = 0; i < OrdersTotal(); i++)

{

OrderSelect(i,SELECT_BY_POS,MODE_TRADES);

if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber && TrailingStop>0)

{

if(OrderType()==OP_BUY)

{

if(Bid-OrderOpenPrice()>pointt()*TrailingStop)

{

if(OrderStopLoss()<Bid-pointt()*TrailingStop || (OrderStopLoss()==0))

{

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-pointt()*TrailingStop,OrderTakeProfit(),0,CLR_NONE);

return(0);

}

}

}

if(OrderType()==OP_SELL)

{

if((OrderOpenPrice()-Ask)>(pointt()*TrailingStop))

{

if((OrderStopLoss()>(Ask+pointt()*TrailingStop)) || (OrderStopLoss()==0))

{

OrderModify(OrderTicket(),OrderOpenPrice(),Ask+pointt()*TrailingStop,OrderTakeProfit(),0,CLR_NONE);

return(0);

}

}

}

}

}

return(0);

}

//+------------------------------------------------------------------+

double pointt()

{

if(Digits==2) return(0.01);

if(Digits==4) return(0.0001);

if(Digits==5 || Digits==3) return(0.00001);

}
luckytea
9
luckytea  

Modifications

Sorry... I've modified this EA, if it's not correct yet. If it's not satisfy enough, please tell me....

Files:
Linuxser
5916
Linuxser  
luckytea:
kalo masih ada yang kurang bener, kasi tau saya ya....

English please...

jebng
4
jebng  

siumancumi

Any luck with your EA?

Everett
10
Everett  

Can you please provide para 4tf indicator so that ea can be tested.

ChicagoRob
523
ChicagoRob  
Everett:
Can you please provide para 4tf indicator so that ea can be tested.

Yes, I would like that, too. Looks like this could make for a good

manual system.

Rob

traderlab
37
traderlab  
ChicagoRob:
Yes, I would like that, too. Looks like this could make for a good

manual system.

Rob

Try this,hope it helps.regards

Files:
traderlab
37
traderlab  

Voice alert on MTF psar

Greetings to all, Can someone make a voice alert (both buy and sell) with arrows on the attached indicator when all blue or red are in the same direction?

Thanking you in advance

Files:
bnbb2004
270
bnbb2004  
traderlab:
Try this,hope it helps.regards

I'm getting the following error with this indicator. Is this normal?

2009.03.01 22:30:59 4 TF PSAR Bar2 NZDUSDm,M5: ArrayCopySeries function internal error

12
To add comments, please log in or register