| New signals service! | |
|
|||||||
| Register in Forex TSD! | |
|
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information |
|
![]() |
|
|
LinkBack (2) | Thread Tools | Display Modes |
|
||||
|
I Found the problem ! TQ for let me post here !
Just found the problem and how to solve,
I'm using function MarketInfo(Symbol(),MODE_POINT) without any trade / history record, That function only show data from pointed record. I change my code to Point ( predefined variable ) It seems same problem with : MarketInfo(Symbol(),MODE_BID) should change to Bid MarketInfo(Symbol(),MODE_ASK) should change to Ask Quote:
__________________
BornToWin Veni Vidi Vici ---------------------------------------------------------------- Knowledge is POWER, Experience is SKILL, Action got RESULT ! Yes I CAN ! |
|
||||
|
Hi All,
I thought I was getting somewhere...but it seems that I'm at a dead end again. I took the Simple Ema cross from Coder's guru and tried to make it work with Stochastic RSI. I have two main problems. 1) It's not placing any orders. Even when I had it working, it was placing orders against the Stochastic RSI trend. 2) I know it's going to place an order as soon as it is activated. I want it to wait until a "new cross" happens but i have no idea how to do that. If there's anyone that can help me, I would appreciate it. It would also help my learning if you could explain your solution to these problems. The following is the pared down version of my Ea that is not working: HTML Code:
//| Bruno StochRSI Expert v4.mq4 |
//| Copyright © 2007, MetaQuotes Software Corp. |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, Putz Canada Corp"
#property link "http://www.Putzfx,com"
extern string Expert_Name = "Albatross v4";
extern int MagicNumber = 757595;
//---- input parameters
extern double TakeProfit=0;
extern double StopLoss = 0;
extern double MinPips = 25;
extern double ValHigh=0;
extern double ValLow=0;
extern double Lots=0.1;
extern bool ExitOnCross = true;
extern int Slippage = 3.0;
extern double SL1=150;
extern double Ret1=75;
double TPA = 500;
double SL = 500;
double CurrentLow = 1000;
double CurrentHigh = 0;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert FreshCross function |
//+------------------------------------------------------------------+
int FreshCross ()
{
double StochRSICurr, StochRSIPrev, Level1, Level2;
StochRSICurr = iCustom(Symbol(),PERIOD_H1,"Stochastic RSI",8,12,9,0,1);
Level1 = 50;
StochRSIPrev = iCustom(Symbol(),PERIOD_H1,"Stochastic RSI",8,12,9,0,2);
Level2 = 50;
if(StochRSICurr > Level1 && StochRSIPrev < Level2)
return(1); //up
if(StochRSICurr < Level1 && StochRSIPrev > Level2)
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);
}
int isCrossed = 0;
isCrossed = FreshCross ();
total = CheckOpenTrades();
if(total < 1)
{
if(isCrossed == 1)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-TPA*Point,Ask+TPA*Point,"Albatross_v4",MagicNumber,0,Black);
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) //down
{
ticket = OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+TPA*Point,Ask-TPA*Point,"Albatross_v4",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);
}
}
total = OrdersTotal();
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber() == MagicNumber)
{
if(OrderType()==OP_BUY) // long position is opened
{
if(ExitOnCross && isCrossed == 2)
{
OrderClose(OrderTicket(),OrderLots(),Ask,3,Black); // close position
return(0); // exit
}
}
else
{
if(ExitOnCross && isCrossed == 1)
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,Black); // close position
return(0); // exit
}
}
}
}
return(0);
}
Putz |
|
|||
|
Putz' EA
Putz,
Well, I set it up and made some progress. the indicator I have is 'Stochastic_RSI', not 'Stochastic RSI', so I changed that in iCustom and it takes trades. Then I get 2 errors in Strat tester: Tester: exchange rate cannot be calculated and Zero Divide. That's all I can do tonight. Good Luck. Big Be |
|
||||
|
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 |
|
|||
|
Re: Speed
Study what I did for a Volatility Quality Index EA I fixed, Kiko_v2.
See post 319 here: Volatility Quality Index Have fun, Big Be |
|
|||
|
Noob question from noobie!
post moved here: http://www.forex-tsd.com/metatrader-...-stoc-etc.html
Last edited by ableze_joepardy; 02-08-2008 at 05:53 AM. |
![]() |
| Bookmarks |
| Tags |
| histogram, forex |
| Thread Tools | |
| Display Modes | |
|
|
LinkBacks (?)
LinkBack to this Thread: http://www.forex-tsd.com/questions/270-ask.html
|
||||
| Posted By | For | Type | Date | |
| OzFx System:) - Page 639 | This thread | Refback | 06-21-2008 09:53 PM | |
| Forex SRDC Sidus Sibkis EA MT4 Forum OTCSmart | This thread | Refback | 12-08-2007 11:46 AM | |