JohnScher

Long only strategy with the TMA channel

Category: Strategies By: JohnScher Created: December 13, 2019, 9:03 AM
December 13, 2019, 9:03 AM
Strategies
25 Comments
Long only strategy with the TMA channel

as simple as it gets

I stole the indicator from here.
https://www.prorealcode.com/prorealtime-indicators/tma-center-channel-bands/
Then I rewrote the indicator into a strategy.

The action instruction is Long after the price crosses over (!) the lower band with the target the middle line of the channel.

thats all
until then

//-------------------------------------------------------------------------
// maincode : TMA Channel 4H co lowerband
// coded by johnscher

// works on dax 1 euro
// timeframe 4H
// timezone europetime, berlin
//-------------------------------------------------------------------------

defparam cumulateorders = false

// parameters
HalfLength = 141
AtrLength = 141
AtrMultiplier = 2.4
 
avg = average [1](close)
 
sum = (HalfLength+1)*avg
sumw = (HalfLength+1)
k = HalfLength
 
for j = 1 to HalfLength do
k = k-1
sum = sum+(k*avg[j])
sumw = sumw+k
next
 
 
myrange = AverageTrueRange[AtrLength](close)*AtrMultiplier

middleband = sum/sumw
//higherband = buffer1+myrange
lowerband = middleband-myrange
 

TradingDay = opendayofweek = 1 or dayofweek = 2 or dayofweek = 3  or  dayofweek = 4 or dayofweek = 5
TradingTime = time = 090000 or time = 130000 or time = 170000

IF TradingDay and TradingTime then
if average [1] (close) crosses over lowerband then
buy at market
endif
Endif

if average [1] (close) crosses over middleband then
sell at market
endif


set stop %loss 3
set target %profit 3 // as insurance

Download
Filename: LongOnly-DAX-4H-TMA-Channel.itf
Downloads: 1034
JohnScher
JohnScher Veteran
Code artist, my biography is a blank page waiting to be scripted. Imagine a bio so awesome it hasn't been coded yet.
Author’s Profile

Comments

Fralex
3 years ago
#

Hello everyone I optimized the original “LongOnly-DAX-4H-TMA-Channel” algorithm over a period of 4 years, from January 2020 to December 2023 The progression of earnings is regular. If you want to do the test, you must take the following parameters: HalfLength = 295 AtrLength = 630 AtrMultiply = 5.8 set stop %loss 3.3 set target %profit 5 Note: I called my algorithm WMA and not TMA because the average is a weighted average and not a Triangular average. The backtest from August 2010 is correct (backtest 1 Mu) Optimization over 13.5 years gives a very good result

superfalcio
4 years ago
#

hello, this strategy is pretty interesting, anyway on index after diferent suggestion and improvement is there a resumed final strategy?

Ludwig
5 years ago
#

Bonjour Merci pour le code, je souhaite intégrer un break even et mette en place un réinvestissement mais impossible avec ce code, quelqu’un aurait une solution?

Bruno38340
6 years ago
#

Bonjour, merci pour le code... Comment peut-on changer/augmenter le nombre de lots achetés sur le Dax30 ?

Ciurno981
6 years ago
#

il suffit de changer le nombre de contrats à acheter

Marcelus
6 years ago
#

Bonjour, Sur Dax , en 4h avec ces réglages backtestés depuis 2011 (200000unités) : HalfLength = 170 AtrLength = 40 AtrMultiplier = 2.8 sum = (HalfLength+1)*avg sumw = (HalfLength+16) set stop %loss 3 set target %profit 3.6 j'obtiens 83,78% de positions gagnantes, un profit factor de 2,73, et 84% de gain pour un capital de 10000€. si quelqu'un à mieux? Bien à vous.

Marcelus
6 years ago
#

Bonjour, Sur Dax , en 1h avec ces réglages depuis 2011 : - HalfLength = 170 AtrLength = 40 AtrMultiplier = 2.8

Gigi
6 years ago
#

Bonjour, pourrait on mettre cette stratégie en Daily?

sfl
sfl
7 years ago
#

Hi, What is the meaning of the time filer ? Why 9:00 13:00 and 17:00 ?

JohnScher
7 years ago
#

The 4H candles begin at 09.00 13.00 17.00

Crystal Babe
7 years ago
#

Hi John, this strategy is Great for DJI -justneededa bitof tweaking for the 1 hr chart. Thanks a million. though its coded to eit early at lowerchannel level , i have edited them to exit at higher levels with lovely results. John, if you dont mind can you explain which parameters i need to inverse to go short? ( planning for the near future:))

Anonymous
6 years ago
#

Hi Crystal Babe - would you be happy sharing your revised code as I too am testing this on the DJI? Many thanks

ALZ
ALZ
7 years ago
#

Hi Regarding the DAX, it's good too with 200k bars (with parameters of the basic idea) For DJI with 200k, i try to have good result but it seems to be impossible to apply this strategy on DJI... maybe other markets...

winnie37
7 years ago
#

could you post for Dji please?

JohnScher
7 years ago
#

I'm sorry, I specialized in the Dax. I'm sure the basic idea of the strategy also works in the Dow Jones. Maybe, you can try the optimization for Dow Jones.

ALZ
ALZ
7 years ago
#

Nice JohnSchern, thx for your contribution i'm going too with my parameters

JohnScher
7 years ago
#

Thank you very much. I am glad that the code is so well accepted here. As for improvements through optimization, I would like to say that I have not optimized through. I was more interested in trading the track from crossover the lowerline to the finish midline. Furthermore I would like to add that the system has been running in demo since 28.12.2018 with tema 12 close as avg and sl tp 2.4%. Number of trades = 12 Won = 10 loss = 2 gains = 554 Euro From 01.01.20 it goes live at ig.com/australia with the germany 30 cash (1£) have good times until then

juju333
7 years ago
#

Quite good results with 'Soy Flour' (SM) too : +63.99 % in H4 100 K (dont' really know the spread) : //------------------------------------------------------------------------- // maincode : TMA Channel 4H co lowerband // coded by johnscher // works on dax 1 euro // timeframe 4H // timezone europetime, berlin //------------------------------------------------------------------------- defparam cumulateorders = false // parameters HalfLength = 151 AtrLength = 151 AtrMultiplier = 2.5 avg = average [1](close) sum = (HalfLength+1)*avg sumw = (HalfLength+1) k = HalfLength for j = 1 to HalfLength do k = k-1 sum = sum+(k*avg[j]) sumw = sumw+k next myrange = AverageTrueRange[AtrLength](close)*AtrMultiplier middleband = sum/sumw //higherband = buffer1+myrange lowerband = middleband-myrange TradingDay = opendayofweek = 1 or dayofweek = 2 or dayofweek = 3 or dayofweek = 4 or dayofweek = 5 TradingTime = time = 090000 or time = 170000 or time = 230000 IF TradingDay and TradingTime then if average [1] (close) crosses over lowerband then buy at market endif Endif if average [1] (close) crosses over middleband then sell at market endif set stop %loss 3 set target %profit 4 // as insurance

ALZ
ALZ
7 years ago
#

thanks juju of course time isn't optimized for DJI See below new version with optimized parameters with profit 1.5 and time = 090000 or time = 120000 on DJI H1 we have 50.42 for the profit factor with only 2 losses

juju333
7 years ago
#

Not sure to have the good parameters : on DJI H1 (100 K, which brings back to 30 july 2015) ? could you repost the all code ? thanks !

juju333
7 years ago
#

Slightly better in 100K (DAX H4) with this : TradingTime = time = 090000 or time = 130000 or time = 160000 set target %profit 2

juju333
7 years ago
#

Thanks JohnScher for sharing and ALZ for optimization. I'll try it !

ALZ
ALZ
7 years ago
#

With same parameters, it works as well on DJI / H1

ALZ
ALZ
7 years ago
#

Hi JohnScher, Nice work Is system works well in production ? With these parameters, the resultat is even better HalfLength = 151 AtrLength = 151 AtrMultiplier = 2.5

Ciurno981
6 years ago
#

Does anyone have the data at 200,000 units, why would I like to see over 5 years?

ProRealCode ProRealCode
Loading...