Gamestudio Links
Zorro Links
Newest Posts
Bmap creation - wrong Alpha values
by txesmi. 12/11/19 12:43
A9
by preacherX. 12/11/19 11:01
Error Message 010: invalid stops
by Volker. 12/11/19 08:25
AssetFix & Assets.csv
by MatPed. 12/11/19 07:03
How to handle profit in a TMF during training
by StefanCGN. 12/09/19 20:09
Simulate complex commission costs [Test]
by AndrewAMD. 12/09/19 13:52
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online Now
6 registered members (3run, AndrewAMD, Volker, Quad, PabloMF, 1 invisible), 802 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
timW, PabloMF, deepscreener, wzschultz, Alit
18342 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
trade idea - your inputs needed #478526
11/03/19 09:28
11/03/19 09:28
Joined: Mar 2019
Posts: 11
S
Smallz Offline OP
Newbie
Smallz  Offline OP
Newbie
S

Joined: Mar 2019
Posts: 11
Hi all

We've put a simplistic trade idea into code. Intuitively the description seems to make sense, but for some reasons, we get funny outputs when we train it. In particular, the first parameter never goes beyond 1.0 when we plot the charts for the parameters. Also,we only get very few trades, which seems strange.

We think that it's more of a problem on how we put it into code, rather than the idea itself, but maybe we are just sitting on a bad trade idea itself.

Would you mind taking a look at this and give some feedback and improvement suggestions?
Here's where we think that we might have problems:
- Lookback period?
- Time frame?
- the parameters in general?
- stop loss/ take profit rules could maybe be useless the way we've done it?
- unknown other issues?

Short description of the trade idea itself:

We want to identify that there is a trend, and then trade in direction of that trend based on a temporary retrace.
The trend is identified by using either (1) the rate of change of the moving average or a bandpass filter looking back a certain amount of time or (2) the rate of change of the price looking back a certain amount of time.
Once a certain rate of change is "achieved", we consider this as a threshold to say that "yes, we are in an up/downtrend".
The actual trade is triggered by a rather fast RSI on close.
Example: Say the threshold for an uptrend is that the rate of change of the moving average over the last x closing prices is -1.2, then we know that we are in a downtrend. A trade would then be triggered if the e.g. RSI (3) on close is overbought by closing e.g. above 70. (remember we want to trade in direction of the trade on a temporary weakness of the trend itself, basically assuming, that the trend will continue.)
By filtering the environment for "trending" vs. "not trending", we though we could eliminate thy typical whipsaw one gets if one purely trades based on RSI being overbought or oversold, no matter the environment.
We've thought that the stop loss could be some multiple of an ATR, and the take profit to be a trailing stop, again based on ATR. Suggestions are very welcome on this part.


Thanks in advance for your feedback. Don't hesitate to tell us that we are fooling ourselves and this is not worth pursuing any further. eek


Code
// Strategy template ///////////////////////





function run()
{
set(PARAMETERS|LOGFILE);  // generate and use optimized parameters
BarPeriod = 60; // 4 hour bars
LookBack = 500;
StartDate = 2005;
EndDate = 2017; // fixed simulation period
NumWFOCycles = 10; // activate WFO
NumCores = -1; // multicore training

asset("EUR/USD");

if(ReTrain) {
UpdateDays = -1; 
SelectWFO = -1; 
}

// calculate the buy/sell signal
vars Prices = series(price());
//var RoCValue = ROC(Prices,optimize(100,2,400,2)); // maybe use rate of change of the price or even a bandpass filter instead of the rate of change of moving averag as below???
var RoCValue = ROC(series(SMA(Prices,50)),5);
var RSIValue = RSI(Prices,optimize(2,2,40,1));

// buy and sell
var upperLimit = optimize(1.6,1,10,0.1); 
var lowerLimit = -1 * upperLimit;
var RSIoverSold = 30;
var RSIoverBought = 100 - RSIoverSold; 

Stop = optimize(1,1,20,1) * ATR(optimize(21,2,200,2)); //
Trail = optimize(1,1,20,1) * ATR(optimize(21,2,200,2)); //

if(RoCValue > upperLimit)
{
//uptrend and look out for RSI oversold
if(RSIValue < RSIoverSold)
enterLong();
}

if(RoCValue < lowerLimit)
{
//downtrend and look out for RSI overbought
if(RSIValue > RSIoverBought)
enterShort();
}

// plot signals and thresholds
PlotWidth = 1600;
PlotHeight1 = 800;
set(PLOTNOW);
}





Last edited by Smallz; 11/03/19 09:30.
Re: trade idea - your inputs needed [Re: Smallz] #478547
11/05/19 20:45
11/05/19 20:45
Joined: Oct 2017
Posts: 38
Brazil
J
jmlocatelli Offline
Newbie
jmlocatelli  Offline
Newbie
J

Joined: Oct 2017
Posts: 38
Brazil
Hi Smallz,

I figured out some small changes in your script that potentially could improve the results.

In order to increase the number of trades, I would suggest you to change the optimization range of RoC limits to something like:

var upperLimit = optimize(0.05,0.01,0.10);

As a trend indicator, try this:

int TrendPeriod = optimize(20,2,50);
int RoCPeriod = optimize(5,2,20,1);
var RoCValue = ROC(series(DEMA(series(DEMA(Prices,TrendPeriod)),TrendPeriod)),RoCPeriod);

Regarding the stops, add a TrailLock:

TrailLock = optimize(0,0,100,5);

Let us know if there was any improvement.

best regards,
jl

Re: trade idea - your inputs needed [Re: jmlocatelli] #478589
11/12/19 06:20
11/12/19 06:20
Joined: Mar 2019
Posts: 11
S
Smallz Offline OP
Newbie
Smallz  Offline OP
Newbie
S

Joined: Mar 2019
Posts: 11

Originally Posted by jmlocatelli


Let us know if there was any improvement.

best regards,
jl



Thanks JL!

We changed the code as suggested, but the performance didn't get much better, tbh.
Performance graph looks kinda weird, it's flattish, only in the end it makes a bit of money.

It's strange, because just intuitively it makes sense to trade like this, but maybe we are fooling ourselves when looking at the chart. Or we are not coding it right. It can't be that bad.

Any other idea how to approach this?

Re: trade idea - your inputs needed [Re: Smallz] #478591
11/12/19 11:26
11/12/19 11:26
Joined: Aug 2017
Posts: 102
Spain
B
Brax Offline
Member
Brax  Offline
Member
B

Joined: Aug 2017
Posts: 102
Spain
Hello.

Some suggestions:

- First try the system without any filter at all, compare results.
- Then use a simple moving average filter for determining trend, just something like price > sma or sma > sma[1], compare results.
- Give MMI a try as stated in WorkShop6.

Sometimes this works better than other more elaborated models. On the other hand, trying to filter flat periods is not easy, you are most times better off just diversifying on assets/algos or just using phantom trade.

Also, maybe you are using the right strategy on the wrong timeframe/asset. Try a portfolio of assets and compare performance.

Greetings.


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1