Gamestudio Links
Zorro Links
Newest Posts
Votes for future features
by 7th_zorro
Today at 01:57
Open WMB file
by Superku
Yesterday at 23:37
Stopping and resuming sessions without interrupting trade statis
by jcl
Yesterday at 08:14
Best Devlopment Experience
by j45p41
03/20/19 23:04
Blog Post: Continuous Futures Data in Zorro
by chsmac85
03/20/19 15:59
Error message : Closing Order Quantity
by OptimusPrime
03/20/19 12:49
script can work but no result(Profit and loss)
by jcl
03/20/19 09:12
AUM Magazine
Latest Screens
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Evonet Beta v1.0 : Online Project Development Template
Who's Online
3 registered (AndrewAMD, 7th_zorro, 1 invisible), 658 Guests and 8 Spiders online.
Key: Admin, Global Mod, Mod
Newest Members
FrankFred, QuartzLoop, Conchip, danatrader, ilikezorro
18190 Registered Users
Topic Options
Rate This Topic
#448932 - 02/26/15 08:07 CyberCycle Adaptive Cy
tvas Offline
Newbie

Registered: 12/10/13
Posts: 13
Here are two instantly profitable strategies which how

Top
#448933 - 02/26/15 08:13 Re: CyberCycle Adaptive Cy [Re: tvas]
tvas Offline
Newbie

Registered: 12/10/13
Posts: 13
The TS code for the CyberCycle strategy as defined by Ehlers. The interesting thing is that this strategy can generate good returns when executed in reverse mode (do exactly the opposite as Mr. Ehlers suggested :)) on volatile instruments (best candidate is GBPJPY) and a time frame around 240 min in order ot avoid too frequent trading. Alternatively you can run it on range bars of ca. 50 pips. It shouldn't be difficult to port the strategy to Zorro and play with it.

////////////////////////////////////////////////////////////////
Inputs: Price((H+L)/2) ,alpha(.07), Lag(9), Reverse(false);
Vars: Smooth(0),
Cycle(0),
alpha2(0),
Signal(0);
Smooth = (Price + 2*Price[1] + 2*Price[2] + Price[3])/6;
Cycle = (1 - .5*alpha)*(1 - .5*alpha)*(Smooth - 2*Smooth[1] + Smooth[2]) + 2*(1 - alpha)*Cycle[1] - (1 - alpha)*(1 - alpha)*Cycle[2];

If currentbar < 7 then Cycle = (Price - 2*Price[1] + Price[2]) / 4;
alpha2 = 1 / (Lag + 1);
Signal = alpha2*Cycle + (1 - alpha2)*Signal[1];

If Reverse then begin
If Signal Crosses Over Signal[1] then Buy Next Bar on Open;
If Signal Crosses Under Signal[1] then Sell Short Next Bar on Open;
end Else begin
If Signal Crosses Under Signal[1] then Buy Next Bar on Open;
If Signal Crosses Over Signal[1] then Sell Short Next Bar on Open;
end;

If MarketPosition = 1 and PositionProfit < 0 and BarsSinceEntry > 8 then Sell This Bar;
If MarketPosition = -1 and PositionProfit < 0 and BarsSinceEntry > 8 then Buy To Cover This Bar;

////////////////////////////////////////////////////////////////

Top
#448934 - 02/26/15 08:28 Re: CyberCycle Adaptive Cy [Re: tvas]
tvas Offline
Newbie

Registered: 12/10/13
Posts: 13
And here is a strategy which uses the Adaptive Cyber Cycle (Cyber Cycle's alpha1 parameter is based on the full Dominant Cycle). To make this strategy profitable you should run it in reverse mode (again: do exactly the opposite what Mr. Ehlers suggests :)) and combine it with a trailing stop exit method which is not included in the code because in TS I simply combine the strategy with the standard PercentTrailing strategy. A good result can be achieved on GBPJPY, time frame 240 min and a percent trailing exit which triggers when the profit exceeds 30 pips and risks 10% from the profit.

/////////////////////////////////////////////////////////////////////
Inputs: Price((H+L)/2) ,alpha(.07), Lag(9), Reverse(false);

Vars: Smooth(0),Cycle(0),Q1(0),I1(0),DeltaPhase(0),MedianDelta(0),DC(0),InstPeriod(0),Period(0),Length(0),Num(0),Denom(0),alpha1(0),Signal(0);

Smooth = (Price + 2*Price[1] + 2*Price[2] + Price[3])/6;
Cycle = (1 -.5*alpha)*(1 - .5*alpha)*(Smooth - 2*Smooth[1] + Smooth[2]) + 2*(1 - alpha)*Cycle[1] - (1 - alpha)*(1 - alpha)*Cycle[2];
If currentbar < 7 then Cycle = (Price - 2*Price[1] + Price[2]) / 4;

Q1 = (.0962*Cycle + .5769*Cycle[2] - .5769*Cycle[4] - .0962*Cycle[6])*(.5 + .08*InstPeriod[1]);
I1 = Cycle[3];
If Q1 <> 0 and Q1[1] <> 0 then DeltaPhase = (I1/Q1 - I1[1]/Q1[1]) / (1 + I1*I1[1]/(Q1*Q1[1]));
If DeltaPhase < 0.1 then DeltaPhase = 0.1;
If DeltaPhase > 1.1 then DeltaPhase = 1.1;
MedianDelta = Median(DeltaPhase, 5);
If MedianDelta = 0 then DC = 15 else DC = 6.28318 / MedianDelta + .5;
InstPeriod = .33*DC + .67*InstPeriod[1];
Period = .15*InstPeriod + .85*Period[1];
alpha1 = 2 / (Period + 1);
Signal = (1 - .5*alpha1)*(1 - .5*alpha1)*(Smooth - 2*Smooth[1] + Smooth[2]) + 2*(1 - alpha1)*Signal[1] - (1 - alpha1)*(1 - alpha1)*Signal[2];
If currentbar < 7 then Signal = (Price - 2*Price[1] + Price[2]) / 4;

If Reverse then begin
If Signal Crosses Over Signal[1] then Buy Next Bar on Open;
If Signal Crosses Under Signal[1] then Sell Short Next Bar on Open;
end Else begin
If Signal Crosses Under Signal[1] then Buy Next Bar on Open;
If Signal Crosses Over Signal[1] then Sell Short Next Bar on Open;
end;

If MarketPosition = 1 and PositionProfit < 0 and BarsSinceEntry > 8 then Sell This Bar;
If MarketPosition = -1 and PositionProfit < 0 and BarsSinceEntry > 8 then Buy To Cover This Bar;
////////////////////////////////////////////////////////////////////////////////

Top
#450478 - 04/15/15 15:17 Re: CyberCycle Adaptive Cy [Re: tvas]
forexcoder Offline
Newbie

Registered: 02/16/15
Posts: 45
Loc: Italy
Tvas thanks for sharing your strategies! Much appreciated.
I don't know TS language. Can someone help me to translate that code in Zorro? Thanks in advance.

Top
#475021 - 11/19/18 05:26 Re: CyberCycle Adaptive Cy [Re: forexcoder]
OptimusPrime Offline
Junior Member

Registered: 08/09/18
Posts: 60
Hi Team:

Forgive the crude attempt, but I am trying to code the CyberCycle Internal Cycle.. It is giving an error message :
" Error 111: Crash in Function at Bar 0"
but I can't find the issue right now.


vars CyberCycleInternalCycle (var* Input, alpha)
{
vars ReversedSeries = rev(series(Input[0]));

vars RevCycle,iCycleCycle,Smooth = series();

int i=0;

for(i=0; i<(NumBars-1); i++)
{

if (i<3)
RevCycle[i]=Smooth[i]=ReversedSeries[i];

if (i<7 && i>2)
{
RevCycle[i]=(
ReversedSeries[i]
-2* ReversedSeries[i-1]
+ ReversedSeries[i-2]) /4;

Smooth[i] = (
ReversedSeries[i]
+ 2* ReversedSeries[i-1]
+ 2*ReversedSeries[i-2]
+ ReversedSeries[i-3]);

Smooth[i]=Smooth[i]/6;
}
else
RevCycle[i]=
(1 - .5*alpha)*(1 - .5*alpha)*(Smooth[i]
- 2*Smooth[i-1]
+ Smooth[i-2])
+ 2*(1 - alpha)*RevCycle[i-1]
- (1 - alpha)*(1 - alpha)*RevCycle[i-2];

}

iCycleCycle = rev(series(RevCycle[0]));

return iCycleCycle;

}
_________________________
Thanks so much,

OptimusPrime


Top
#475122 - 11/23/18 21:39 Re: CyberCycle Adaptive Cy [Re: OptimusPrime]
Spirit Offline
Moderator

Registered: 09/02/03
Posts: 819
It is crashing with empty pointers. You have 4 pointers but only 2 have series assigned.

Top
#475395 - 12/06/18 01:03 Re: CyberCycle Adaptive Cy [Re: Spirit]
OptimusPrime Offline
Junior Member

Registered: 08/09/18
Posts: 60
Hi Spirit:

I have tried to write a Variable Moving Average. This one too is not working.

What am I missing when it comes to series creation inside a function?

// NOT WORKING
///////////////////////////////////////////////////

///// Variable Moving Average /////

///////////////////////////////////////////////////

vars VariableMovingAverage (var* Input, int MAPeriod, int CMOPeriod)
{

int factor = (2/((MAPeriod)+1));

vars VI = series(abs((CMO(Input, CMOPeriod))/100) );

int m = max(MAPeriod, CMOPeriod);

vars v = series(0);

int i;

for (i=(NumBars-1); i>0; i--)
{
if (i>(NumBars-1-m))
v[i]= Input[i];
else
v[i] = (factor*VI[i]*Input[i]) + ((1-factor* VI[i])* v[i+1]);
} //end of loop

return v;
} //end of function
_________________________
Thanks so much,

OptimusPrime


Top
#475492 - 12/14/18 17:33 Re: CyberCycle Adaptive Cy [Re: OptimusPrime]
OptimusPrime Offline
Junior Member

Registered: 08/09/18
Posts: 60
thanks Andrew.. I will try with those changes.
_________________________
Thanks so much,

OptimusPrime


Top
#475493 - 12/14/18 17:47 Re: CyberCycle Adaptive Cy [Re: OptimusPrime]
AndrewAMD Online
User

Registered: 02/21/17
Posts: 583
Loc: Chicago
I think this piece of advice might be more helpful:

Sometimes you have to build a script piece by piece to make sure it works correctly, rather than throwing everything together at once and wondering for days why it doesn’t work. Do diagnostics for every step.

Top
#475502 - 12/16/18 07:26 Re: CyberCycle Adaptive Cy [Re: AndrewAMD]
OptimusPrime Offline
Junior Member

Registered: 08/09/18
Posts: 60
Hi Andrew:

Thanks for your suggestion to make it work within the run() loop instead of giving it a separate function. Yes, it was much easier that way.


Much Appreciated.


Edited by OptimusPrime (12/17/18 17:06)
_________________________
Thanks so much,

OptimusPrime


Top



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

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