Here's the new "Goblin" ea...little brother to Predator - page 83

 

bluto, bluto, bluto that is spelled b-l-u-t-o. This is part of my memory retention training to remember your name.

FYI

Don't know if intended strategy, but one of Globin's order close routines seems questionable. Goblin uses OrderSelect() with MODE_TRADES, and then uses OrderClosePrice() in calculaltions. OrderClosePrice() is history and not valid for current open orders. These profit calculations is using an open order OrderOpenPrice() and OrderClosePrice(), which would be 0 (since the order has not closed) or maybe a value from last closed order.

Shoud it use Ask and Bid to calculate profit on open orders?

Your nickpicking or MYOB friend,

Wackena

Profit=0;

LastTicket=0;

LastType=0;

LastClosePrice=0;

LastLots=0;

for(cnt=0;cnt<OrdersTotal();cnt++)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if (OrderSymbol()==Symbol() && OrderMagicNumber() == Magic)

{

LastTicket=OrderTicket();

if (OrderType()==OP_BUY) { LastType=OP_BUY; }

if (OrderType()==OP_SELL) { LastType=OP_SELL; }

LastClosePrice=OrderClosePrice();

LastLots=OrderLots();

if (LastType==OP_BUY)

{

//Profit=Profit+(Ord(cnt,VAL_CLOSEPRICE)-Ord(cnt,VAL_OPENPRICE))*PipValue*Ord(cnt,VAL_LOTS);

if (OrderClosePrice()<OrderOpenPrice())

{ Profit=Profit-(OrderOpenPrice()-OrderClosePrice())*OrderLots()/Point; }

if (OrderClosePrice()>OrderOpenPrice())

{ Profit=Profit+(OrderClosePrice()-OrderOpenPrice())*OrderLots()/Point; }

}

if (LastType==OP_SELL)

{

//Profit=Profit+(Ord(cnt,VAL_OPENPRICE)-Ord(cnt,VAL_CLOSEPRICE))*PipValue*Ord(cnt,VAL_LOTS);

if (OrderClosePrice()>OrderOpenPrice())

{ Profit=Profit-(OrderClosePrice()-OrderOpenPrice())*OrderLots()/Point; }

if (OrderClosePrice()<OrderOpenPrice())

{ Profit=Profit+(OrderOpenPrice()-OrderClosePrice())*OrderLots()/Point; }

}

//Print(Symbol,":",Profit,",",LastLots);

}

}
 
Wackena:
bluto, bluto, bluto that is spelled b-l-u-t-o. This is part of my memory retention training to remember your name.

FYI

Don't know if intended strategy, but one of Globin's order close routines seems questionable. Goblin uses OrderSelect() with MODE_TRADES, and then uses OrderClosePrice() in calculaltions. OrderClosePrice() is history and not valid for current open orders. These profit calculations is using an open order OrderOpenPrice() and OrderClosePrice(), which would be 0 (since the order has not closed) or maybe a value from last closed order.

Shoud it use Ask and Bid to calculate profit on open orders?

Your nickpicking or MYOB friend,

Wackena

Profit=0;

LastTicket=0;

LastType=0;

LastClosePrice=0;

LastLots=0;

for(cnt=0;cnt<OrdersTotal();cnt++)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if (OrderSymbol()==Symbol() && OrderMagicNumber() == Magic)

{

LastTicket=OrderTicket();

if (OrderType()==OP_BUY) { LastType=OP_BUY; }

if (OrderType()==OP_SELL) { LastType=OP_SELL; }

LastClosePrice=OrderClosePrice();

LastLots=OrderLots();

if (LastType==OP_BUY)

{

//Profit=Profit+(Ord(cnt,VAL_CLOSEPRICE)-Ord(cnt,VAL_OPENPRICE))*PipValue*Ord(cnt,VAL_LOTS);

if (OrderClosePrice()<OrderOpenPrice())

{ Profit=Profit-(OrderOpenPrice()-OrderClosePrice())*OrderLots()/Point; }

if (OrderClosePrice()>OrderOpenPrice())

{ Profit=Profit+(OrderClosePrice()-OrderOpenPrice())*OrderLots()/Point; }

}

if (LastType==OP_SELL)

{

//Profit=Profit+(Ord(cnt,VAL_OPENPRICE)-Ord(cnt,VAL_CLOSEPRICE))*PipValue*Ord(cnt,VAL_LOTS);

if (OrderClosePrice()>OrderOpenPrice())

{ Profit=Profit-(OrderClosePrice()-OrderOpenPrice())*OrderLots()/Point; }

if (OrderClosePrice()<OrderOpenPrice())

{ Profit=Profit+(OrderOpenPrice()-OrderClosePrice())*OrderLots()/Point; }

}

//Print(Symbol,":",Profit,",",LastLots);

}

}

Wack-

OrderClosePrice() is a completely valid function call to us on open orders...it simply returns the current Bid or Ask depending on what the order type is. Think of it this way...when you're looking at the "Price" column of the Trade tab grid in the MT4 Terminal window....that's the current OrerClosePricevalue. It's actually a pretty handy function when coding. However...I didn't write that chunk of code you listed - Alejandro Galindo did.

 

Q

@xxDavidxSxx

use You one (the same) magic number to run long Goblin and short Goblin in a pair or two different magic numbers?

 

Fellas, dewds & dewdstresses...

Just for grins and giggles, I built an "exploratory" version of Goblin named "Goblin BiPolar Edition" that mimics what David is doing with running two separate Goblins - one for buy and one for sell. Basically, it's two completely separate Goblin instances (sub-EA's) with their own magic numbers running inside one EA, one for longs and one for shorts completely isolated from each other. You have separate settings for each sub-EA in the EA Inputs window and a few global parameters. Might be cool. Should have it done later tonight. Check back.

 

Wow

bluto:
Fellas, dewds & dewdstresses... Just for grins and giggles, I built an "exploratory" version of Goblin named "Goblin BiPolar Edition" that mimics what David is doing with running two separate Goblins - one for buy and one for sell. Basically, it's two completely separate Goblin instances (sub-EA's) with their own magic numbers running inside one EA, one for longs and one for shorts completely isolated from each other. You have separate settings for each sub-EA in the EA Inputs window and a few global parameters. Might be cool. Should have it done later tonight. Check back.

Man you're fast!!

 
xxDavidxSxx:
yea thats the results. Week and 2 days.

started around 500$

30 pip target

no s/l

buy only one chart, sell only another chart, seperate majic #'s

account protect=0

orders protect=0

mm=0

max trades=4

pips=8

Hi David,

I got confused. With initiall 500$ account, you had opening from 0.1, 0.2, 0.4 and 0.8 lots at the same time,

4960523 2006.12.11 03:27 sell 0.10 eurusd 1.3158 0.0000 1.3128 2006.12.14 17:30 1.3155 0.00 0.00 2.69 3.00

4969565 2006.12.11 08:12 sell 0.20 eurusd 1.3167 0.0000 1.3137 2006.12.14 17:30 1.3153 0.00 0.00 5.38 28.00

4970491 2006.12.11 08:24 sell 0.40 eurusd 1.3176 0.0000 1.3146 2006.12.14 17:30 1.3155 0.00 0.00 10.76 84.00

4973369 2006.12.11 09:26 sell 0.80 eurusd 1.3185 0.0000 1.3155 2006.12.14 17:30 1.3155 0.00 0.00 21.51 240.00

I tried to open such positions with $500 acount (1:200 leverage), but got erro "Not enough money"? Do I miss something?

Thanks!

 
bluto:
Fellas, dewds & dewdstresses... Just for grins and giggles, I built an "exploratory" version of Goblin named "Goblin BiPolar Edition" that mimics what David is doing with running two separate Goblins - one for buy and one for sell. Basically, it's two completely separate Goblin instances (sub-EA's) with their own magic numbers running inside one EA, one for longs and one for shorts completely isolated from each other. You have separate settings for each sub-EA in the EA Inputs window and a few global parameters. Might be cool. Should have it done later tonight. Check back.

Cool deal Bluto thanks.

To answer the questions given to me....

the posted settings are what I am using. the rest are default.

yes seperate majic# for buy/sell on same pair.

1h chart (but should make no differance as it trades off of daily trend)

use what ever pair you want. as long as it moves.

No I don't use a s/l. No I don't use a trailing s/l.

Am I insane...thats left to be decided

I manage my own losing positions. As I have stated befor.........If the losing positions are giving me negitive intrest rate(swap rate)Ill consider closeing.

If losing positions give me positive intrest rate(swap rate) I'll hold them and they'll become carry trades.

I trade for a living. I do my own technical analysis. I trust my judgment because my judgment makes me a living.

If I determine the likelyhood of the price comming back I'll leave trades open. If I determine the likelyhood of the price running away and not comming back I'll close trades.

Currently on the testing peroid..I have seen price move 200 pips against me and then return for profits. I have no problem letting losing trades ride a few days.

Fear, will make you lose money. So will greed.

Most of you won't be able to tolerate the method I am using.( because of the no s/l and no trailing s/l) Thats ok, because not every one can be successfull.

remember 80% of you reading this will fail at the market.

Dave

 

OK, i found the Answer. Sorry.

 
bluto:
Wack- OrderClosePrice() is a completely valid function call to us on open orders...it simply returns the current Bid or Ask depending on what the order type is. Think of it this way...when you're looking at the "Price" column of the Trade tab grid in the MT4 Terminal window....that's the current OrerClosePricevalue. It's actually a pretty handy function when coding. However...I didn't write that chunk of code you listed - Alejandro Galindo did.

Profit=0;

LastTicket=0;

LastType=0;

LastClosePrice=0;

LastLots=0;

for(cnt=0;cnt<OrdersTotal();cnt++)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if (OrderSymbol()==Symbol() && OrderMagicNumber() == Magic)

{

LastTicket=OrderTicket();

if (OrderType()==OP_BUY) { LastType=OP_BUY; }

if (OrderType()==OP_SELL) { LastType=OP_SELL; }

LastClosePrice=OrderClosePrice();

LastLots=OrderLots();

if (LastType==OP_BUY)

{

//Profit=Profit+(Ord(cnt,VAL_CLOSEPRICE)-Ord(cnt,VAL_OPENPRICE))*PipValue*Ord(cnt,VAL_LOTS);

if (OrderClosePrice()<OrderOpenPrice())

{ Profit=Profit-(OrderOpenPrice()-OrderClosePrice())*OrderLots()/Point; }

if (OrderClosePrice()>OrderOpenPrice())

{ Profit=Profit+(OrderClosePrice()-OrderOpenPrice())*OrderLots()/Point; }

}

if (LastType==OP_SELL)

{

//Profit=Profit+(Ord(cnt,VAL_OPENPRICE)-Ord(cnt,VAL_CLOSEPRICE))*PipValue*Ord(cnt,VAL_LOTS);

if (OrderClosePrice()>OrderOpenPrice())

{ Profit=Profit-(OrderClosePrice()-OrderOpenPrice())*OrderLots()/Point; }

if (OrderClosePrice()<OrderOpenPrice())

{ Profit=Profit+(OrderOpenPrice()-OrderClosePrice())*OrderLots()/Point; }

}

//Print(Symbol,":",Profit,",",LastLots);

}

}[/PHP]

Bluto, I think the code above is wrong :

First, looping thru the orders collection, you cannot be sure to end with the last order, it depends of the sorted column of the terminal (I have talked about this with Slawa, and it's like that...).

Second, the calculation of the profit seems strange: for a buy, the pip's profit is always (OrderClosePrice()-OrderOpenPrice())*OrderLots()/Point, regardless the closePrice is higher or lower than the OpenPrice, idem for the sells

I sugest you something like this, which is more synthetic:

[PHP]

Profit=0;

LastTicket=0;

for(cnt=0;cnt<OrdersTotal();cnt++)

{

if(!OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES) continue;

if(OrderSymbol()!=Symbol() || OrderMagicNumber() != Magic) continue;

if(OrderTicket() > LastTicket)

{

LastTicket = OrderTicket();

LastType = OrderType();

LastLots = OrderLots();

.......

}

if(OrderType() == OP_BUY) Profit += (OrderClosePrice()-OrderOpenPrice())*OrderLots()/Point;

if(OrderType() == OP_SELL) Profit += (OrderOpenPrice()-OrderClosePrice())*OrderLots()/Point;

}

 
Michel:

Profit=0;

LastTicket=0;

LastType=0;

LastClosePrice=0;

LastLots=0;

for(cnt=0;cnt<OrdersTotal();cnt++)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if (OrderSymbol()==Symbol() && OrderMagicNumber() == Magic)

{

LastTicket=OrderTicket();

if (OrderType()==OP_BUY) { LastType=OP_BUY; }

if (OrderType()==OP_SELL) { LastType=OP_SELL; }

LastClosePrice=OrderClosePrice();

LastLots=OrderLots();

if (LastType==OP_BUY)

{

//Profit=Profit+(Ord(cnt,VAL_CLOSEPRICE)-Ord(cnt,VAL_OPENPRICE))*PipValue*Ord(cnt,VAL_LOTS);

if (OrderClosePrice()<OrderOpenPrice())

{ Profit=Profit-(OrderOpenPrice()-OrderClosePrice())*OrderLots()/Point; }

if (OrderClosePrice()>OrderOpenPrice())

{ Profit=Profit+(OrderClosePrice()-OrderOpenPrice())*OrderLots()/Point; }

}

if (LastType==OP_SELL)

{

//Profit=Profit+(Ord(cnt,VAL_OPENPRICE)-Ord(cnt,VAL_CLOSEPRICE))*PipValue*Ord(cnt,VAL_LOTS);

if (OrderClosePrice()>OrderOpenPrice())

{ Profit=Profit-(OrderClosePrice()-OrderOpenPrice())*OrderLots()/Point; }

if (OrderClosePrice()<OrderOpenPrice())

{ Profit=Profit+(OrderOpenPrice()-OrderClosePrice())*OrderLots()/Point; }

}

//Print(Symbol,":",Profit,",",LastLots);

}

}[/PHP]

Bluto, I think the code above is wrong :

First, looping thru the orders collection, you cannot be sure to end with the last order, it depends of the sorted column of the terminal (I have talked about this with Slawa, and it's like that...).

Second, the calculation of the profit seems strange: for a buy, the pip's profit is always (OrderClosePrice()-OrderOpenPrice())*OrderLots()/Point, regardless the closePrice is higher or lower than the OpenPrice, idem for the sells

I sugest you something like this, which is more synthetic:

[PHP]

Profit=0;

LastTicket=0;

for(cnt=0;cnt<OrdersTotal();cnt++)

{

if(!OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES) continue;

if(OrderSymbol()!=Symbol() || OrderMagicNumber() != Magic) continue;

if(OrderTicket() > LastTicket)

{

LastTicket = OrderTicket();

LastType = OrderType();

LastLots = OrderLots();

.......

}

if(OrderType() == OP_BUY) Profit += (OrderClosePrice()-OrderOpenPrice())*OrderLots()/Point;

if(OrderType() == OP_SELL) Profit += (OrderOpenPrice()-OrderClosePrice())*OrderLots()/Point;

}

Michel -

I didn't write any of that original 10Point3 code. However....

1. Using 'SELECT_BY_POS' in a for loop to process orders implicitly uses the internal order index which is based on the chronological order addition, regardless of how the grid column(s) may be sorted.

2. I agree that the original profit computation is clumbsy, and I have replaced

all of this with a simple accumulation of profit in the loop using the OrderProfit() function.

Reason: