MACD CCI Strategy

Strategies are published here.

Moderator: admin

MACD CCI Strategy

Postby Apprentice » Tue Nov 22, 2011 1:35 pm

MACD CCI Strategy.png


buying condition:

1. cci [period14] > buy level { and}
2. macd line cross over signal line { and}
3. signal line < buy level {0}

selling condition:

1. cci [ period 14] < sell level{ and }
2. macd line cross under signal line { and }
3. signal line > sell level {0}

exit buy conditions:

1. cci cross below buy level { or}
2. macd line cross under signal line

exit sell conditions:

1. cci cross above sell level {or}
2. macd line cross above signal line

MACD CCI Strategy.lua
(19.37 KiB) Downloaded 1250 times


The Strategy was revised and updated on November 21, 2018.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: MACD CCI Strategy

Postby transformer » Wed Nov 23, 2011 2:27 am

hi apprentice,

i request an indicator based on this strategy with bigger time frame feature.

GREEN COLOR:

1. cci [period 14] > 0 and macd line > signal line


RED COLOR:

1. cci [ period 14] < 0 and macd line < signal line


YELLOW COLOR

1. cci > 0 and macd line< signal line {or}

2. cci < 0 and macd line> signal line

thank you
User avatar
transformer
 
Posts: 84
Joined: Thu Nov 10, 2011 9:18 am


Re: MACD CCI Strategy

Postby transformer » Wed Nov 23, 2011 4:22 pm

thank you very much.
User avatar
transformer
 
Posts: 84
Joined: Thu Nov 10, 2011 9:18 am

Re: MACD CCI Strategy

Postby nicdu40 » Fri Nov 25, 2011 3:08 pm

hello , i'm new member here, first thank for all.

i modified this strategy like this :

buy condition : macd line cross over signal line and
signal line < - 0.0000X x line 0 and
macd line [period -1] < macd line [periode] - X <-------------------------

in fact i would want find something to change this last line by "macd line cross over signal line" whith X degres (betwen 45° and 135°for example) .
can you help me please?


this is a part of the modified code:

-- buying condition:

if core.crossesOver( Short["MACD"], Short["SIGNAL"] , period)
and Short["MACD"][period] < - MACDBS / 100000
and Short["MACD"][period -1] < - MACDec / 100000 + Short["MACD"][period]

then
if Direction then
BUY();
else
SELL();
end

--selling condition:

elseif core.crossesUnder( Short["MACD"], Short["SIGNAL"] , period)
and Short["MACD"][period] > MACDBS / 100000
and Short["MACD"][period -1] > MACDec / 100000 + Short["MACD"][period]

then

if Direction then
SELL();
else
BUY();
end
end

-- exit buy conditions

if core.crossesUnder( Short["MACD"], Short["SIGNAL"] , period)
and (( Short["MACD"][period] < - MACDBS /100000 ) or (( Short["MACD"][period -1] > MACDec / 100000 + Short["MACD"][period] ) and Short["SIGNAL"][period] < MACDBS /100000 ))

then

if Direction then
if haveTrades("B") then
exit("B");
Signal ("Close Long");
end
else
if haveTrades("S") then
exit("S");
Signal ("Close Short");
end

end
end
--exit sell conditions:

if core.crossesOver( Short["MACD"], Short["SIGNAL"] , period)
and (( Short["MACD"][period] > MACDBS /100000 ) or (( Short["MACD"][period -1] < Short["MACD"][period] - MACDec / 100000 ) and Short["SIGNAL"][period] > - MACDBS /100000 ))

then
if Direction then
if haveTrades("S") then
exit("S");
Signal ("Close Short");
end

else

if haveTrades("B") then
exit("B");
Signal ("Close Long");
nicdu40
 
Posts: 10
Joined: Fri Nov 25, 2011 2:44 pm

Re: MACD CCI Strategy

Postby Apprentice » Sat Nov 26, 2011 4:49 am

X degres ?
Do you think the pips.
I'm not sure, from where degrees came.
Describe to me what you want, add the formula.
I'm not sure that it is wisest to read your code.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: MACD CCI Strategy

Postby nicdu40 » Sat Nov 26, 2011 8:48 am

Image
for this example i want sell if angle (macd/signal) > X degres

i think i found :

but the angle is not realy the true angle but i think it's a good indice

tanMACD= (macd(period-1) -macd(period)

tanSIGNAL= signal(period-1) -signal(period)

angle(in radian) = math.atan (tanMAcD) + math.atan (tanSIGNAL)

thank you
nicdu40
 
Posts: 10
Joined: Fri Nov 25, 2011 2:44 pm

Re: MACD CCI Strategy

Postby Apprentice » Sat Nov 26, 2011 10:27 am

Here you have a serious problem.

X axis. We use periods
Y axis. We use Value
These are apples and pears.
And as such, does not mix.

What is the distance between two points on the x axis.

I suppose I could use the average change in some time.
As a reference value for the distance between two points on the X axis.

I suggest something simpler.
Difference in slope.
A = MACD [period]-MACD [period-1]
B = Signal [period] - Signal [period-1]

Difference = A - B

Basically it is a histogram.
You should only define trigger level for it.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: MACD CCI Strategy

Postby nicdu40 » Sat Nov 26, 2011 11:01 am

Yes ! its more simpler, and also effective, thank you very mutch!!!
nicdu40
 
Posts: 10
Joined: Fri Nov 25, 2011 2:44 pm

Re: MACD CCI Strategy

Postby Apprentice » Sun Nov 27, 2011 3:31 pm

MACD Strategy.png


This is a simple MACD Zero line, Cross Strategy.
As an additional filter you can add a minimum difference of MACD histogram,
that must be achieved, in order to enter the trade.

buying condition:

MACD / MACD Buy LineCrossover
and
Histogram[period-1] - Histogram[period] < Trigger

selling condition:
MACD / MACD Sell LineCrossunder
Histogram[period-1] - Histogram[period] > Trigger

exit buy conditions:
MACD / MACD Buy LineCrossunder
and
Histogram[period-1] - Histogram[period] > Trigger

exit sell conditions:
MACD / MACD Sell LineCrossover
and
Histogram[period-1] - Histogram[period] < Trigger

MACD Strategy.lua
(18.53 KiB) Downloaded 823 times


This is only first draft.
I hope that I understood the intent.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Next

Return to Custom Strategies

Who is online

Users browsing this forum: No registered users and 12 guests