DislikedI agree with kennyhubbard in regard to using iCustom().
Here is a function to calculate the TrendMagic value in an EA (or script or whatever). I think Supertrend is very similar to TrendMagic. Hopefully, this will at least point you in the right direction. I did limited testing of this, but I think everything is in order.
BTW, this function can be used as a "shell" for all other indicators you want to turn into functions. Some indicators are easier to "functionize" than others. Anyway, hope this helps.
[code]
double getTrendMagic(...Ignored
Here is what I have thus far for identifying the break.
Inserted Code
//+------------------------------------------------------------------+ //| SuperTrend V1.mq4 | //| Copyright © 2010, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ double ExtMapBuffer1[]; double ExtMapBuffer2[]; int Periods = 3; double Multiplier = 1.25; int TimeFrame = 240; string TrendDirection = "No Direction YET!"; double UpTrend,DownTrend; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- RefreshRates(); UpTrend = iCustom(NULL, 0, "SuperTrend",Periods,Multiplier,TimeFrame,0,1); DownTrend = iCustom(NULL, 0, "SuperTrend",Periods,Multiplier,TimeFrame,1,1); if(UpTrend > 5000) { UpTrend = 0; TrendDirection = "Down"; } if(DownTrend > 5000) { DownTrend = 0; TrendDirection = "Up"; } if(UpTrend > 0 && Close[0] >= UpTrend && Close[1] < UpTrend) Alert("Price is higher than SuperTrend"); if(DownTrend > 0 && Close[0] <= DownTrend && Close[1] > DownTrend) Alert("Price is lower than SuperTrend"); Comment("UpTrend: ", UpTrend, "n", "DownTrend: ", DownTrend, "n", "Trade Direction: ", TrendDirection); //---- return(0); }
We are our own best indicator.