Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Quad, aliswee), 835 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 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: 22
S
Smallz Offline OP
Newbie
Smallz  Offline OP
Newbie
S

Joined: Mar 2019
Posts: 22
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: 52
Brazil
J
jmlocatelli Offline
Junior Member
jmlocatelli  Offline
Junior Member
J

Joined: Oct 2017
Posts: 52
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: 22
S
Smallz Offline OP
Newbie
Smallz  Offline OP
Newbie
S

Joined: Mar 2019
Posts: 22

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.


Moderated by  Petra 

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