Australian (ASX) Stock Market Forum

How to debug in Amibroker?

Joined
21 October 2012
Posts
46
Reactions
0
Hi

I'm a newbie here. This is my first post. I hope someone will help me to resolve a issue I'm facing in AmiBroker.




I have set up Email alert in AmiBroker>Preference>Alert correctly. I have also tested a TEST mail OK from Alert window.

However I still don't get email from AFL in my mailbox although I get Buy signals from this AFL during Scan.

Do you see anything wrong in this Email code ?

Buy = Cross(MA(C, 20), MA(C,50));
AlertIf(Buy,"EMAIL","A sample alert on"+FullName(),1);

How do I debug whats going wrong ?
 
Hi

I'm a newbie here. This is my first post. I hope someone will help me to resolve a issue I'm facing in AmiBroker.




I have set up Email alert in AmiBroker>Preference>Alert correctly. I have also tested a TEST mail OK from Alert window.

However I still don't get email from AFL in my mailbox although I get Buy signals from this AFL during Scan.

Do you see anything wrong in this Email code ?

Buy = Cross(MA(C, 20), MA(C,50));
AlertIf(Buy,"EMAIL","A sample alert on"+FullName(),1);

How do I debug whats going wrong ?

Read what is written in the manual

only lookback most recent bars are considered, default value is 1 (bar) for lookback.

AlertIf( BOOLEAN_EXPRESSION, command, text, type = 0, flags = 1+2+4+8, lookback = 1 );

lookback parameter controls how many recent bars are checked
 
Read what is written in the manual

only lookback most recent bars are considered, default value is 1 (bar) for lookback.

AlertIf( BOOLEAN_EXPRESSION, command, text, type = 0, flags = 1+2+4+8, lookback = 1 );

lookback parameter controls how many recent bars are checked


my code conforms your syntax properly.

I tried with this also ...
AlertIf(Buy,"EMAIL","A sample alert on"+FullName(),1); // did not work


I tried with this also ...

AlertIf( Buy, "EMAIL", "A sample alert on" + Name(),0,15,1 ); //did not work

I tried with this also ...

AlertIf( Buy, "EMAIL", "A sample alert on" + Name(),1,15,1 ); //did not work

What is the correct code ? Do you know how to fix it ?
 
You should carefully read the manual. It's not difficult. And don't tell me it doesn't work because it does.
I told you that lookback = 1 looks for most recent 1 bar. If there is no buy on most recent bar (lookback = 1) then no email is sent. lookback = 1 is for realtime.

www.amibroker.com/guide/afl/afl_view.php?id=12

You should do the following

Buy = Cross( MACD(), Signal() );
Sell = Cross( Signal(), MACD() );
Short = Cover = 0;

AlertIf( Buy, "EMAIL", "A sample alert on " + FullName(), 1, 1, 100 );

first "1" means it will look for Buy signals
second "1" is flag "display text in the output window"
"100" is the number of lookback bars

And I have tested it in Scan window on EURUSD 5-minute time frame

And an email arrived at gmail right after scan

2012_10_19_223548.png

As a test set lookback to 100 and you will definitely get an email.
 

Attachments

  • 2012_10_19_223548.png
    2012_10_19_223548.png
    2.9 KB · Views: 2
I want to look for both BUY and SELL signals ...So should I put 0 here ?

No, Sell is "2"

Buy = Cross( MACD(), Signal() );
Sell = Cross( Signal(), MACD() );
Short = Sell;
Cover = Buy;
AlertIf( Sell, "EMAIL", FullName() + ", " + "Sell@: " + SellPrice, 2, 1, 100 );

just look in the manual and the description for AlertIf function. It's all explained there in detail.

output window ? I'm sending mail ...what is output window of email ?not understood this part.

It's an additional Flag! Again look at the AlertIf description in the manual or in the link of my previous reply.

Flag = 1 will do an additional output in the Alert Window of Amibroker

image.png

Got to "Window - Alert output" of the Amibroker menu bar to view the output
 

Attachments

  • image.png
    image.png
    4.1 KB · Views: 2
I have updated code to include SELL signal now...



AlertIf( Buy, "EMAIL", "Buy triggered for " + Name(),1, 1, 100 ); //for BUY
AlertIf( Sell, "EMAIL", "Sell triggered for " + Name(),2, 1, 100 ); //for SELL


I'm getting only SELL signals in email. Why BUY signals are not mailed ?

I get 2 BUY and 2 SELL when I do a SCAN ...but I'm getting SELL signal in email only.
 
Probably because only last occurring signal will be alerted. If you have bought in real-time you only want to know sell signal also and you are not interested in buy alert anymore that you got before sell signal.

Ask support of Amibroker for confirmation.
 
Probably because only last occurring signal will be alerted. If you have bought in real-time you only want to know sell signal also and you are not interested in buy alert anymore that you got before sell signal.

Ask support of Amibroker for confirmation.

yes. I have BUY - SELL -BUY -SELL ..... In this case my last occuring signal is SELL......and I'm really getting one SELL signal in mail.

Can you please tell how to add closing price in the email text. This will confirm the which SELL I'm receiving.




AlertIf( Buy, "EMAIL", "Buy triggered for " + Name()+" Closing Price "+close,1, 1, 100 ); //include close price
AlertIf( Sell, "EMAIL", "Sell triggered for " + Name()+" Closing Price "+close,2, 1, 100 ); //include close price

This does not work ...Can you please tell how to include closing price in the email text ?
 
yes. I have BUY - SELL -BUY -SELL ..... In this case my last occuring signal is SELL......and I'm really getting one SELL signal in mail.

Can you please tell how to add closing price in the email text. This will confirm the which SELL I'm receiving.




AlertIf( Buy, "EMAIL", "Buy triggered for " + Name()+" Closing Price "+close,1, 1, 100 ); //include close price
AlertIf( Sell, "EMAIL", "Sell triggered for " + Name()+" Closing Price "+close,2, 1, 100 ); //include close price

This does not work ...Can you please tell how to include closing price in the email text ?

I have tested it and adding this does work

AlertIf( Sell, "EMAIL", FullName() + ", " + "Sell@: " + Close, 2, 1, 100 );

Or uses SellPrice

AlertIf( Sell, "EMAIL", FullName() + ", " + "Sell@: " + SellPrice, 2, 1, 100 );
 
I have tested it and adding this does work

AlertIf( Sell, "EMAIL", FullName() + ", " + "Sell@: " + Close, 2, 1, 100 );

This email Close price will not match with close price in the chart crossover. Please compare your chart crossover close price and email close price .

are they matching ?
 
This email Close price will not match with close price in the chart crossover. Please compare your chart crossover close price and email close price .

are they matching ?


Then use this

AlertIf( Sell, "EMAIL", Name() + ", " + "Sell@: " + ValueWhen( Sell, Close ), 2, 1, 100 );

You should be more specific next time if you tell "does not work" otherwise I waste my time here in endless posts.
 
Then use this

AlertIf( Sell, "EMAIL", Name() + ", " + "Sell@: " + ValueWhen( Sell, Close ), 2, 1, 100 );

You should be more specific next time if you tell "does not work" otherwise I waste my time here in endless posts.

Amazing . This is running OK. Thanks for the help

Here is my full code:

Buy=Cross(MA(C, 20), MA(C,50));
Sell=Cross(MA(C, 50), MA(C,20));
Buy = ExRem(Buy,Sell);
Sell= ExRem(Sell,Buy);


AlertIf( Buy, "EMAIL", "Buy triggered for " + Name()+ ", " + "Buy@: " + ValueWhen( Buy, Close ),1, 1, 100 );
AlertIf( Sell, "EMAIL", "Sell triggered for " + Name()+ ", " + "Sell@: " + ValueWhen( Sell, Close ),2, 1, 100 );
 
I looked at your code . You had this ..

Short = Sell;
Cover = Buy;

you are not using this variables after assigning though.

I'm worried which is better..... Should I use Short/Cover or Buy/Sell ....which is the best practice ?
 
I looked at your code . You had this ..

Short = Sell;
Cover = Buy;

you are not using this variables after assigning though.

I'm worried which is better..... Should I use Short/Cover or Buy/Sell ....which is the best practice ?

What you wanna have as Short and Cover rules is up to you.

But to make alerts for those ones ... again just read what is written in the manual

Code:
AlertIf( Short, "EMAIL", "Short triggered for " + Name()+ ", " + "Short@: " + ValueWhen( Short, Close ), 3, 1, 100 ); 
AlertIf( Cover, "EMAIL", "Cover triggered for " + Name()+ ", " + "Cover@: " + ValueWhen( Cover, Close ), 4, 1, 100 );

Lookback = 100 is just for testing. For realtime alerts you can set it to 1.
 
What you wanna have as Short and Cover rules is up to you.

But to make alerts for those ones ... again just read what is written in the manual

Code:
AlertIf( Short, "EMAIL", "Short triggered for " + Name()+ ", " + "Short@: " + ValueWhen( Short, Close ), 3, 1, 100 ); 
AlertIf( Cover, "EMAIL", "Cover triggered for " + Name()+ ", " + "Cover@: " + ValueWhen( Cover, Close ), 4, 1, 100 );

Lookback = 100 is just for testing. For realtime alerts you can set it to 1.

Ok...I guess either I need to use BUY/SELL Or Short/Cover.

otherwise mixture of all these 4 trade methods would make scan report complicated.
 
Hello Trash,
Read your well informed posts on alert function.
I have one query.
I have written alertif function like

AlertIf( Buy, "SOUND C:\\Windows\\Media\\tada.wav", "Audio alert", 1, 1+2+4+8 );

I have to run auto explorer to get buy alerts.
What I want is whenever a new script generates buy signal
it should give non repeating alert without having to run auto explorer.

Thanks in advance..
 
Top