Francesco78

USDJPY 3candles and reversal strategy with ADX and VOL filter.

Category: Strategies By: Francesco78 Created: May 15, 2017, 2:13 PM
May 15, 2017, 2:13 PM
Strategies
40 Comments
USDJPY 3candles and reversal strategy with ADX and VOL filter.

Dear all

I have been playing around with the concept of reversal after n consecutive bullish or bearish bars and I found a quite nice result in the USD JPY 1 hr timeframe.

The strategy has 3 condition:

  • 3 consecutive bars of hte same colour
  • ADX > ADXmin
  • Vol > Volmin ( expressed in ATR )

In attachment you find the results of a WF static analysis 70/30 with 3 variables.

Please feel free to comment, any constructive criticism will be greatly appreciated!

//USDJPY TF 1hr spread 1.5 pips

DEFPARAM CUMULATEORDERS = False
//DEFPARAM FLATBEFORE = 090000
//DEFPARAM FLATAFTER = 220000

//n = 3  // number of consecutive bars with the same colour
fastavperiod=5 /// period of fast moving average
slowavperiod=100// period of slow moving average
atrmin= 10 // take poistion only if there is enough vol
//adxval = 25 // take position only if there is a trend
//t = 7 // multiplier for exit strategy

volindic = averagetruerange[14]
fastav = average[fastavperiod](close)
slowav = average[slowavperiod](close)
cl = summation[n](close<open) = n
cs = summation[n](close>open) = n
volok = volindic > atrmin
ctrend = adx[14]>adxval
position = round(100/averagetruerange[14])

if cl and ctrend and fastav > slowav and volok then
 buy position contract at market
endif

if cs  and ctrend and fastav < slowav and volok then
 sellshort  position contract at market
endif

set target profit t*volindic
set stop ploss 2*t*volindic

 

Download
Filename: usdjpy3candlesreversion.itf
Downloads: 636
Download
Filename: wf_1.png
Downloads: 264
Francesco78
Francesco78 Master
Developer by day, aspiring writer by night. Still compiling my bio... Error 404: presentation not found.
Author’s Profile

Comments

Jusmih1
9 years ago
#

Hi there, i am looking at your Strategy however when you put in automatic trading mode its saying that I have to remove all the variables from the "Probacktest" and to replace them with specific numeric values in the code of the trading system? can you help me as I am not sure how to do this? Thank you

Francesco78
9 years ago
#

Hi Pepmartorell, please let's continue the discussion on the forum thread so that we can share pictures, I would like to see a snapshot of your screen when you try the backtest in order to help you.

this is the link

https://www.prorealcode.com/topic/ncandle-and-reversal-filtered-strategy/

 

Francesco78
9 years ago
#

Hi Pepmartorell, please let's continue the discussion on the forum thread so that we can share pictures, I would like to see a snapshot of your screen when you try the backtest in order to help you.

 

pepmartorell
9 years ago
#

 It seems it doesn't work, even with the change proposed by Francesco78. In fact the maximum amount of winning trades in my nacktest simulation is under 10%...

Where's my error? I apply the code on USDJPY at 1-hour frame, wth 1.5 pips, etc.

Francesco78
9 years ago
#

ciao Dario, 

try to change line 19 with 

volok = volindic > atrmin*pointsize

Let me know.

Best

DarioMazza
9 years ago
#

THIS doesn't work. no operations

Francesco78
9 years ago
#

Hi Grahal, thanks for your attention to my strategy, yes there is a forum thread I opened.

https://www.prorealcode.com/topic/ncandle-and-reversal-filtered-strategy/

GraHal
9 years ago
#

Hi Francesco78 are you opening a Forum thread for testing / discussions on this yet another excellent bot of yours.  Oops I didn't even look ... maybe you have already? :)  

Seems to work fine for me on USD/JPY. but I am also on IG spreadbet, I'll compare direct with your results tomorrow.

GraHal 

Francesco78
9 years ago
#

Thanks! I hope this will sort the issues some people were experiencing

Nicolas
9 years ago
#

 The problem is at line 19, you should adapt the 'atrmin' variable to the pointsize of the current security:

volok = volindic > atrmin*pointsize

I think there might be a problem in the stoploss size, you should use "loss" instead of "ploss", to be perfectly compatible with any instrument:

set stop loss 2*t*volindic

(like you did correctly for the takeprofit).

Francesco78
9 years ago
#

Ok thank you, I hope we will be able to find what is missing so that we can share our results more efficently in the future.

Ciao

juanj
9 years ago
#

Unfortunately not. However it is possible that there is a setting somewhere on your system that is different to ours.

The strategy however still holds merit as I can produce decent results on other markets, proving it is a valid strategy to outperform a given market.

I have strategies in place that outperform it on the 1 hr but the results are still good and the strategy can definitely be built upon.

Francesco78
9 years ago
#

ok I see, many thanks, so you are not able to replicate the results on USDJPY right?

 

juanj
9 years ago
#

Hi Francesco, I did use v10.3, however like the others I am having trouble running it on FX pairs on the original code. But the re-written code work well.

Your strategy also adapts very well to other markets. I have managed to get some good results out of it on some of the indexes.

It's a very cool idea. Well Done

Francesco78
9 years ago
#

are you all using v 10.3?

Francesco78
9 years ago
#

Guys volok means VOLATILITY ok.

there is no reference to volume in this code whatsoever

StantonR
9 years ago
#

Think Juan is right can run it on dax but not on forex pairs.
Could have something to do with volume. As volume is not available on forex pairs on some accounts.

Francesco78
9 years ago
#

Guys can you pls let me know if any one of you can run the code at all?

Thanks

StantonR
9 years ago
#

HI There

The security does not have volume but does  have ATR as you can add the ATR indicator.

So I dont think that is the issue.

StantonR
9 years ago
#

HI There

The security does not have volume but does have volume but does have ATR as you can add the ATR indicator.

So I dont think that is the issue.

Francesco78
9 years ago
#

 @ DEIO 

what do you mean? you mean that id doesnt give you any trade for currencies?

From what I have been looking at, it works well with USDCAD, GBPJPY, CADJPY and BUND

Francesco78
9 years ago
#

Hi Junaji, thank for your comments, I have always backtested in tick by tick mode. Please do not use any flat bore and flat after. I forgot to remove them from the original code. With flatbefore and flatafter the results are negative.

Best

juanj
9 years ago
#

I think the problem lies with the 'volok' parameter (line 19 in original code). I have rewritten the code to systematically determine where the problem might be (my flatbefore time is different due to my timezone).

Unfortunately using tick by tick testing yields negative results. Without tcik by tick the code performs very well in test period March 2013 to Current except for a period between March and October 2014 where there is a large draw down period.

//USDJPY TF 1hr spread 1.5 pips

DEFPARAM CUMULATEORDERS = False
DEFPARAM PRELOADBARS = 14
DEFPARAM FLATBEFORE = 010000
DEFPARAM FLATAFTER = 200000

possize = 1//round(100/averagetruerange[14])

n = 3 // number of consecutive bars with the same colour
fastma = 5 /// period of fast moving average
slowma = 100// period of slow moving average
adxval = 25 // take position only if there is a trend
t = 7 // multiplier for exit strategy
atr = averagetruerange[14](close)
atrmin = 10 // take poistion only if there is enough vol
fastav = average[fastma,1](close)
slowav = average[slowma,1](close)

red = 0
green = 0
For i = 1 to n
If close[i] > open[i] then
red = red + 1
ElsIf close[i] < open[i] then
green = green + 1
EndIf
Next

volok = 1 //no volume for security
If atr > atrmin then
volok = 1
EndIf

ctrend = 0
If adx[14] > adxval Then
ctrend = 1
EndIf

if countofposition = 0 and red >= n and ctrend = 1 and fastav > slowav and volok = 1 then
buy possize contract at market
endif

if countofposition = 0 and green >= n and ctrend = 1 and fastav < slowav and volok = 1 then
sellshort possize contract at market
endif

set target pprofit t*atr
set stop ploss 2*t*atr

 

Francesco78
9 years ago
#

Is it for working for anyone of you?

DEIO
9 years ago
#

hi Francesco,

it seems to me that it works with any instrument  but currencies.

It's possible ?

 

Francesco78
9 years ago
#

mm ok.. Im really wondering what's going on..

I'm testing it across many different currency pair and bund and seems to stay up quite nicely in most of the cases and most of timeframes.. I have a UK account but it shouldn't make any difference.

Try to use constant position maybe?

Nicolas was it working properly when you reviewed it?

 

Francesco78
9 years ago
#

mm ok.. Im really wondering what's going on..

I'm testing it across many different currency pair and bund and seems to stay up quite nicely in most of the cases and most of timeframes.. I have a UK account but it shouldn't make any difference

 

ALE
ALE
9 years ago
#

Hi Francesco

my EURO account no trade.

StantonR
9 years ago
#

Yeah my currency is in JPY for this pair added 1,000,000 yen still no trades

StantonR
9 years ago
#

Yeah my currency is in JPY for this pair

ProRealCode ProRealCode
Loading...