Rajandran R Founder of Marketcalls and Co-Founder Algomojo. Full-Time Derivative Trader. Expert in Designing Trading Systems (Amibroker, Ninjatrader, Metatrader, Python, Pinescript). Trading the markets since 2006. Mentoring Traders on Trading System Designing, Market Profile, Orderflow and Trade Automation.

AllinOneAlerts – 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 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

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 12th Jan 2022
//Website - www.marketcalls.in / www.algomojo.com
//Version - 1.0


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

//For 6.17 or higher version users Telegram Modern Alert mehtod will be used
//For lower version users VBscript based Telegram Alert (Legacy Method is used)
AmiVersion = 6.17;  

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

%> 

tg = 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)
{	
	if(Version() >= AmiVersion)
	{
	//call the modern Internet Function
	ih = InternetOpenURL("https://api.telegram.org/bot"+TelegramAPI_ID+"/sendMessage?chat_id="+TelgramCHAT_ID+"&text="+Message ); 
	InternetClose(ih);
	}
	else
	{
	//call the legacy method
	tg.Telegram(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)
{
	if(Version()>=AmiVersion)
	{
	ih = InternetOpenURL("https://api.telegram.org/bot"+TelegramAPI_ID+"/sendMessage?chat_id="+TelgramCHAT_ID+"&text="+Message ); 
	InternetClose(ih);
	}
	else
	{
	//call the legacy method
	tg.Telegram(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 Founder of Marketcalls and Co-Founder Algomojo. Full-Time Derivative Trader. Expert in Designing Trading Systems (Amibroker, Ninjatrader, Metatrader, Python, Pinescript). Trading the markets since 2006. Mentoring Traders on Trading System Designing, Market Profile, Orderflow and Trade Automation.

AllinOneAlerts – Amibroker Alerts Module for Amibroker Users

AllinOneAlerts is one of the most important and most requested modules to bring all sorts of alerts with no extra coding efforts. Now even...
Rajandran R
5 min read

How to improve your Amibroker Algo Trading Execution Speed

When comes to Automated Trading speed of execution plays a dominant role in executing at better prices. Here I would like to list three...
Rajandran R
1 min read

Introduction to QuantZilla 2.0

QuantZilla is a 75+ hours of immersive coding mentor-ship program on designing trading systems, converting trading ideas into indicators and trading strategies, automating the...
Rajandran R
4 min read

Leave a Reply

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