Go Back   Forex-TSD > Downloads > Expert Advisors - Metatrader 4
Forex Forum Register More recent 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
  #721 (permalink)  
Old 03-05-2009, 07:06 AM
Senior Member
 
Join Date: Mar 2006
Posts: 1,072
barnix is on a distinguished road
Trading Strategy tester in java
SourceForge.net: Trading Strategy Runner: Files
Data file structure:
27/10/2008,00:00:01,2,1.2624,1.2623,1.2623,1.2624
27/10/2008,00:00:11,0,1.2623,1.2623,1.2623,1.2623
27/10/2008,00:00:21,2,1.2624,1.2623,1.2623,1.2624
27/10/2008,00:00:31,1,1.2623,1.2624,1.2623,1.2624
27/10/2008,00:00:41,0,1.2624,1.2624,1.2624,1.2624
Attached Images
File Type: jpg screenshot.jpg (49.1 KB, 1518 views)
File Type: jpg testter1.jpg (28.3 KB, 1496 views)

Last edited by barnix; 03-05-2009 at 07:42 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
  #722 (permalink)  
Old 03-05-2009, 07:31 AM
Member
 
Join Date: Jan 2006
Posts: 33
sae2k is on a distinguished road
Suppose I created two classes of vectors, one for SELL, one for the BUY.

to properly classify the current vector ( to which class he belongs) need to determinate sigma. If him 0.0001 is the vector may be classified as a BUY, as if to let him 0.01 - then classified as the vector begins SELL.

For me, until the mystery of how to determine the optimum value for sigma.
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
  #723 (permalink)  
Old 03-05-2009, 07:51 AM
Senior Member
 
Join Date: Mar 2006
Posts: 1,072
barnix is on a distinguished road
public enum SignalDirection {

BUY, SELL, NEUTRAL, CLOSE
}
///////////////////////////////////////////////////////////////////
public enum SignalType {

OPEN, CLOSE, INDICATION
}
///////////////////////////////////////////////////////////////////
public class Util {

static DecimalFormat decFormat = new DecimalFormat("0.0000");
static SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");

public static synchronized String formatDate(Date date) {
return date == null ? "" : dateFormat.format(date);
}

public static synchronized Date parseDate(String date) throws ParseException {
return date == null ? null : dateFormat.parse(date);
}

public static synchronized String formatPrice(double totalProfit) {
return decFormat.format(totalProfit);
}

public static final double calcProfit(TradePosition pos, Tick currentTick) {
if (pos.getDirection() == SignalDirection.BUY) {
// long the security
return currentTick.getSellPrice() - pos.getTick().getBuyPrice();
} else {
// short the security
return pos.getTick().getSellPrice() - currentTick.getBuyPrice();
}
}

}
////////////////////////////////////////////////////////////////////////////////////////////////////////
public class TradePosition implements Serializable, Comparable<TradePosition> {

private final Tick tick;
private final SignalDirection direction;
private final SignalType type;

/**
* The default constructor
* @param direction
* @param type
* @param tick
*/
public TradePosition(SignalDirection direction, SignalType type, Tick tick) {
if (direction != SignalDirection.BUY && direction != SignalDirection.SELL) {
throw new RuntimeException("Cannot create trade position with direction: " + direction);
}

this.direction = direction;
this.type = type;
this.tick = tick;
}

@Override
public String toString() {
DecimalFormat df = new DecimalFormat("0.0000");
StringBuilder sb = new StringBuilder(30).append(direction).append(",").
append(df.format(direction == SignalDirection.BUY ? -1d * tick.getBuyPrice() : tick.getSellPrice())).
append(",").
append(Util.formatDate(tick.getTimestamp())).appen d(", ").append(type);
return sb.toString();
}

/**
* Reference to the tick when this position is opened/closed
* @return
*/
public Tick getTick() {
return tick;
}

/**
* Get the direction of this position
* @return
*/
public SignalDirection getDirection() {
return direction;
}

/**
* Get the signal type of this position
* @return
*/
public SignalType getSignalType() {
return type;
}

@Override
public boolean equals(Object obj) {
if (obj instanceof TradePosition) {
TradePosition b = (TradePosition) obj;
return this.direction == b.direction && this.type == b.type && this.tick.equals(b.tick);
}
return false;
}

public int compareTo(TradePosition o) {
int i = this.tick.compareTo(o.getTick());
return (i == 0) ? this.direction.toString().compareTo(o.direction.to String()) : i;
}

@Override
public int hashCode() {
return tick.hashCode();
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
public class Tick implements Comparable<Tick>, Serializable {

/**
* The bid/offer spread, e.g. in EUR/USD, this is generally 2 pips, that is 0.0002.
* Set this value before running a strategy.
*/
public static double BID_OFFER_SPREAD = 0d; //0.0002d;
protected Date date;
protected long volume;
protected double open;
protected double close;
protected double low;
protected double high;

protected Tick() {
}

public Tick(Date date, long volume, double open, double close, double low, double high) {
this.date = date;
this.volume = volume;
this.open = open;
this.close = close;
this.low = low;
this.high = high;
}

public Date getTimestamp() {
return date;
}

public long getVolume() {
return volume;
}

public double getOpenPrice() {
return open;
}

public double getClosePrice() {
return close;
}

public double getLow() {
return low;
}

public double getHigh() {
return high;
}

/**
* Is a function of closing price + (SPREAD / 2);
* @return
*/
public double getBuyPrice() {
return close + (BID_OFFER_SPREAD / 2d);
}


/**
* Is a function of closing price - (SPREAD / 2);
* @return
*/
public double getSellPrice() {
return close - (BID_OFFER_SPREAD / 2d);
}


/**
* Compare the current tick's timestamp with the other's
*/
public int compareTo(Tick o) {
long thisVal = this.date.getTime();
long anotherVal = o.date.getTime();
return (thisVal < anotherVal ? -1 : (thisVal == anotherVal ? 0 : 1));
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(Util.formatDate(date)).append(" P: ").append(getSellPrice()).append("/").append(getBuyPrice()).
append(" H: ").append(high).
append(" L: ").append(low).
append(" O: ").append(open);

return sb.toString();
}

@Override
public boolean equals(Object obj) {
if (obj instanceof Tick) {
Tick o = (Tick) obj;
return this.close == o.close && this.getTimestamp() == o.getTimestamp() && this.high == o.high && this.low == o.low && this.open == o.open;
}
return false;
}

@Override
public int hashCode() {
return date.hashCode();
}
}

Last edited by barnix; 03-05-2009 at 08:03 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
  #724 (permalink)  
Old 03-05-2009, 08:11 AM
Senior Member
 
Join Date: Mar 2006
Posts: 1,072
barnix is on a distinguished road
// PROFIT for long position
PROFITL= currentTick.getSellPrice() - pos.getTick().getBuyPrice()
// PROFIT for short position
PROFITS=pos.getTick().getSellPrice() - currentTick.getBuyPrice()

//////////////////////////////////////////////////////
public double getBuyPrice() {
return close + (BID_OFFER_SPREAD / 2d);
}
////////////////////////////////////////////////////////
public double getSellPrice() {
return close - (BID_OFFER_SPREAD / 2d);
}

Last edited by barnix; 03-05-2009 at 08:34 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
  #725 (permalink)  
Old 03-05-2009, 01:17 PM
Member
 
Join Date: Jan 2006
Posts: 33
sae2k is on a distinguished road
Plot pdf parzen function

need 5000 Bars min on chart, i used EURUSD 5 min

green - BUY PDF function
red - SELL PDF function

on first screenshot probality down > probality up
on two screenshot chart with 3 MA

PS: PlotGraph.mq4 extreme CPU overload, take care
Attached Images
File Type: jpg PlotGraph.jpg (276.0 KB, 1373 views)
File Type: jpg chart.JPG (301.4 KB, 1365 views)
Attached Files
File Type: mq4 PlotGraph.mq4 (7.8 KB, 133 views)
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
  #726 (permalink)  
Old 03-06-2009, 07:11 AM
Member
 
Join Date: Jan 2006
Posts: 33
sae2k is on a distinguished road
optimization

Quote:
Different values of scale factor sigma lead to different classification performances. First, the performance score of the PNN classifier with a given sigma is determined by the cross-validation method. In the process of cross-validation, each training sample is temporally removed from the training set and used as the test sample. The remaining training data is then used in PNN classifier to classify this test sample. If the sample is correctly classified, the performance score is increases by 1. Repeat this procedure for all the training samples go give the final score. Finally, a one dimensional heuristically search is performed to find the optimal sigma with the largest performance score.
I understand the algorithm is as follows:

array with samples PNN[][], suppose it is kept 50 vectors. temporarily removed from his first vector and calculate pdf-function. That's the question what it means: "If the sample is correctly classified"? What criteria ?

then remove the second (the first returned) and again calculate pdf, and so on.

Last edited by sae2k; 03-06-2009 at 07:14 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
  #727 (permalink)  
Old 03-06-2009, 02:17 PM
Senior Member
 
Join Date: Mar 2006
Posts: 1,072
barnix is on a distinguished road
Trading Strategy tester in java
Classes
Attached Images
File Type: jpg tester1.jpg (116.1 KB, 1259 views)
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
  #728 (permalink)  
Old 03-10-2009, 03:07 PM
Member
 
Join Date: May 2008
Posts: 31
payback is on a distinguished road
Hi barnix and all the others, i've some experience with NN and i will try to join your trip in forecasting, i will use neurosolutions so i hope i ll have some help in linking dll with mt4 eh eh

i guess you use smoothed time series for NN right?
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
  #729 (permalink)  
Old 03-27-2009, 09:40 PM
Junior Member
 
Join Date: Feb 2009
Posts: 1
silfal is on a distinguished road
Good evening, new here in the thread, but not in the subject I have read for a while the postings. Many thanks for the great work and suggestions here.
@sae2k :
A small hint is allowed to me: I hold for critical to work with standard deviation for the prediction of financial time series, assuming a normally distribution. No one else as John Bollinger pointed to the kurtosis in the stock markets, a similar acceptance can be probably met to other time series. A classification with plants cannot be transferred anyway directly to the financial markets.
I would choose a simple unit vector between 0 and 1 for an initial standardization, however, I can't assess the efficiency for the chosen PNN.

Regard
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
  #730 (permalink)  
Old 05-09-2009, 05:17 PM
Senior Member
 
Join Date: Mar 2006
Posts: 1,072
barnix is on a distinguished road
Simple Trading System in python
Source Checkout - wtx - Google Code


class Strategy:
def __init__(self, deposit=400000, price_per_point=200, commission=500):
self.bars = None
self.current_index = -1
self.points_balance = 0
self.entry_price = 0
self.current_contracts = 0
self.price_per_point = price_per_point
self.commission = commission
self.initial_deposit = deposit
self.balance = deposit
self.win = 0
self.lose = 0

def Buy(self, price):
self.ExitShort(price)
self.entry_price = price
self.current_contracts = 1
#print "Buy @%d"%(price)

def Sell(self, price):
self.ExitLong(price)
self.entry_price = price
self.current_contracts = -1
#print "Sell @%d"%(price)

def ExitLong(self, price):
if self.current_contracts > 0:
points_balance = (price - self.entry_price)*self.current_contracts
if points_balance>=0:
self.win += 1
else:
self.lose += 1
print "ExitLong: %d points (%d -> %d)"%(points_balance, self.entry_price, price)
self.points_balance += points_balance
self.balance += points_balance * self.price_per_point - self.commission
self.current_contracts = 0

def ExitShort(self, price):
if self.current_contracts < 0:
points_balance = (price - self.entry_price)*self.current_contracts
if points_balance<=0:
self.win += 1
else:
self.lose += 1
print "ExitShort: %d points (%d -> %d)"%(points_balance, self.entry_price, price)
self.points_balance += points_balance
self.balance += points_balance * self.price_per_point - self.commission
self.current_contracts = 0

def ShowResults(self):
self.ExitLong(self.Close(0))
self.ExitShort(self.Close(0))
transaction = self.lose+self.win
print "--------------- Performance Report ------------------"
print "%d Transaction, Win=%d (%.1f%%), Lose=%d(%.1f%%)"%(\
transaction, self.win, self.win*100/transaction, self.lose, self.lose*100/transaction)
print "Initial deposit=%d"%(self.initial_deposit)
print "points_balance is %d points, equals to %d (NTD)"%\
(self.points_balance, self.points_balance*self.price_per_point)
print "commission is %d"%(self.balance-self.initial_deposit-self.points_balance*self.price_per_point)
print "Final balance is %d"%(self.balance)
print "Actual earning is %d"%(self.balance-self.initial_deposit)
print "--------------- Performance Report ------------------"

def CrossOver(self, a, b):
#prev a < prev b and current a > current b
print "[%s] Close=%d, Fast[-1](%d)<Slow[-1](%d) and Fast(%d)>=Slow(%d) ? %d"%(self.bars[self.current_index].time, \
self.bars[self.current_index].close, a(1),b(1),a(0),b(0), a(1)<b(1) and a(0)>=b(0))
return a(1)<b(1) and a(0)>=b(0)

def Close(self, offset=0):
if self.current_index < offset:
return 0
else:
return self.bars[self.current_index - offset].close

def Open(self, offset=0):
if self.current_index < offset:
return 0
else:
return self.bars[self.current_index - offset].open

def High(self, offset=0):
if self.current_index < offset:
return 0
else:
return self.bars[self.current_index - offset].high

def Low(self, offset=0):
if self.current_index < offset:
return 0
else:
return self.bars[self.current_index - offset].low

def Sum(self, f, count, offset=0):
sum = 0
if self.current_index < offset:
return sum
elif self.current_index < offset + count:
count = self.current_index-offset
for e in map(f, range(offset, count+offset)):
#print "sum(%d) += %d"%(sum, e)
sum += e
#print "[%d] Sum(count=%d, offset=%d)=%d"%(self.current_index, count, offset, sum)
return sum

def Average(self, f, count, offset=0):
avg = 0
if self.current_index < offset:
return 0
elif self.current_index < offset + count:
count = self.current_index-offset

if count == 0:
return 0

avg = self.Sum(f, count, offset)/count
#print "[%d] Average(count=%d, offset=%d)=%d"%(self.current_index, count, offset, avg)
return avg

def Run(self, Open, High, Low, Close):
pass

def RunWithBars(self, bars):
self.bars = bars
self.count = len(bars)
for i in range(0, self.count):
self.current_index = i
#print "[%d][%s] %d %d %d %d"%(i, self.bars[i].time, self.bars[i].open, \
#self.bars[i].high, self.bars[i].low, self.bars[i].close)
self.Run(lambda x: self.Open(x), \
lambda x: self.High(x), \
lambda x: self.Low(x), \
lambda x: self.Close(x))

self.ShowResults()
Attached Files
File Type: rar wtx.rar (18.4 KB, 71 views)

Last edited by barnix; 05-09-2009 at 05:27 PM.
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

Tags
better ea, neural network, svm forex, cache:Jtu9ppOwDvsJ:www.forex-tsd.com/expert-advisors-metatrader-4/11096-better-nn-ea-development.htm, better, nn ea, better ea development, forex better ea, cortex, forex, Better NN EA, better development, better NN development, wackena NN-EA, libsvm, ea better, kalman, auto-scalper, Forex Auto-Scalper, search, Abdul Rahman EA Forex, fapturbo, betterea, GaussPNN, neuro, MT4_FANN, Auto-Scalper.ex4, better nn, Matrix NN ea


Currently Active Users Viewing This Thread: 2 (1 members and 1 guests)
beakon
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
BrainSystem: indicators development newdigital Brain Systems 59 01-07-2010 11:04 PM
Zigzag system development newdigital Indicators - Metatrader 3 14 05-20-2009 04:52 AM
StochThreshold | ... under development wibitiens Indicators - Metatrader 4 0 05-26-2007 02:26 AM
Brainwashing: system development newdigital Brain Systems 45 11-24-2006 11:55 AM
Help with simple EA idea development Spider4896 Metatrader 4 2 04-21-2006 01:23 PM


All times are GMT. The time now is 02:55 AM.



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