Stock Portfolio Organizer
The ultimate porfolio management solution.
WiseTrader Toolbox
#1 Selling Amibroker Plugin featuring:
Chandelier Exit Functions for Amibroker (AFL)
These are two functions that can be used to calculate the chandelier exit. This AFL is only the functions and does not plot anything.
By Geoff Mulhall
Similar Indicators / Formulas
Indicator / Formula
function ChandelierCl(AtrARRAY, AtrMult) { // Skip empty values i = 0; do { result[i] = Null; i++; } while( i < BarCount AND (IsNull(O[i]) OR IsNull(H[i]) OR IsNull(L[i]) OR IsNull(C[i]) ) ); First = i; if (i < BarCount - 1) { HHC[First] = C[First]; LLC[First] = C[First]; if (C[First + 1] > HHC[First]) { HHC[First + 1] = C[First + 1]; LLC[First + 1] = LLC[First]; result[First] = C[First] - AtrMult * AtrARRAY[First]; iTrade = "LT"; } else { if (C[First + 1] < LLC[First]) { HHC[First = 1] = HHC[First]; LLC[First + 1] = LLC[First + 1]; result[First] = C[First] + AtrMult * AtrARRAY[First]; iTrade = "ST"; } else { HHC[First + 1] = C[First + 1]; LLC[First + 1] = C[First + 1]; result[First] = C[First] - AtrMult * AtrARRAY[First]; iTrade = "LT"; } } for( i = First; i < BarCount; i++ ) { if (iTrade == "LT") { if (C[i] >= result[i-1]) { // Long Trade is continuing if (C[i] > C[i-1]) { HHC[i] = C[i]; } else { HHC[i] = HHC[i-1]; } result[i] = HHC[i] - AtrMult * AtrARRAY[i]; if (result[i] < result[i-1]) { result[i] = result[i-1]; } } else { // Long trade Exit triggered iTrade = "ST"; LLC[i] = C[i]; result[i] = C[i] + AtrMult * AtrARRAY[i]; } } else { // Short trade if (C[i] <= result[i-1]) { if (C[i] <= C[i-1]) { // Short Trade is continuing LLC[i] = C[i]; } else { LLC[i] = LLC[i-1]; } result[i] = LLC[i] + AtrMult * AtrARRAY[i]; if (result[i] > result[i-1]) { result[i] = result[i-1]; } } else { //Short Trade Exit is triggered iTrade = "LT"; HHC[i] = C[i]; result[i] = C[i] - AtrMult * AtrARRAY[i]; } } } } return result; } function ChandelierHL(AtrARRAY, AtrMult) { // Skip empty values i = 0; do { result[i] = Null; i++; } while( i < BarCount AND (IsNull(O[i]) OR IsNull(H[i]) OR IsNull(L[i]) OR IsNull(C[i]) ) ); First = i; if (i < BarCount - 1) { HHC[First] = H[First]; LLC[First] = L[First]; if (H[First + 1] > HHC[First]) { HHC[First + 1] = H[First + 1]; LLC[First + 1] = LLC[First]; result[First] = H[First] - AtrMult * AtrARRAY[First]; iTrade = "LT"; } else { if (L[First + 1] < LLC[First]) { HHC[First = 1] = HHC[First]; LLC[First + 1] = LLC[First + 1]; result[First] = L[First] + AtrMult * AtrARRAY[First]; iTrade = "ST"; } else { HHC[First + 1] = C[First + 1]; LLC[First + 1] = C[First + 1]; result[First] = H[First] - AtrMult * AtrARRAY[First]; iTrade = "LT"; } } for( i = First; i < BarCount; i++ ) { if (iTrade == "LT") { if (C[i] >= result[i-1]) { // Long Trade is continuing if (H[i] > H[i-1]) { HHC[i] = H[i]; } else { HHC[i] = HHC[i-1]; } result[i] = HHC[i] - AtrMult * AtrARRAY[i]; if (result[i] < result[i-1]) { result[i] = result[i-1]; } } else { // Long trade Exit triggered iTrade = "ST"; LLC[i] = L[i]; result[i] = L[i] + AtrMult * AtrARRAY[i]; } } else { // Short trade if (C[i] <= result[i-1]) { if (L[i] <= L[i-1]) { // Short Trade is continuing LLC[i] = L[i]; } else { LLC[i] = LLC[i-1]; } result[i] = LLC[i] + AtrMult * AtrARRAY[i]; if (result[i] > result[i-1]) { result[i] = result[i-1]; } } else { //Short Trade Exit is triggered iTrade = "LT"; HHC[i] = H[i]; result[i] = H[i] - AtrMult * AtrARRAY[i]; } } } } return result; }
0 comments
Leave Comment
Please login here to leave a comment.
Back