Quantcast How to debug in Amibroker? - Aussie Stock Forums

Results 1 to 17 of 17
  1. #1

    Default How to debug in Amibroker?

    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 ?

  2. #2

    Default Re: How to debug in Amibroker?

    Quote Originally Posted by amiuser View Post
    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

  3. #3

    Default Re: How to debug in Amibroker?

    Quote Originally Posted by trash View Post
    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 ?
    Last edited by amiuser; 22nd-October-2012 at 01:22 AM.

  4. #4

    Default Re: How to debug in Amibroker?

    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



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

  5. #5

    Default Re: How to debug in Amibroker?

    I received email when I set 100 ..Thanks ..this is running

  6. #6

    Default Re: How to debug in Amibroker?

    Quote Originally Posted by amiuser View Post
    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.

    Quote Originally Posted by amiuser View Post
    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



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

  7. #7

    Default Re: How to debug in Amibroker?

    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.

  8. #8

    Default Re: How to debug in Amibroker?

    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.

  9. #9

    Default Re: How to debug in Amibroker?

    Quote Originally Posted by trash View Post
    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 ?

  10. #10

    Default Re: How to debug in Amibroker?

    Quote Originally Posted by amiuser View Post
    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 );

  11. #11

    Default Re: How to debug in Amibroker?

    Quote Originally Posted by trash View Post
    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 ?

  12. #12

    Default Re: How to debug in Amibroker?

    Quote Originally Posted by amiuser View Post
    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.

  13. #13

    Default Re: How to debug in Amibroker?

    Quote Originally Posted by trash View Post
    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 );

  14. #14

    Default Re: How to debug in Amibroker?

    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 ?

  15. #15

    Default Re: How to debug in Amibroker?

    Quote Originally Posted by amiuser View Post
    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.

  16. #16

    Default Re: How to debug in Amibroker?

    Quote Originally Posted by trash View Post
    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.

  17. #17

    Default Re: How to debug in Amibroker?

    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..

Similar Threads

  1. AmiBroker
    By GreatPig in forum Software and Data
    Replies: 33
    Last Post: 13th-January-2011, 01:45 PM
  2. Amibroker help
    By jasoni in forum Software and Data
    Replies: 4
    Last Post: 1st-November-2010, 03:08 PM
  3. Amibroker
    By westerly in forum Software and Data
    Replies: 30
    Last Post: 21st-December-2009, 12:01 AM
  4. Amibroker - How to do this?
    By R0n1n in forum Software and Data
    Replies: 7
    Last Post: 11th-September-2009, 02:01 PM
  5. AmiBroker - 4.60 to 4.70
    By GreatPig in forum Software and Data
    Replies: 9
    Last Post: 31st-July-2005, 08:09 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Aussie Stock Forums