[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] "Pimping" my code


  • Date: Mon, 1 Feb 2010 14:33:34 +0100
  • From: "Markus Witzler" <funnybiz@xxxxxx>
  • Subject: Re: [amibroker] "Pimping" my code

PureBytes Links

Trading Reference Links



Hello Aron,
 
right, I was thinking too complicated.    ;-)
 
Still, would storing the results of the loop into an addtocomposite ticker make sense that my code could access every time it checked for a MY crossover instead of running the loop?
 
Thanks for your clue!
 
Markus
----- Original Message -----
From: Aron
Sent: Monday, February 01, 2010 1:52 PM
Subject: Re: [amibroker] "Pimping" my code

 

period1 =  Optimize("period1", 25, 10, 50, 5);
period2=
Optimize("period2", 840, 800, 900, 10);

fast [
0] = C[0];
slow [
0] = C[0];
for( bar = 1; bar < BarCount; bar++ )
{
   fast[ bar ] =fast[bar-
1]+(Close[bar]-fast[bar-1])*2/(period1+1);
   slow[ bar ] =slow[bar-
1]+(Close[bar]-slow[bar-1])*2/(period2+1);
}

Plot(fast, "" ,colorGreen);
Plot(slow, "", colorRed);

Buy = Cross(fast, slow);
Sell = Cross(slow,fast);




On 2/1/2010 1:26 PM, Markus Witzler wrote:

Hello,
 
I have loops built into my code and thus suppose that it´s running too slow.
 
I use a EMA crossover system (long side only at this point):
 

Buy= Cum(1)>=25 AND Cross(Fast_EMA(period1), Slow_EMA(period2))AND period1 < period2;

Sell= Cross(Slow_EMA(period2), Fast_EMA(period1));

I coded Fast_EMA and Slow_EMA instead of using AB´s built-in EMA function to be able to use my own seed values.

Anyways, the code for both follows further below.

Would the rode run faster, if I stored the values for fast_MA and slow_EMA in a separate composite and then used these in the buy and sell rules?

Or is there another way to make my code faster? Are there some clues how to "pimp" my code when I "have" to use loops (for instance when coding proprietary stops instead of applystop etc.)???

Some other general guidelines what to look out for when trying to keep the code as fast as possible (or better: the execution thereof)??

Thanks

Markus

function Fast_EMA( period1 )

{ local bar;

for( bar = 0; bar < BarCount; bar++ )

{ if (bar < 1)

EMA_fast[ bar ] = Close[ 0 ];

else

EMA_fast[ bar ] =EMA_fast[bar-1]+(Close[bar]-EMA_fast[bar-1])*2/(period1+1);

}

return EMA_fast;

}

period1 = Optimize("period1", 25, 10, 50, 5);

Exp_MA_fast = Fast_EMA ( Period1 );

 

function Slow_EMA( period2 )

{ local bar;

for( bar = 0; bar < BarCount; bar++ )

{ if (bar < 1)

EMA_slow[ bar ] = Close[ 0 ];

else

EMA_slow[ bar ] =EMA_slow[bar-1]+(Close[bar]-EMA_slow[bar-1])*2/(period2+1);

}

return EMA_slow;

}

period2 = Optimize("period2", 840, 800, 900, 10);

Exp_MA_slow = Fast_EMA ( Period2 );

 



__________ Information from ESET Smart Security, version of virus signature database 4668 (20091207) __________

The message was checked by ESET Smart Security.

http://www.eset.com



__________ Information from ESET Smart Security, version of virus signature database 4668 (20091207) __________

The message was checked by ESET Smart Security.

http://www.eset.com


__________ Information from ESET Smart Security, version of virus signature database 4668 (20091207) __________

The message was checked by ESET Smart Security.

http://www.eset.com


__._,_.___


**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/





Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___