how to do this in AB ?

#1
Hi guys, I have been trying to work on my system and the problem I face is that not all the indicators give a signal at the same time. So Stoch might have crossed a couple of days back but MACD only crossed its signal line today and ADX might cross tomorrow.

So in short how do I check if an indicator gave a positive signal in the last 7 days and another gave today and check for it in the BUY rule. thanx a lot.
 

beginner_av

Well-Known Member
#2
if you are using AA, just increase you n last days to 7. Since your question is too newbie like, I assume you are new to AB, so I am not going into the AFL part.
 
#3
Hi guys, I have been trying to work on my system and the problem I face is that not all the indicators give a signal at the same time. So Stoch might have crossed a couple of days back but MACD only crossed its signal line today and ADX might cross tomorrow.

So in short how do I check if an indicator gave a positive signal in the last 7 days and another gave today and check for it in the BUY rule. thanx a lot.
Hi,

You can use ValueWhen() clubbed together with DateNum() to achieve what you are looking for.

This is not possible without an AFL.

Praveen.
 
#4
thanx for the replies guys. I am happy to do AFL coding, although not an expert.

I was wondering if I can use BarsSince ? like
Code:
BUY = BarsSince(ADXBuy) <= 7;
where ADXBuy would have given the signal a few days back ?

With ValueWhen() and DateNum() can you give a small example ? it will help me get on my way. thanx.
 
#5
thanx for the replies guys. I am happy to do AFL coding, although not an expert.

I was wondering if I can use BarsSince ? like
Code:
BUY = BarsSince(ADXBuy) <= 7;
where ADXBuy would have given the signal a few days back ?

With ValueWhen() and DateNum() can you give a small example ? it will help me get on my way. thanx.
Yes, BarsSince should solve the problem.

Its much simpler than using ValueWhen and DateNum. What I thought was to use ValueWhen to get the last day we got the buy signal. And then compare it with DateNum of current day. As you can see, BarsSince provides this functionality at one shot.

Praveen.
 
#8
I would like to sort scans results by time. But Amibroker seems to sort them
by date only. Could someone let me know how to sort by time?
Simple. Use SetSortColumns() to set the column number to sort.

For eg. if your Scan output is in the format: Ticker, Date, Trade,etc, use SetSortColumns(3);

It takes the column number, the index of which starts from 1. Give negative number to mean descending order. ie SetSortColumns(-3); would sort the results, in this example, in datetime descending order.

Praveen.
 
#9
Swagat and Praveen

Thanks for the response.

When i try to sort the scan results manually I am able to sort by clicking on the column header for all the other parameters like ticker, trade, price etc. When I try to sort the datetime column it automatically sorts by date only and fails to take time into account. This becomes painful when your are running intraday scans.

Praveen as you said I would be able automate the scan process by using the setsortcolumn.

But I also need the scan to be sorted datetime wise so that the last results are displayed
on top. Is there a solution for this. Please suggest (My guess is the format of the datetime field must be properly set. How to do this? )

Thanks
 
#10
Hi,

As I'd said SetSortColumns() solves your problem. It takes care of time too.
Please refer to the screen shot attached.

Note both the AA output, as well as the AFL at the background.

Praveen.
 

Attachments