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
  #971 (permalink)  
Old 02-07-2008, 10:00 PM
Putz's Avatar
Junior Member
 
Join Date: Aug 2006
Posts: 24
Putz is on a distinguished road
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
HTML Code:
#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<LEma && SEmaP > 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);
  }
//+------------------------------------------------------------------+
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #972 (permalink)  
Old 02-07-2008, 10:16 PM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
Have you verified that your Stochastic RSI takes 3 input parameters?
(The one I looked at takes 4)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #973 (permalink)  
Old 02-08-2008, 12:42 AM
Putz's Avatar
Junior Member
 
Join Date: Aug 2006
Posts: 24
Putz is on a distinguished road
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #974 (permalink)  
Old 02-09-2008, 02:06 PM
Junior Member
 
Join Date: Sep 2006
Posts: 16
aaezz is on a distinguished road
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
Attached Files
File Type: mq4 Pivot_Monday Fixed.mq4 (5.1 KB, 7 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #975 (permalink)  
Old 02-09-2008, 05:03 PM
fxgrm's Avatar
Member
 
Join Date: Mar 2007
Posts: 90
fxgrm is on a distinguished road
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #976 (permalink)  
Old 02-09-2008, 05:15 PM
Senior Member
 
Join Date: Feb 2006
Posts: 519
Michel is on a distinguished road
Quote:
Originally Posted by fxgrm View Post
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #977 (permalink)  
Old 02-09-2008, 08:14 PM
Putz's Avatar
Junior Member
 
Join Date: Aug 2006
Posts: 24
Putz is on a distinguished road
Help again

Hi All,

I've been working on an EA for what seems like an eternity. Thanks to all the people on this thread for all the help they've given me.

I am now stumped again and looking for more help. As we all know, most crossover type of signals from MA's to Stoch's don't work very well because many times it crosses at the end of the move.

What I am trying to do is use Stochastic RSI when it crosses the 50 line but only on the following bar once price has passed either the high or the low by a certain amount of pips (MinPips). My main problem is that when I track the cross, if price only reaches the MinPips on the subsequent bars after the cross but the cross stays in the same direction.

I'm trying to attach a picture to show what I am trying to do.

Point #1 is at a sell cross but since price never passes the low of that bar, no trade is taken (actually, I would like any previous trade to stay active).

Point #2 is at a buy cross but price only passes the high of the bar on the 4th bar after the cross and should be taken at that time. Any previous sell orders should be closed at this time.

I hope this works as it is the first time that I attach a picture. I apologize in advance if I messed up.

Putz
Attached Images
File Type: jpg cross example.jpg (166.9 KB, 119 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #978 (permalink)  
Old 02-09-2008, 08:28 PM
Putz's Avatar
Junior Member
 
Join Date: Aug 2006
Posts: 24
Putz is on a distinguished road
More information

The following is my programming where CurrDir is the current direction and that PrevDir is the previous direction so if it is not equal, then there has been a cross.

The problem is that if it does not cross on the current bar, then CurrDir and PrevDir become equal and it never goes past that bar to see if it reaches the ValHigh or ValLow.

Any help will be appreciated.

Putz

HTML Code:
if(CurrDir != PrevDir)   
   {
    if(CurrDir == 1)
     {
      ValHigh = iHigh(Symbol(),Timeframe2,1) + MinPips*Point;
      if(Bid >= ValHigh)
       {
        return(1); //up
       }
      return (2);
     }  
    
    if(CurrDir == 2)
     {
      ValLow = iLow(Symbol(),Timeframe2,1) - MinPips*Point;
      if(Ask <= ValLow)
       {    
        return(2);//down 
       }
      return (1);
     } 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #979 (permalink)  
Old 02-10-2008, 05:19 AM
Putz's Avatar
Junior Member
 
Join Date: Aug 2006
Posts: 24
Putz is on a distinguished road
Figured out...I think

I think I finally figured out my problem. It is now almost 2:30 am and I'm exhausted so I will check it out tomorrow...

Putz
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #980 (permalink)  
Old 02-11-2008, 03:01 PM
MFM MFM is offline
Junior Member
 
Join Date: May 2007
Posts: 11
MFM is on a distinguished road
Is there a way to change the data format of MT4 export file

I am looking for the ASCII.csv but need the data to be in the following format;

1) separate columns (only need: time, high, low and close)
2) only for the last 1000 bars
3) reverses the order (last on top)
4) saves it in a folder that i already have on my desktop (maybe a browse function to select which one?)

Thanks in advance to anyone that might be able to help me.
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 07:58 AM.



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