
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
// 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);
}
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
optimization
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.
Trading Strategy tester in java
Classes
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?
Can you please help me
Great Ideas
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
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 current b
print "[%s] Close=%d, Fast[-1](%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(0))
return a(1)=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.time, self.bars.open, \
#self.bars.high, self.bars.low, self.bars.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()
C++ tester:
Let me begin with the classes to be used for default (an abstract contract with the minimum
tick 0.0001 and the tick dollar value 0.0001), gold and soybean futures contracts specifica-
tions. They are defined in the header fileSpec.h.
#ifndef __Spec_h__
#define __Spec_h__
namespace PPBOOK {
class SpecDefault {
public:
static const char* name(){return "default";}
static double tick(){return 0.0001;}
static double tickValue(){return 0.0001;}
};
// Gold
class SpecGC {
public:
static const char* name(){return "GC";}
static double tick(){return 0.1;}
static double tickValue(){return 10.0;}
};
// Soybean
class SpecS {
public:
static const char* name(){return "S";}
static double tick(){return 0.25;}
static double tickValue(){return 12.5;}
};
//…
} // PPBOOK
#endif /* __Spec_h__ */
The definition of the class Price is in the header file Price.h:
#ifndef __Price_h__
#define __Price_h__
#include
#include
#include
using namespace std;
namespace PPBOOK {
template
class Price {
public:
Price(double p) : p_(p){check(p);}
Price(const Price& p) : p_(p.p_){}
double price() const {return p_;}
Price& operator=(double p)
{check(p); p_ = p; return *this;}
Price& operator=(const Price& p)
{p_ = p.p_; return *this;}
private:
double p_;
static void check(double p)
{
if(p <= 0.0) {
ostringstream s;
s << S::name() << " price " << p
<< " must be positive.";
throw invalid_argument(s.str());
}
double nt = p / S::tick();
if(fabs(floor(nt) * S::tick() - p) > 1.0e-8 &&
fabs(ceil(nt) * S::tick() - p) > 1.0e-8) {
ostringstream s;
s << S::name() << " price " << p
<< " must be a whole number of ticks " << S::tick();
throw invalid_argument(s.str());
}
}
};
// Only for illustration
//template
//double
//operator-(const Price& lhs, const Price& rhs)
//{
// return lhs.price() - rhs.price();
//}
} // PPBOOK
#endif /* __Price_h__ */