Martingale EA - page 123

 

ES,

How is TFX v1_8 testing going anyway?

 

Ralph,

could you explain this more?

Can I help?

ES

ralph.ronnquist:
Maybe one could cap that close price difference by pairing up the trades and use OrderCloseBy; that'd be some serious coding, though....
 

wolfe,

could you start the thread...it is your EA...? I do not really know how to start the EA thread without ND moving it to the Discussion area...

I blew up two accounts with 1.8...I think most of the bugs are fixed. I just do not know a setfile to use with it. I know there is one and tfx 1.8 can do a lot.

I like PipIdiot™~...it is safer. If only Ralph would share ordergrouping with you.....You somehow missed an important post of his.

ES

wolfe:
ES, How is TFX v1_8 testing going anyway?
 
ElectricSavant:
Ralph,

could you explain this more?

Can I help?

ES

What does that tell you when Ralph says that would be serious coding?

 

That I cannot help...

wolfe:
What does that tell you when Ralph says that would be serious coding?
 
ElectricSavant:
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.

 

The bugs I posted caused me to close it (it stopped executing orders)...I am trying the EUR/USD now as it has a smaller spread ...

ES

wolfe:
Interesting, let us know on the Guppy. If you want, set max trades to 99999999999999999999 it will still work.
 

That is PipSpace™ that i posted earlier...

wolfe:
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.
 
 

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.

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; i >= 0; i-- ) {

if ( ! OrderSelect( i, SELECT_BY_POS ) )

continue;

if ( OrderMagicNumber() != magic )

continue;

if ( OrderType() == OP_BUY ) {

if ( sp < 1 ) {

buys[ bp ] = OrderTicket();

bp += 1;

continue;

}

both = true;

sp -= 1;

OrderCloseBy( sells[ sp ], OrderTicket(), Yellow );

} else if ( OrderType() == OP_SELL ) {

if ( bp < 1 ) {

sells[ sp ] = OrderTicket();

sp += 1;

continue;

}

both = true;

bp -= 1;

OrderCloseBy( buys[ bp ], OrderTicket(), Yellow );

}

}

}

}