I've been using code from a forum thread on profit targets which seems to be getting out quite a distance from the actual profit target level. For example I set a profit target of .0020 in cash currencies and when I view the strategy report when my profit target exit occurs is it usually well below the actual .0020 points, usually .0005 to .0015 and I ca't figure out why.
I noticed the techniques for testing for profit targets and trailing stops/stops has evolved over time, here is the code I've been using. Is this still the recommended way for testing such breeches?
Also I noticed that there was some mention of a "Real Time EFS Strategies" document, Does such a document exist and/or are there any consideration that need to be programmed in relative to simpley backtesting that I should know aout. I do this for a living and really need to know anything that will alter the results of my tested systems as my job depends on it.
Thanks very much.
PROFIT TARGET BREECH CODE:
/*----------------------------------------------------------------
// Test for Profit Target Breach (ProfitTarget1)
----------------------------------------------------------
This portion of the code identifies if our profit target has
been reached and exits our trades.
----------------------------------------------------------*/
if (Strategy.isInTrade() == true && (Strategy.isShort() == true)) {
// Check if the profit target has been reached/breached
if (low() <= (nTradeEntryPrice - ProfitTarget1)) {
// Profit Target Breached, Execute Cover order.
Strategy.doCover("Short PT1 Exit", Strategy.STOP, Strategy.THISBAR,
Strategy.getDefaultLotSize(), (nTradeEntryPrice - ProfitTarget1));
}
}
if (Strategy.isInTrade() == true && (Strategy.isLong() == true)) {
// Check if the profit target has been reached/breached
if (high() >= (nTradeEntryPrice + ProfitTarget1)) {
// Profit Target Breached, Execute Sell order.
Strategy.doSell("Long PT1 Exit", Strategy.STOP, Strategy.THISBAR,
Strategy.getDefaultLotSize(), (nTradeEntryPrice + ProfitTarget1));
STOP TARGET BREECH CODE:
if (Strategy.isInTrade() == true && (Strategy.isShort() == true)) {
// Check if the profit target has been reached/breached
if (high() >= nStopLevel) {
// Stop Breached, Execute Cover order.
Strategy.doCover("Short T-Stop Exit", Strategy.STOP, Strategy.THISBAR,
Strategy.getDefaultLotSize(), nStopLevel);
}
}
if (Strategy.isInTrade() == true && (Strategy.isLong() == true)) {
// Check if the profit target has been reached/breached
if (low() <= nStopLevel) {
// Stop Breached, Execute Sell order.
Strategy.doSell("Long T-Stop Exit", Strategy.STOP, Strategy.THISBAR,
Strategy.getDefaultLotSize(),nStopLevel);
I noticed the techniques for testing for profit targets and trailing stops/stops has evolved over time, here is the code I've been using. Is this still the recommended way for testing such breeches?
Also I noticed that there was some mention of a "Real Time EFS Strategies" document, Does such a document exist and/or are there any consideration that need to be programmed in relative to simpley backtesting that I should know aout. I do this for a living and really need to know anything that will alter the results of my tested systems as my job depends on it.
Thanks very much.
PROFIT TARGET BREECH CODE:
/*----------------------------------------------------------------
// Test for Profit Target Breach (ProfitTarget1)
----------------------------------------------------------
This portion of the code identifies if our profit target has
been reached and exits our trades.
----------------------------------------------------------*/
if (Strategy.isInTrade() == true && (Strategy.isShort() == true)) {
// Check if the profit target has been reached/breached
if (low() <= (nTradeEntryPrice - ProfitTarget1)) {
// Profit Target Breached, Execute Cover order.
Strategy.doCover("Short PT1 Exit", Strategy.STOP, Strategy.THISBAR,
Strategy.getDefaultLotSize(), (nTradeEntryPrice - ProfitTarget1));
}
}
if (Strategy.isInTrade() == true && (Strategy.isLong() == true)) {
// Check if the profit target has been reached/breached
if (high() >= (nTradeEntryPrice + ProfitTarget1)) {
// Profit Target Breached, Execute Sell order.
Strategy.doSell("Long PT1 Exit", Strategy.STOP, Strategy.THISBAR,
Strategy.getDefaultLotSize(), (nTradeEntryPrice + ProfitTarget1));
STOP TARGET BREECH CODE:
if (Strategy.isInTrade() == true && (Strategy.isShort() == true)) {
// Check if the profit target has been reached/breached
if (high() >= nStopLevel) {
// Stop Breached, Execute Cover order.
Strategy.doCover("Short T-Stop Exit", Strategy.STOP, Strategy.THISBAR,
Strategy.getDefaultLotSize(), nStopLevel);
}
}
if (Strategy.isInTrade() == true && (Strategy.isLong() == true)) {
// Check if the profit target has been reached/breached
if (low() <= nStopLevel) {
// Stop Breached, Execute Sell order.
Strategy.doSell("Long T-Stop Exit", Strategy.STOP, Strategy.THISBAR,
Strategy.getDefaultLotSize(),nStopLevel);
Comment