Ask! - page 97

 

Still problems

Hi All,

Thanks Big Be for taking a look at my EA. My Stochastic RSI is without the underline. When I tried it with, it gave me an error. But, I did find out a few things.

1) When I try Strategy Tester on the lower time frames, it seems to work faster. Once I get to H1 or over, it gets really slow. I assume that is because it has to do too much checking on every tick. Is there anything that can be done about that? I would like to optimize it for H4 and possibly even Daily.

2) There is still the problem with the first trade happening before an actual cross.

3) When I look at my backtests, it seems to miss out on some trades completely. Is that because my data is flawed/mismatched? I checked around a found a place where New Digital explains how to get the data for the broker that we are using by going to history and double clicking on it...then opening each time frame and holding "Page Up" until it reaches the end but, it did not seem to help.

The portion of the program that I sent you is only one part of 3. I still have to add the other 3 parts into it. If I can't get the Strategy Tester to get faster, I'll never know if it's a profitable idea.

Any ideas or suggestions will be helpful.

Regards,

Putz

 

Study what I did for a Volatility Quality Index EA I fixed, Kiko_v2.

See post 319 here:

https://www.mql5.com/en/forum/general

Have fun,

Big Be

 

Vq

Hi Big Be

Thanks for the idea. I will work on it this weekend...and if everything works fantastic...I should be rich by next weekend...hahaha

Putz

 

Help...please

Hi Big Be and all programmers,

Big Be, I studied your volatility EA but it now seems that was not my problem after all. I was using IBFX for my backtesting and had nothing but problems. I finally gave up and downloaded Alpari and that works a lot better.

At least now it doesn't take days to do a backtest on my EA's. So I started all over and re-built my program from scratch and it doesn't place any orders.

The program is basically codersguru's EMS Fresh Cross but I want it to be based on Stochastic RSI and when StochRSI crosses the 50 line. I have left almost everything as per codersguru including variables to make it easier to isolate the problem.

I believe the problem is in the iCustom function as that is basically the only changes that I have made to the program and it does not take any orders. Can someone look at it and see if they can find my mistake. I have been trying for two weeks to get this to work and it is driving me nuts.

I have put a couple of notes preceded by //

Thanks

Putz

#property copyright "Putz FX

#property link "http://www.putzfx.com"

//---- input parameters

extern double TakeProfit=130;

extern double StopLoss = 60;

extern double Lots=1;

extern double TrailingStop=30;

extern double TimeFrame= 60;

extern bool ExitOnCross = true;

extern int MagicNumber = 444444;

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

//| expert initialization function |

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

int init()

{

//----

//----

return(0);

}

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

//| expert deinitialization function |

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

int deinit()

{

//----

//----

return(0);

}

int FreshCross ()

{

//This was added in based on what I could figure from Big Be.

if (Volume[0] != 1) return(0);

//what is the difference between using "Null" or "Symbol()" in iCustom as

//neither one works.

double SEma, LEma,SEmaP, LEmaP;

//The following 4 lines have been changed from the original

SEma = iCustom(Symbol(),PERIOD_H1,"Stochastic RSI",28,55,9,0,0);

LEma = 50;

SEmaP = iCustom(Symbol(),PERIOD_H1,"Stochastic RSI",28,55,9,0,1);

LEmaP = 50;

//Don't work in the first load, wait for the first cross!

//some changes were done to the below two lines as he was comparing the

//return value with the Ask or Bid and Close values

if(SEma>LEma && SEmaP < LEmaP) return(1); //up

if(SEma LEmaP) return(2); //down

return (0); //not changed

}

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

//| Check Open Position Controls |

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

int CheckOpenTrades()

{

int cnt;

int NumTrades; // Number of buy and sell trades in this symbol

NumTrades = 0;

for(cnt=OrdersTotal()-1;cnt>=0;cnt--)

{

OrderSelect (cnt, SELECT_BY_POS, MODE_TRADES);

if ( OrderSymbol() != Symbol()) continue;

if ( OrderMagicNumber() != MagicNumber) continue;

if(OrderType() == OP_BUY ) NumTrades++;

if(OrderType() == OP_SELL ) NumTrades++;

}

return (NumTrades);

}

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

//| expert start function |

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

int start()

{

//----

int cnt, ticket, total;

double TP;

if(Bars<100)

{

Print("bars less than 100");

return(0);

}

/* if(TakeProfit<10)

{

Print("TakeProfit less than 10");

return(0); // check TakeProfit

}

*/

int isCrossed = 0;

isCrossed = FreshCross ();

total = CheckOpenTrades();

if(total < 1)

{

if(isCrossed == 1)

{

TP = 0;

if (TakeProfit > 0) TP = Ask + TakeProfit * Point;

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-StopLoss*Point,TP,"EMA_CROSS",MagicNumber,0,Green);

if(ticket>0)

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());

}

else Print("Error opening BUY order : ",GetLastError());

return(0);

}

if(isCrossed == 2)

{

TP = 0;

if (TakeProfit > 0) TP = Bid - TakeProfit * Point;

ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+StopLoss*Point,TP,"EMA_CROSS",MagicNumber,0,Black);

if(ticket>0)

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());

}

else Print("Error opening SELL order : ",GetLastError());

return(0);

}

return(0);

}

total = OrdersTotal();

for(cnt=0;cnt<total;cnt++)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

//OrderPrint();

if(OrderType()<=OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber() == MagicNumber)

{

if(OrderType()==OP_BUY) // long position is opened

{

// should it be closed?

/* REMOVED - Trailling stop only close */

if(ExitOnCross && isCrossed == 2)

{

OrderClose(OrderTicket(),OrderLots(),Bid,3,Black); // close position

return(0); // exit

}

/**/

// check for trailing stop

if(TrailingStop>0)

{

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

{

if(OrderStopLoss()<Bid-Point*TrailingStop)

{

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);

return(0);

}

}

}

}

else // go to short position

{

// should it be closed?

/* REMOVED - Trailling stop only close */

if(ExitOnCross && isCrossed == 1)

{

OrderClose(OrderTicket(),OrderLots(),Ask,3,Black); // close position

return(0); // exit

}

/* */

// check for trailing stop

if(TrailingStop>0)

{

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

{

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

{

OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);

return(0);

}

}

}

}

}

}

return(0);

}

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

Have you verified that your Stochastic RSI takes 3 input parameters?

(The one I looked at takes 4)

 

that helps

Hi Ralph,

Thanks for your help. Mine has two buffers but 4 input parameters. I tried it with 4 parameters and that did not work but then I tried it with 2 and I got an order. Now I just have to work out the rest. Thanks for getting me unstuck.

Putz

 

Noob question from noobie!

post moved here: https://www.mql5.com/en/forum

Files:
buy.jpg  7 kb
 

any one help me?

hi all

all you know the Pivot_Monday_fixed indicator

i need some changes in this indicator

i want only the pivot line and another four lines

2 blue color Pivot +20 and Pivot + 40

2 red color Pivot - 20 and Pivot - 40

only 5 lines

thanks

Files:
 

Dumb question

Can someone tell me the quickest way to convert an EA's mq4 file to an ex4 file?

I know it shows up in experts files as ex4 after running on mt4 once but is this the only way to do this?

Thanks in advance

 
fxgrm:
Can someone tell me the quickest way to convert an EA's mq4 file to an ex4 file?

I know it shows up in experts files as ex4 after running on mt4 once but is this the only way to do this?

Thanks in advance

Open your .mq4 file in the MetaEditor, then clic "Compile" and the .ex4 file is create.