Rajandran R Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, USDINR and High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Strongly believe that market understanding and robust trading frameworks are the key to the trading success. Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in)

AllinOneAlerts 2.0 – Amibroker Alerts Module for Amibroker Users

5 min read

Lately, I been working on reducing the coding effort of Amibroker users and let them focusing primarily on building their own trading system.

AllinOneAlerts 2.0 is a plug-n-play module for Amibroker, a technical analysis, and trading software platform. The module provides alerts for users of Amibroker, with various types of alerts. These alerts can be used to notify users about buy, sell, short, and cover events to alert any potential trading opportunities.

AllinOneAlerts 2.0 is one of the most important and most requested modules to bring all sorts of alerts with no extra coding efforts. Now even a non-coder can use this module to build their own trading alerts.

Alerts Supported by AllinOneAlerts Module

1)Arrow Alerts
2)Sound Alerts
3)Popup Alerts
4)Voice Alerts
5)Email Alerts
6)Telegram Alerts
7)Slack Alerts

How to Access AllinOneAlerts Module?

Drag and Drop the AllinOne Alert Module on top of your trading strategy. Ensure that your strategy has Buy,Sell,Short,cover variables defined. If the Short and Cover variable is not defined then initialize the value of Short and Cover to zero before dragging and dropping the AllinOneAlert Module

Here is the sample Alerts module with simplified AFL Coding


//AllinOne Alert Module - Readmade Module (Drag and Drop on top of your trading strategy)

//Coded by Rajandran R - Founder - Marketcalls / Co-Founder - Algomojo
//Coded on 24th Dec 2022
//Website - www.marketcalls.in / www.algomojo.com
//Version - 2.0

//Alerts Supported by AllinOneAlerts Module

//1)Arrow Alerts
//2)Sound Alerts
//3)Popup Alerts
//4)Voice Alerts
//5)Email Alerts
//6)Telegram Alerts
//7)Slack Alerts


_SECTION_BEGIN("Marketcalls - All in One Alerts Module");


// Send Alerts even if Amibroker is minimized or Chart is not active
RequestTimedRefresh(1, False); 

//Initialization

ArrowAlerts = ParamToggle("Arrow Alerts","Enable|Disable",1);
LabelAlerts = ParamToggle("Label Alerts","Enable|Disable",0);
SoundAlerts = ParamToggle("Sound Alerts","Enable|Disable",0);
EmailAlerts = ParamToggle("Mail Alerts","Enable|Disable",0);
VoiceAlerts = ParamToggle("Voice Alerts","Enable|Disable",0);
PopUpAlerts = ParamToggle("PopUp Alerts","Enable|Disable",0);
TelegramAlerts = ParamToggle("Telegram Alerts","Enable|Disable",0);
TelegramAPI_ID = ParamStr("Telegram Bot API Key","1734928163:AAEiZ_64DJmk7jtosP1hkRywz1savZWUHAY");  //Get the Bot API key via BotFather in Telgram
TelgramCHAT_ID = ParamStr("Telegram Channel ID","@quantalerts2021");  //Channel ID example : @marketcalls_in
SlackAlerts = ParamToggle("Slack Alerts","Enable|Disable",0);
Slackwebhookurl = ParamStr("Slack Webhook URL","https://hooks.slack.com/services/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");

tradedelay = Param("Execution Delay",0,0,1); // 0 - Alerts with No Delay (Touch Based Strategies), 1- Alerts with 1 Bar Delay (EOD of Candle - Next Bar Open based Alerts)
AlertName = ParamStr("Alert Name","Strategy Alerts");
fontsize = Param("Font Size",10,10,40,1);


//User Defined Function -> Created using VBscript
EnableScript("VBScript"); 

<% 

Public Sub Telegram(Message_Text)


sAPI_ID = AFL.Var("TelegramAPI_ID")
sChat_ID = AFL.Var("TelgramCHAT_ID")
sMSG = Message_Text

'URL to open....
sUrl = "https://api.telegram.org/bot" & sAPI_ID & "/sendMessage"
'POST Request to send.
sRequest = "text=" & sMSG & "&chat_id=" & sChat_ID


set oHTTP = CreateObject("Microsoft.XMLHTTP")
oHTTP.open "POST", sUrl,false
oHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
oHTTP.setRequestHeader "Content-Length", Len(sRequest)
oHTTP.send sRequest
HTTPPost = oHTTP.responseText


'Store response 
'msgbox(objXmlHttpMain.responseText)
'response.Write (objXmlHttpMain.responseText) 

End Sub 


Public Sub Slack(message)

Set http = CreateObject("Microsoft.XMLHTTP")

sWebhook = AFL.Var("Slackwebhookurl")


Dim url
url = sWebhook

Dim params
params = "payload={'text': '"+message+"'}"

http.Open "POST", url, False
http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
http.Send params

End Sub


%> 

//create objects to access VBscript methods
tg = GetScriptObject(); 
sl = GetScriptObject();


function SignalArrowPlots(iBuy,iSell,iShort,iCover)
{
/* Plot Buy and Sell Signal Arrows */

PlotShapes(IIf(iBuy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(iBuy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);                      
PlotShapes(IIf(iBuy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45); 
PlotShapes(IIf(iShort, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(iShort, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);                      
PlotShapes(IIf(iShort, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
PlotShapes(iSell * shapestar, colorBrightGreen, 0, High, 12);
PlotShapes(iCover * shapestar, colorRed, 0, Low, -12);

}

function SignalTextLabels(iBuy,iSell,ishort,iCover)
{


for( i = 0; i < BarCount; i++ ) 
 {  
if( iBuy[i] ) PlotTextSetFont("Long Entry","Arial", fontsize,i,L[i],colorWhite,colorGreen,-30);
if( iSell[i] ) PlotTextSetFont("Long Exit","Arial", fontsize,i,H[i],colorWhite,colorGreen,30);
if( ishort[i] ) PlotTextSetFont("Short Entry","Arial", fontsize,i,H[i],colorWhite,colorRed,50);
if( iCover[i] ) PlotTextSetFont("Short Exit","Arial", fontsize,i,L[i],colorWhite,colorRed,-50);


}

}



//Buy and Sell Order Functions

function BuyAlerts(AlertBuy,AlertCover,Message)
{

if(SoundAlerts)
{
	if(AlertBuy AND !AlertCover)
	{
		AlertIf(AlertBuy,"SOUND C:\\Windows\\Media\\Ding.wav",Message,1,flag=1+2);
	}
	
	if(!AlertBuy AND AlertCover)
	{
		AlertIf(AlertCover,"SOUND C:\\Windows\\Media\\Ding.wav",Message,4,flag=1+2);
	}
	
	if(AlertBuy AND AlertCover)
	{
		AlertIf(AlertBuy AND AlertCover,"SOUND C:\\Windows\\Media\\Ding.wav",Message,5,flag=1+2);
		
	}

}

if(EmailAlerts)
{

	if(AlertBuy AND !AlertCover)
	{
		AlertIf(AlertBuy,"EMAIL",Message,1,flag=1+2);
	}
	
	if(!AlertBuy AND AlertCover)
	{
		AlertIf(AlertCover,"EMAIL",Message,4,flag=1+2);
	}
	
	if(AlertBuy AND AlertCover)
	{
		AlertIf(AlertBuy AND AlertCover,"EMAIL",Message,5,flag=1+2);
	}



}

if(VoiceAlerts)
{
	if(AlertBuy AND !AlertCover)
	{
		Say("Buy Signal");
	}
	
	if(!AlertBuy AND AlertCover)
	{
		Say("Cover Signal");
	}
	
	if(AlertBuy AND AlertCover)
	{
		Say("Buy and Cover Signal");
	}


}

if(PopUpAlerts)
{
	if(AlertBuy AND !AlertCover)
	{
		PopupWindow("Buy Signal",Message);
	}
	
	if(!AlertBuy AND AlertCover)
	{
		PopupWindow("Cover Signal",Message);
	}
	
	if(AlertBuy AND AlertCover)
	{
		PopupWindow("Buy and Cover Signal",Message);
	}


}

if(TelegramAlerts)
{	
	
	tg.Telegram(Message);


}

if(SlackAlerts)
{	
	
	sl.Slack(Message);


}



}



function SellAlerts(AlertShort,AlertSell,Message)
{
if(SoundAlerts)
{
	if(AlertShort AND !AlertSell)
	{
	AlertIf(AlertShort,"SOUND C:\\Windows\\Media\\Ding.wav",Message,3,flag=1+2);
	}
	
	if(!AlertShort AND AlertSell)
	{
	AlertIf(AlertSell,"SOUND C:\\Windows\\Media\\Ding.wav",Message,2,flag=1+2);
	}
	
	if(AlertShort AND AlertSell)
	{
	AlertIf(AlertShort AND AlertSell,"SOUND C:\\Windows\\Media\\Ding.wav",Message,6,flag=1+2);
	}

}
if(EmailAlerts)
{

	if(AlertShort AND !AlertSell)
	{
		AlertIf(AlertShort,"EMAIL",Message,3,flag=1+2);
	}
	
	if(!AlertShort AND AlertSell)
	{
		AlertIf(AlertSell,"EMAIL",Message,2,flag=1+2);
	}
	
	if(AlertShort AND AlertSell)
	{
		AlertIf(AlertShort AND AlertSell,"EMAIL",Message,6,flag=1+2);
	}

}

if(VoiceAlerts)
{
	if(AlertShort AND !AlertSell)
	{
		Say("Short Signal");
	}
	
	if(!AlertShort AND AlertSell)
	{
		Say("Sell Signal");
	}
	
	if(AlertShort AND AlertSell)
	{
		Say("Short and Sell Signal");
	}

}

if(PopUpAlerts)
{
	if(AlertShort AND !AlertSell)
	{
		PopupWindow("Short Signal",Message);
	}
	
	if(!AlertShort AND AlertSell)
	{
		PopupWindow("Sell Signal",Message);
	}
	
	if(AlertShort AND AlertSell)
	{
		PopupWindow("Short and Sell Signal",Message);
	}

}

if(TelegramAlerts)
{
	
	
	tg.Telegram(Message);
	
}

if(SlackAlerts)
{	
	
	sl.Slack(Message);


}

} //end of function

function AllinOneAlerts(iBuy,iSell,iShort,iCover)
{


//Configure Trade Execution Delay


AlertBuy = lastvalue(Ref(iBuy,-tradedelay));
AlertSell = lastvalue(Ref(iSell,-tradedelay));
AlertShort = lastvalue(Ref(iShort,-tradedelay));
AlertCover = lastvalue(Ref(iCover,-tradedelay));

//Static Varibales for Alert Protection

static_name_ = Name()+GetChartID()+interval(2)+AlertName;

BuyMessage = 	"Buy Signal in "+Name()+" Buy Price :"+BuyPrice;
CoverMessage =  "Cover Signal in "+Name()+" Cover Price :"+CoverPrice;
BuyCoverMessage = 	"Buy and Cover Signal in "+Name()+" Stop and Reverse Buy @ :"+BuyPrice;

ShortMessage =  "Short Signal in "+Name()+" Short Price :"+ShortPrice;
SellMessage = 	"Sell Signal in "+Name()+" Sell Price :"+SellPrice;
ShortSellMessage = 	"Short and Sell Signal in "+Name()+" Stop and Reverse Short @ :"+ShortPrice;

if(ArrowAlerts)
{
SignalArrowPlots(iBuy,iSell,iShort,iCover);
}
if(LabelAlerts)
{
SignalTextLabels(iBuy,iSell,ishort,iCover);
}



//Enable Dual Alert Protection using Static Variables
         
	if (AlertBuy==True AND AlertCover == True AND StaticVarGet(static_name_+"buyCoverAlerts")==0)
    {
		// Stop and Reverse Long Entry 
		BuyAlerts(AlertBuy,AlertCover,BuyCoverMessage);
		StaticVarSet(static_name_+"buyCoverAlerts",1); //Alerts Order was triggered, no more order on this bar
    }
    else if ((AlertBuy != True OR AlertCover != True))
    {   
    StaticVarSet(static_name_+"buyCoverAlerts",0);
    }
            
    if (AlertBuy==True AND AlertCover != True AND StaticVarGet(static_name_+"buyAlerts")==0)
    {
		// Long Entry 
		BuyAlerts(AlertBuy,AlertCover,BuyMessage);
		StaticVarSet(static_name_+"buyAlerts",1); //Alerts Order was triggered, no more order on this bar
    }
    else if (AlertBuy != True)
    {   
		StaticVarSet(static_name_+"buyAlerts",0);
                
    }
    
    if (AlertSell==true AND AlertShort != True AND StaticVarGet(static_name_+"sellAlerts")==0)
    {     
		// Long Exit 
		SellAlerts(AlertShort,AlertSell,SellMessage);
		StaticVarSet(static_name_+"sellAlerts",1); //Alerts Order was triggered, no more order on this bar
    }
    else if (AlertSell != True )
    {   
		StaticVarSet(static_name_+"sellAlerts",0);
    }
            
    if (AlertShort==True AND AlertSell==True AND  StaticVarGet(static_name_+"ShortSellAlerts")==0)
    {
		// Stop and Reverse Short Entry
		SellAlerts(AlertShort,AlertSell,ShortSellMessage);
		StaticVarSet(static_name_+"ShortSellAlerts",1); //Alerts Order was triggered, no more order on this bar
    }
    else if ((AlertShort != True OR AlertSell != True))
    {   
        StaticVarSet(static_name_+"ShortSellAlerts",0);
    }
                
    if (AlertShort==True  AND  AlertSell != True AND StaticVarGet(static_name_+"ShortAlerts")==0)
    {
		// Short Entry
		SellAlerts(AlertShort,AlertSell,ShortMessage);
		StaticVarSet(static_name_+"ShortAlerts",1); //Alerts Order was triggered, no more order on this bar
    }
    else if (AlertShort != True )
    {   
        StaticVarSet(static_name_+"ShortAlerts",0);
    }
    if (AlertCover==true AND AlertBuy != True AND StaticVarGet(static_name_+"CoverAlerts")==0)
    {
		// Short Exit
		BuyAlerts(AlertBuy,AlertCover,CoverMessage);
		StaticVarSet(static_name_+"CoverAlerts",1); //Alerts Order was triggered, no more order on this bar
    }
    else if (AlertCover != True )
    {   
        StaticVarSet(static_name_+"CoverAlerts",0);
    }
       

}        
        



AllinOneAlerts(Buy,Sell,Short,Cover);




_SECTION_END();
Rajandran R Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, USDINR and High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Strongly believe that market understanding and robust trading frameworks are the key to the trading success. Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in)

Reversal Finder – Tradingview to Amibroker AFL Code Conversion

Reversal Finder is designed to identify potential reversal signals in a stock's price action. It highlights specific bars that meet the criteria for a...
Rajandran R
2 min read

CM Williams VIX FIX Pinescript to Amibroker AFL Conversion

Thought of converting some of the top-rated pinescript codes to Amibroker AFL code. So started with CM Williams VIX FIX with 51,000+ ratings for...
Rajandran R
1 min read

5 Paisa Webhook – Amibroker Button Trading Module

In this tutorial, we will be using 5 Paisa Webhooks to Send Orders using the Amibroker Button Trading Module. This Button trading module provides...
Rajandran R
3 min read

Leave a Reply

Get Notifications, Alerts on Market Updates, Trading Tools, Automation & More