Amibroker - How to do this? - Aussie Stock Forums

# Thread: Amibroker - How to do this?

1. ## Amibroker - How to do this?

In AB, how do I check if an indicator gave a positive signal in the last 7 days ?
For example if STOCH or MACD crossed its signal line 5 days ago but the EMA just crossed ? as sometimes not all the signals cross at the same time. I have been trying but with no success.
thanx.

2. ## Re: Amibroker - How To do this....

Originally Posted by R0n1n
In AB, how do I check if an indicator gave a positive signal in the last 7 days ?
For example if STOCH or MACD crossed its signal line 5 days ago but the EMA just crossed ? as sometimes not all the signals cross at the same time. I have been trying but with no success.
thanx.
Use the "Hold" code.
HOLD

SYNTAX hold( EXPRESSION, periods )
RETURNS ARRAY
FUNCTION Holds a "true" result of EXPRESSION for the specified number of periods. This true result is held true over the number of periods specified even if a "false" result is generated.
EXAMPLE hold( cross(rsi(14),70),5 )

3. ## Re: Amibroker - How To do this....

thanx for that wayneL,

does "This true result is held true over the number of periods specified even if a "false" result is generated. " mean that, lets say, the signal got generated 5 days ago and HOLD is keeping it, but in the mean time the RSI has fallen below the threshhold, HOLD would still give me a positive ?

4. ## Re: Amibroker - How To do this....

Originally Posted by R0n1n
thanx for that wayneL,

does "This true result is held true over the number of periods specified even if a "false" result is generated. " mean that, lets say, the signal got generated 5 days ago and HOLD is keeping it, but in the mean time the RSI has fallen below the threshhold, HOLD would still give me a positive ?
yes exactly

5. ## Re: Amibroker - How To do this....

You can also use BarsSince, as in:

sig1 = Cross(macdLine, macdSignal); // MACD crossover
sig2 = Cross(ema1, ema2); // EMA crossover

haveSignal = sig2 && BarsSince(sig1) <= 7;

GP

6. ## Re: Amibroker - How To do this....

thanx guys for it. Can I use lookback as well?

Here is how it looks for me.

Code:
```Signal1 = BarsSince(MABuy) <= 7;
Buy = Signal1 AND Signal2 AND Signal3;```
So when I replace it with
Code:
`Buy = Signal1 OR Signal2 OR Signal3`

thanx for ur help guys.

7. ## Re: Amibroker - How To do this....

Are you sure you're actually getting all three buy signals within those 7 days apart?

Use DebugView and add a trace loop after the "Buy=" statement like this:

dt = DateTime();
for (i = 0; i < BarCount; i++)
_TRACE(DateTimeToStr(dt[i]) + StrFormat(": MABuy = %1.0f, sig1 = %1.0f, sig2 = %1.0f", MABuy[i], sig1[i], sig2[i]));

then after doing a run, look through the trace for all the '1' indications and see if there are any that comply with the 7 days apart conditions.

Or trying testing with only two conditions at a time, to see which pairs are not falling within the 7 days apart.

GP

8. ## Re: Amibroker - How To do this....

Hi ya all. My AFL syntax skills are zilch and frankly I have no intention of learning more than the basics.

I have a VPA formula that I need a function removed/disabled from it and simply if possible. That being the ticker and url on the chart background.

I think it is this part

Code:
```if( Status("action") == actionCommentary )
(
printf ( "=========================" +"\n"));
printf ( "VOLUME PRICE ANALYSIS" +"\n");
printf ( "www.vpanalysis.blogspot.com" +"\n");
printf ( "=========================" +"\n");
printf ( Name() + " - " +Interval(2) +  "  - " + Date() +" - " +"\n"+"High-"+H+"\n"+"Low-"+L+"\n"+"Open-"+O+"\n"+
"Close-"+C+"\n"+ "Volume= "+ WriteVal(V)+"\n");
WriteIf(Vpc,"=======================","");
WriteIf(Vpc,"VOLUME ANALYSIS COMMENTARY:\n","");```