Forex



Go Back   Forex Trading > Programming > Metatrader Programming






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
 
Thread Tools Display Modes
  #1 (permalink)  
Old 06-05-2009, 05:10 AM
ajk's Avatar
ajk ajk is offline
Senior Member
 
Join Date: Dec 2005
Posts: 261
ajk is on a distinguished road
no longer hedging ?

Since hedging is not allowed anymore... does anyone have any trade ea manager or something that would reverse the trade immediately after close when a trade hits a stop loss...
or can any one show me how to add a pending order as a sell (below is a buy) so that it triggers as soon as sl is hit?
Thoughts?
ANy help appreciated!.

int OpenOrder(int type)
{
int ticket=0;
int err=0;
int c = 0;

if(type==OP_BUY)
{
for(c = 0 ; c < NumberOfTries ; c++)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage ,Ask-StopLoss*Point,Ask+TakeProfit*Point,ExpertComment, MagicNumber,0,Yellow);
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;
}
}
}
}
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 06-06-2009, 02:07 AM
wolfe's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 816
wolfe is on a distinguished road
Quote:
Originally Posted by ajk View Post
Since hedging is not allowed anymore... does anyone have any trade ea manager or something that would reverse the trade immediately after close when a trade hits a stop loss...
or can any one show me how to add a pending order as a sell (below is a buy) so that it triggers as soon as sl is hit?
Thoughts?
ANy help appreciated!.

int OpenOrder(int type)
{
int ticket=0;
int err=0;
int c = 0;

if(type==OP_BUY)
{
for(c = 0 ; c < NumberOfTries ; c++)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage ,Ask-StopLoss*Point,Ask+TakeProfit*Point,ExpertComment, MagicNumber,0,Yellow);
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;
}
}
}
}
Something like this should work, as long as your s/l is greater than the MarketInfo(Symbol(),MODE_STOPLEVEL).

PHP Code:
 int OpenOrder(int type)
  {
   
int ticket=0;
   
int err=0;
   
int c 0;
   
double StopLoss_SellStop_Open =0;

   if(
type==OP_BUY)
    {
     for(
NumberOfTries c++)
      {
       
StopLoss_SellStop_Open Ask-StopLoss*Point;
       
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage ,StopLoss_SellStop_Open,Ask+TakeProfit*Point,"ExpertComment"MagicNumber,0,Yellow);
       
err=GetLastError();
       if(
err==0)
        {
         
OrderSend(Symbol(),OP_SELLSTOP,Lots,StopLoss_SellStop_Open,Slippage,NULL,NULL,"ExpertComment",MagicNumber,0,Red);
         break;
        }
       else
        {
         if(
err==|| err==137 ||err==146 || err==136//Busy errors
          
{
           
Sleep(5000);
           continue;
          }
         else 
//normal error
          
{
           break;
          }
        }
      }
    } 
You of course would have to decide what to do for your s/l and t/p for the pending order.
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 06-06-2009, 03:09 AM
Member
 
Join Date: Dec 2008
Posts: 37
wannaberich is on a distinguished road
You can still hedge with a lot of brokers, my broker still allows hedging and could not care what robot you use or if you win or lose. Just shop around you will still find many brokers that you can hedge with!

Quote:
Originally Posted by ajk View Post
Since hedging is not allowed anymore... does anyone have any trade ea manager or something that would reverse the trade immediately after close when a trade hits a stop loss...
or can any one show me how to add a pending order as a sell (below is a buy) so that it triggers as soon as sl is hit?
Thoughts?
ANy help appreciated!.

int OpenOrder(int type)
{
int ticket=0;
int err=0;
int c = 0;

if(type==OP_BUY)
{
for(c = 0 ; c < NumberOfTries ; c++)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage ,Ask-StopLoss*Point,Ask+TakeProfit*Point,ExpertComment, MagicNumber,0,Yellow);
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;
}
}
}
}
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 06-08-2009, 12:16 AM
ajk's Avatar
ajk ajk is offline
Senior Member
 
Join Date: Dec 2005
Posts: 261
ajk is on a distinguished road
thanks for the potential programming!.

Last edited by ajk; 06-09-2009 at 03:25 AM.
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 06-09-2009, 03:24 AM
ajk's Avatar
ajk ajk is offline
Senior Member
 
Join Date: Dec 2005
Posts: 261
ajk is on a distinguished road
Quote:
Originally Posted by ajk View Post
thanks for the potential programming!.
It was working sweet...however, IBFX "stated HEdge not allowed" even though. My buy stop / sell stop was above my stop loss

Cant those losers just process these trades.... What a bunch of crap.
argh...my only thoughts now are to wait until the trade closed and somehow program after close to reverse


Any suggestions from anyone ? on how to do that?

Never mind..moved my $;s overseas.
AWESOME PROGRAMMING ! love the feedback ..runnin live already!

Last edited by ajk; 06-09-2009 at 03:28 AM.
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

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
Longer Term Trend Filter agisthos Metatrader 4 8 06-14-2009 04:25 PM
No more hedging JoZo General Discussion 15 04-28-2009 07:46 AM
MT4 Problem: EAs no longer work et_phonehome_2 Metatrader 4 3 12-29-2006 01:30 PM
Alpari Tick data no longer? drgoodvibe Metatrader 4 2 11-08-2006 01:20 AM
Best Oscillator to judge longer term trend ? samarkand General Discussion 1 05-12-2006 08:31 PM


All times are GMT. The time now is 01:03 PM.



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