Forex



Go Back   Forex Trading > Downloads > Expert Advisors - Metatrader 4
Forex Forum Register More recent Blogs Calendar Advertising Others Help






Register
Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.

From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.

Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
  • Elite Section
    Get access to private discussions, specialized support, indicators and trading systems reported every week.
  • Advanced Elite Section
    For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
See more

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 05-03-2006, 10:44 PM
babarmughal's Avatar
Senior Member
 
Join Date: Apr 2006
Posts: 315
babarmughal is on a distinguished road
Smile EA Based on Price Movement

Hi Guys,

Can someone please help me by making a simple EA...which places a BUY order few pips away from the current price.....e.g GBPUSD is 1.8000 what I want EA to do is place BUY order if price goes to 1.8100 and place SELL order if the price drops to 1.7900 with trailing stop.......i dont know what do you call this type of trading.....


Thanks in Advance
Babar
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #2 (permalink)  
Old 05-03-2006, 11:12 PM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 994
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Lightbulb

Quote:
Originally Posted by babarmughal
Hi Guys,

Can someone please help me by making a simple EA...which places a BUY order few pips away from the current price.....e.g GBPUSD is 1.8000 what I want EA to do is place BUY order if price goes to 1.8100 and place SELL order if the price drops to 1.7900 with trailing stop.......i dont know what do you call this type of trading.....


Thanks in Advance
Babar
Babar,

It's call a "Pending Order"

Please use this function to open a pending order:

PHP Code:
int OpenPendingOrder(int pType=OP_BUYLIMIT,double pLots=1,double pLevel=5,int sp=0double sl=0,double tp=0,string pComment="",int pMagic=123,datetime pExpiration=0,color pColor=Yellow)
{
  
int ticket=0;
  
int err=0;
  
int c 0;
  
  switch (
pType)
  {
      case 
OP_BUYLIMIT:
         for(
NumberOfTries c++)
         {
            
ticket=OrderSend(Symbol(),OP_BUYLIMIT,pLots,Ask-pLevel*Point,sp,(Ask-pLevel*Point)-sl*Point,(Ask-pLevel*Point)+tp*Point,pComment,pMagic,pExpiration,pColor);
            
err=GetLastError();
            if(
err==0)
            { 
               break;
            }
            else
            {
               if(
err==|| err==137 ||err==146 || err==136//Busy errors
               
{
                  
Sleep(5000);
                  continue;
               }
               else 
//normal error
               
{
                  break;
               }  
            }
         }
         break;
      case 
OP_BUYSTOP:
         for(
NumberOfTries c++)
         {
            
ticket=OrderSend(Symbol(),OP_BUYSTOP,pLots,Ask+pLevel*Point,sp,(Ask+pLevel*Point)-sl*Point,(Ask+pLevel*Point)+tp*Point,pComment,pMagic,pExpiration,pColor);
            
err=GetLastError();
            if(
err==0)
            { 
               break;
            }
            else
            {
               if(
err==|| err==137 ||err==146 || err==136//Busy errors
               
{
                  
Sleep(5000);
                  continue;
               }
               else 
//normal error
               
{
                  break;
               }  
            }
         }
         break;
      case 
OP_SELLLIMIT:
         for(
NumberOfTries c++)
         {
            
ticket=OrderSend(Symbol(),OP_SELLLIMIT,pLots,Bid+pLevel*Point,sp,(Bid+pLevel*Point)+sl*Point,(Bid+pLevel*Point)-tp*Point,pComment,pMagic,pExpiration,pColor);
            
err=GetLastError();
            if(
err==0)
            { 
               break;
            }
            else
            {
               if(
err==|| err==137 ||err==146 || err==136//Busy errors
               
{
                  
Sleep(5000);
                  continue;
               }
               else 
//normal error
               
{
                  break;
               }  
            }
         } 
         break;
      case 
OP_SELLSTOP:
         for(
NumberOfTries c++)
         {
            
ticket=OrderSend(Symbol(),OP_SELLSTOP,pLots,Bid-pLevel*Point,sp,(Bid-pLevel*Point)+sl*Point,(Bid-pLevel*Point)-tp*Point,pComment,pMagic,pExpiration,pColor);
            
err=GetLastError();
            if(
err==0)
            { 
               break;
            }
            else
            {
               if(
err==|| err==137 ||err==146 || err==136//Busy errors
               
{
                  
Sleep(5000);
                  continue;
               }
               else 
//normal error
               
{
                  break;
               }  
            }
         } 
         break;
  } 
  
  return(
ticket);

__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #3 (permalink)  
Old 05-03-2006, 11:16 PM
babarmughal's Avatar
Senior Member
 
Join Date: Apr 2006
Posts: 315
babarmughal is on a distinguished road
Smile

Thanks CodersGuru,

now how can I get the coding for trailing stop.....can you please help me making this EA....

Thanks
Babar
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #4 (permalink)  
Old 05-04-2006, 03:17 AM
firedave's Avatar
Senior Member
 
Join Date: Nov 2005
Location: Jakarta, Indonesia
Posts: 414
firedave is on a distinguished road
Quote:
Originally Posted by babarmughal
Hi Guys,

Can someone please help me by making a simple EA...which places a BUY order few pips away from the current price.....e.g GBPUSD is 1.8000 what I want EA to do is place BUY order if price goes to 1.8100 and place SELL order if the price drops to 1.7900 with trailing stop.......i dont know what do you call this type of trading.....


Thanks in Advance
Babar
Hi Babar, then what you do with the trade ? If price goes to 1.8100 and fill your BUY order, then move back to 1.8000, what to do ? If price retrace back all the way to fill the SELL order at 1.7900, what to do ? Hope you could give more entry rule / trading plan for this strategy. Just my two cents
__________________
David Michael H
"Trader helps traders with sincerity, honesty and integrity"
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #5 (permalink)  
Old 05-04-2006, 09:38 AM
babarmughal's Avatar
Senior Member
 
Join Date: Apr 2006
Posts: 315
babarmughal is on a distinguished road
Smile

Hi Dave,

Thanks for your reply.....well if the price hits 1.8100 then ofcourse there will be stop loss and trailing stop. and ake Profit will be say 50 pip......price reverses...and will be closed b stop loss...and vice versa for Sell...

Thanks
Babar
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #6 (permalink)  
Old 05-04-2006, 04:12 PM
babarmughal's Avatar
Senior Member
 
Join Date: Apr 2006
Posts: 315
babarmughal is on a distinguished road
Hi Dave ,

Can you please help me in this EA.......Thanks

Babar
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #7 (permalink)  
Old 05-04-2006, 05:51 PM
babarmughal's Avatar
Senior Member
 
Join Date: Apr 2006
Posts: 315
babarmughal is on a distinguished road
Smile

Come on guy ....can you please help me making this EA..........

Thanks in Advance
Babar
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #8 (permalink)  
Old 05-07-2006, 09:45 PM
Senior Member
 
Join Date: Dec 2005
Posts: 130
Pecunia non olet is on a distinguished road
You might find this to be interesting:

http://www.metaquotes.ru/forum/6950/

It might be exactly what you're looking for...

I hope it helps!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #9 (permalink)  
Old 05-08-2006, 06:56 AM
Techguy's Avatar
Junior Member
 
Join Date: Nov 2005
Posts: 26
Techguy is on a distinguished road
CG - You Rule! Thanks for the Error Handling gem!


Quote:
switch (pType)
{
case OP_BUYLIMIT:
for(c = 0 ; c < NumberOfTries ; c++)
{
ticket=OrderSend(Symbol(),OP_BUYLIMIT,pLots,Ask-pLevel*Point,sp,(Ask-pLevel*Point)-sl*Point,(Ask-pLevel*Point)+tp*Point,pComment,pMagic,pExpiration ,pColor);
err=GetLastError();
if(err==0)
{
break;
}
else
{
if(err==4 || err==137 ||err==146 || err==136) //Busy errors
{
Sleep(5000);
continue;
}
else //normal error
{
break;
}
}
}
break;
case OP_BUYSTOP:
for(c = 0 ; c < NumberOfTries ; c++)
{
ticket=OrderSend(Symbol(),OP_BUYSTOP,pLots,Ask+pLe vel*Point,sp,(Ask+pLevel*Point)-sl*Point,(Ask+pLevel*Point)+tp*Point,pComment,pMag ic,pExpiration,pColor);
err=GetLastError();
if(err==0)
{
break;
}
else
{
if(err==4 || err==137 ||err==146 || err==136) //Busy errors
{
Sleep(5000);
continue;
}
else //normal error
{
break;
}
}
}
break;
SUPER! THANK YOU!
__________________
Kind Regards,

Techguy
Never Lose A Password
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #10 (permalink)  
Old 05-08-2006, 08:47 AM
babarmughal's Avatar
Senior Member
 
Join Date: Apr 2006
Posts: 315
babarmughal is on a distinguished road
Smile

Quote:
Originally Posted by Pecunia non olet
You might find this to be interesting:

http://www.metaquotes.ru/forum/6950/

It might be exactly what you're looking for...

I hope it helps!

Cool Stuff

Thanks
Babar
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
PipMaker v1 - Price action based EA don_forex Martingale/Average Cost and Hedging 1871 Yesterday 06:09 PM
Currency - Daily Movement XOLOSIS General Discussion 10 04-02-2007 09:10 AM
Significant Price Movement Alert ToroWinner Indicators - Metatrader 4 0 03-25-2007 10:09 AM


All times are GMT. The time now is 04:36 AM.



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