Forex
Google
New signals service!

Go Back   Forex Trading > Metatrader Training > Metatrader 4 mql 4 - Development course > Questions


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

Reply
 
LinkBack (2) Thread Tools Display Modes
  #961 (permalink)  
Old 01-28-2008, 01:31 PM
Junior Member
 
Join Date: Dec 2007
Location: Poland, Warsaw
Posts: 6
janekpietrzyk is on a distinguished road
Hi maybe someone knows how to make this ea close trades...
Attached Files
File Type: mq4 # FI sell.mq4 (4.6 KB, 9 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #962 (permalink)  
Old 01-28-2008, 08:59 PM
Putz's Avatar
Junior Member
 
Join Date: Aug 2006
Posts: 24
Putz is on a distinguished road
Thanks Big Be

Hi Big Be,

Thanks for your offer to help. I took the whole program apart into bits and pieces and finally got it to do backtesting. Now I have another issue of it not closing the orders at the right time but I want to try to figure that one out myself. It's the best way to learn. I will keep your contact info if I can't get out of this one.

Thanks again
Putz
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #963 (permalink)  
Old 01-29-2008, 12:54 AM
BornToWin's Avatar
Junior Member
 
Join Date: Nov 2007
Posts: 26
BornToWin is on a distinguished road
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:
Originally Posted by BornToWin View Post
Hi guru,

I have a little prob with my MQL4 code,
i got message ZERO DIVIDE at my experts message.

I'm sure there were no any divide operation will give zero value to my equation.

While i mark some of my code statement with '//', and compile to run,
my code run very well.

After then i open my mark '//' again, at the same place and compile to run again, my code also can run very well again.

If my code have problem, then i'm pretty sure while open the mark '//' an make compilation, my code can't run well, right ?

Is this bugs from MQL4 or i'm write bad code or bad logic on my MQL4 ?

I read from MLQ4 forum, found their explain, that is hard to found why make we got ZERO DIVIDE

Thanks in advanced for one answer this problem
__________________
BornToWin
Veni Vidi Vici
----------------------------------------------------------------
Knowledge is POWER, Experience is SKILL, Action got RESULT !
Yes I CAN !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #964 (permalink)  
Old 01-30-2008, 03:03 AM
Member
 
Join Date: Oct 2006
Posts: 69
Big Be is on a distinguished road
For Putz

You are welcome. I hope it goes well.
Keep learning!

Big Be
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #965 (permalink)  
Old 01-30-2008, 09:57 PM
Putz's Avatar
Junior Member
 
Join Date: Aug 2006
Posts: 24
Putz is on a distinguished road
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);
  }
Thanks,
Putz
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #966 (permalink)  
Old 01-31-2008, 06:05 AM
Member
 
Join Date: Oct 2006
Posts: 69
Big Be is on a distinguished road
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #967 (permalink)  
Old 01-31-2008, 08:40 PM
Putz's Avatar
Junior Member
 
Join Date: Aug 2006
Posts: 24
Putz is on a distinguished road
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #968 (permalink)  
Old 02-01-2008, 05:55 AM
Member
 
Join Date: Oct 2006
Posts: 69
Big Be is on a distinguished road
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #969 (permalink)  
Old 02-01-2008, 09:05 PM
Putz's Avatar
Junior Member
 
Join Date: Aug 2006
Posts: 24
Putz is on a distinguished road
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #970 (permalink)  
Old 02-07-2008, 11:43 AM
Junior Member
 
Join Date: Feb 2008
Posts: 7
ableze_joepardy is on a distinguished road
Noob question from noobie!

post moved here: http://www.forex-tsd.com/metatrader-...-stoc-etc.html
Attached Images
File Type: jpg buy.JPG (6.5 KB, 111 views)

Last edited by ableze_joepardy; 02-08-2008 at 05:53 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
histogram, forex

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

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


All times are GMT. The time now is 08:14 PM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.