PureBytes Links
Trading Reference Links
|
Sorry, Correction, this one does not count the buy day in the barssinceEntry.
Buy = Cross( MACD(), Signal());
Sell=Cross(Signal(),MACD());
BarsSinceentry =0;
poslong=0;posshort=0;
for( i = 0; i < BarCount; i++ )
{
if( Buy[i])
{
poslong=1;posshort=0;
}
if(Sell[i])
{
poslong=0;posshort=1;
}
if(poslong==1)
{
if(Buy[i])
BarsSinceentry[i]=0;//BarsSinceentry[i-1]+1;
else
{
if(poslong==1)
BarsSinceentry[i]=BarsSinceentry[i-1]+1;
}
}
}
Days=BarsSinceentry;
Plot(C,"",colorBlack,styleCandle);
PlotShapes(Buy*shapeUpArrow,colorGreen);
Title=Name()+ " BarsSinceBuy [ "+WriteVal(Days,1)+ "]";
----- Original Message -----
From: Anthony Faragasso
To: amibroker@xxxxxxxxxxxxxxx
Sent: Sunday, October 31, 2004 7:49 PM
Subject: Re: [amibroker] Bars since Buy signal - how to code in AFL ?
Owen,
This is coded for the Buy side of the signal, load into Indicator builder, make sure that scaling is set to automatic...it seems that when you open a new formula window in Indicator builder it defaults to Custom scaling....you will see in the title the number of bars since buy...
it resets at every buy signal, currently it shows 0 for sell side......does this help ?
Anthony
Buy = Cross( MACD(), Signal());
Sell=Cross(Signal(),MACD());
BarsSinceentry =0;
poslong=0;posshort=0;
for( i = 0; i < BarCount; i++ )
{
if( Buy[i])
{
poslong=1;posshort=0;
}
if(Sell[i])
{
poslong=0;posshort=1;
}
if(poslong==1)
{
if(Buy[i])
BarsSinceentry[i]=BarsSinceentry[i-1]+1;
else
{
if(poslong==1)
BarsSinceentry[i]=BarsSinceentry[i-1]+1;
}
}
}
Days=BarsSinceentry;
Plot(C,"",colorBlack,styleCandle);
PlotShapes(Buy*shapeUpArrow,colorGreen);
Title=Name()+ " BarsSinceBuy [ "+WriteVal(Days,1)+ "]";
----- Original Message -----
From: Owen Davies
To: amibroker@xxxxxxxxxxxxxxx
Sent: Sunday, October 31, 2004 6:55 PM
Subject: Re: [amibroker] Bars since Buy signal - how to code in AFL ?
Anthony Faragasso wrote:
>Owen,
>
>Could it be written as a function:
>
That is the only way I can see to do it, but the task is beyond me.
That's why I keep goosing Tomasz every six or ten months. It's a
function I really believe should be built in.
Owen
Check AmiBroker web page at:
http://www.amibroker.com/
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Sponsor
ADVERTISEMENT
------------------------------------------------------------------------------
Yahoo! Groups Links
a.. To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
b.. To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
[Non-text portions of this message have been removed]
Check AmiBroker web page at:
http://www.amibroker.com/
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Sponsor
ADVERTISEMENT
------------------------------------------------------------------------------
Yahoo! Groups Links
a.. To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
b.. To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
[Non-text portions of this message have been removed]
------------------------ Yahoo! Groups Sponsor --------------------~-->
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~->
Check AmiBroker web page at:
http://www.amibroker.com/
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|