Forex
Google
New signals service!

Go Back   Forex Trading > Trading systems > Martingale/Average Cost and Hedging


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 (20) Thread Tools Display Modes
  #1231 (permalink)  
Old 03-04-2008, 01:16 AM
ElectricSavant's Avatar
Senior Member
 
Join Date: Jun 2007
Posts: 2,828
ElectricSavant is on a distinguished road
That I cannot help...


Quote:
Originally Posted by wolfe View Post
What does that tell you when Ralph says that would be serious coding?
__________________
Live Portfolio (This takes a while to download as it is a big excel spreadsheet)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1232 (permalink)  
Old 03-04-2008, 01:20 AM
wolfe's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 704
wolfe is on a distinguished road
Quote:
Originally Posted by ElectricSavant View Post
The bugs I posted caused me to close it (it stoped executing orders)...I am trying the EUR/USD now as it has a smaller spread ...


ES
Maybe we should have an option to select how many pips for the next trade, in case EVERY pip is too much. It adds too many orders I'm afraid.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1233 (permalink)  
Old 03-04-2008, 01:21 AM
ElectricSavant's Avatar
Senior Member
 
Join Date: Jun 2007
Posts: 2,828
ElectricSavant is on a distinguished road
That is PipSpace™ that i posted earlier...

Quote:
Originally Posted by wolfe View Post
Maybe we should have an option to select how many pips for the next trade, in case EVERY pip is too much. It adds too many orders I'm afraid.
__________________
Live Portfolio (This takes a while to download as it is a big excel spreadsheet)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1234 (permalink)  
Old 03-04-2008, 01:25 AM
wolfe's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 704
wolfe is on a distinguished road
Quote:
Originally Posted by ElectricSavant View Post
That is PipSpace™ that i posted earlier...
Sorry. I need to read more thoroughly.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1235 (permalink)  
Old 03-04-2008, 02:40 AM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
I've attached a code snippet below, which pairs up buys and sells and close them against each other. The point is that it really doesn't matter which ones you pair up, especially if they are all of the same lot size.

Ideally though, you should first compute the right amount of excess trades to close at current price, because the pairing up and closing takes some time, and the price might be moving while that happens; you would want to close the excess first, and thereafter the paired up ones.

One alternative could be to pair up and close the pairs earlier, at anytime after a positive state is achieved. Though then you will have to account for the balance change induced by the pairwise closing in the remaining cycle life until TS fires; the EA would have to pretend that the pairwise closing hasn't happened yet for the TS calculations and in trade counts etc. That is, if you want to actually close early, but mimic the behaviour as if not having closed.

PHP Code:
int buys[10000];
int sells[10000];

void ClosePairwise(int magic)
{
    
bool both true;
    while ( 
both ) {
        
int sp 0;
        
int bp 0;
        
both false;
        for ( 
int i OrdersTotal() - 1>= 0i-- ) {
            if ( ! 
OrderSelectiSELECT_BY_POS ) )
                continue;
            if ( 
OrderMagicNumber() != magic )
                continue;
            if ( 
OrderType() == OP_BUY ) {
                if ( 
sp ) {
                    
buysbp ] = OrderTicket();
                    
bp += 1;
                    continue;
                }
                
both true;
                
sp -= 1;
                
OrderCloseBysellssp ], OrderTicket(), Yellow );
            } else if ( 
OrderType() == OP_SELL ) {
                if ( 
bp ) {
                    
sellssp ] = OrderTicket();
                    
sp += 1;
                    continue;
                }
                
both true;
                
bp -= 1;
                
OrderCloseBybuysbp ], OrderTicket(), Yellow );
            }
        }
    }

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1236 (permalink)  
Old 03-04-2008, 02:45 AM
ElectricSavant's Avatar
Senior Member
 
Join Date: Jun 2007
Posts: 2,828
ElectricSavant is on a distinguished road
Just fricken genius...

Ralph...I would hate to think if you were a trader and treated Forex other than a hobby...

Excuse me for drooling over your code...

ES
__________________
Live Portfolio (This takes a while to download as it is a big excel spreadsheet)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1237 (permalink)  
Old 03-04-2008, 02:53 AM
wolfe's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 704
wolfe is on a distinguished road
Quote:
Originally Posted by ralph.ronnquist View Post
I've attached a code snippet below, which pairs up buys and sells and close them against each other. The point is that it really doesn't matter which ones you pair up, especially if they are all of the same lot size.

Ideally though, you should first compute the right amount of excess trades to close at current price, because the pairing up and closing takes some time, and the price might be moving while that happens; you would want to close the excess first, and thereafter the paired up ones.

One alternative could be to pair up and close the pairs earlier, at anytime after a positive state is achieved. Though then you will have to account for the balance change induced by the pairwise closing in the remaining cycle life until TS fires; the EA would have to pretend that the pairwise closing hasn't happened yet for the TS calculations and in trade counts etc. That is, if you want to actually close early, but mimic the behaviour as if not having closed.

PHP Code:
int buys[10000];
int sells[10000];

void ClosePairwise(int magic)
{
    
bool both true;
    while ( 
both ) {
        
int sp 0;
        
int bp 0;
        
both false;
        for ( 
int i OrdersTotal() - 1>= 0i-- ) {
            if ( ! 
OrderSelectiSELECT_BY_POS ) )
                continue;
            if ( 
OrderMagicNumber() != magic )
                continue;
            if ( 
OrderType() == OP_BUY ) {
                if ( 
sp ) {
                    
buysbp ] = OrderTicket();
                    
bp += 1;
                    continue;
                }
                
both true;
                
sp -= 1;
                
OrderCloseBysellssp ], OrderTicket(), Yellow );
            } else if ( 
OrderType() == OP_SELL ) {
                if ( 
bp ) {
                    
sellssp ] = OrderTicket();
                    
sp += 1;
                    continue;
                }
                
both true;
                
bp -= 1;
                
OrderCloseBybuysbp ], OrderTicket(), Yellow );
            }
        }
    }

Thank you Ralph! I'll check this out and try to incorporate it. I really appreciate your help and contribution!

Yet another time you have rescued me.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1238 (permalink)  
Old 03-04-2008, 03:30 AM
kayvan's Avatar
Senior Member
 
Join Date: Mar 2007
Location: .....
Posts: 145
kayvan is on a distinguished road
Quote:
Originally Posted by ElectricSavant View Post
wolfey,

I thought I would put all of the new requested upgrades together in one place

we need the following
  • Improved WFM™ handling
  • Time Choke™
  • Pause
  • PipSpace™
  • MA Initial Start
  • New Thread
  • Make the default in Maxtrades to read 999

ES

also we need 1 tp for every order and 1 tp for the remaining ordes.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1239 (permalink)  
Old 03-04-2008, 03:38 AM
ElectricSavant's Avatar
Senior Member
 
Join Date: Jun 2007
Posts: 2,828
ElectricSavant is on a distinguished road
This will violate IBFX scalping rules and we will get flagged!

It is real and yes I guaranty it will happen for those of us at IBFX....with an EA with this many orders there will be too many "90 second duration and under", trades.

ES


Quote:
Originally Posted by kayvan View Post
also we need 1 tp for every order and 1 tp for the remaining ordes.
__________________
Live Portfolio (This takes a while to download as it is a big excel spreadsheet)

Last edited by ElectricSavant; 03-04-2008 at 03:58 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1240 (permalink)  
Old 03-04-2008, 03:38 AM
kayvan's Avatar
Senior Member
 
Join Date: Mar 2007
Location: .....
Posts: 145
kayvan is on a distinguished road
Quote:
Originally Posted by wolfe View Post
You're describing a coding NIGHTMARE here Kayvan!

sorry Wolfe , but it seem`s to be necessary for our EA.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
martingale, martingale EA

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/martingale-average-cost-hedging/11734-martingale-ea.html
Posted By For Type Date
ea - learn to trade forex swicki - powered by eurekster This thread Refback 06-05-2008 05:34 PM
[intraday]martingale strategy dan variasinya - Page 6 - Forexindo Forum This thread Refback 04-04-2008 02:15 AM
TFX v1.5 Expert Adviser - The Money Guru Forum - Money Making Discussions This thread Refback 03-31-2008 04:36 PM
Download 10points3 Ea - Type Your Search Here This thread Refback 03-12-2008 12:38 AM
Expert Advisor | Forex MetaTrader Expert Advisors | Over 40 of the Best EA's for MT4 on Squidoo This thread Refback 03-08-2008 07:36 PM
Expert Advisor | Forex MetaTrader Expert Advisors | Over 40 of the Best EA's for MT4 on Squidoo This thread Refback 03-07-2008 06:27 AM
Expert Advisor | Forex MetaTrader Expert Advisors | Over 40 of the Best EA's for MT4 on Squidoo This thread Refback 03-07-2008 02:27 AM
Expert Advisor | Forex MetaTrader Expert Advisors | Over 40 of the Best EA's for MT4 on Squidoo This thread Refback 03-05-2008 12:56 AM
Bright Idea's :: View topic - TFX Public EA Thread (work in progress) This thread Refback 02-29-2008 12:05 PM
Martingale Baggio Method - Page 11 This thread Refback 02-27-2008 08:59 PM
Martingale Baggio Method - Page 11 This thread Refback 02-27-2008 04:07 PM
Martingale Baggio Method - Page 11 This thread Refback 02-27-2008 04:04 PM
Martingale Baggio Method - Page 10 This thread Refback 02-25-2008 05:50 PM
Martingale Baggio Method - Page 10 This thread Refback 02-25-2008 05:07 PM
Martingale Baggio Method - Page 10 This thread Refback 02-25-2008 05:05 PM
Bright Idea's :: View topic - TFX Public EA Thread (work in progress) This thread Refback 02-23-2008 06:38 PM
Bright Idea's :: View topic - TFX Public EA Thread (work in progress) This thread Refback 02-04-2008 05:15 AM
Bright Idea's :: View topic - TFX Public EA Thread (work in progress)