Hello Everyone,
I was hoping you could help me add a simple alert to a code. I have tried many times, but it seems that I cannot get it right.
This particular channel indicator (from RickD BJF Trading Group) makes trendlines the way that I like trendlines to be made. I base most of my trades off of this. Usually the currency price is between the upper and lower trendlines. However, I would like to be emailed every time the price breaks out of a trendline (I would actually use my cell/text email address).
This would be simple to code, or I thought it would be simple to code, because all you would need to do is check the current price, the upper trendline price, and the lower trendline price. Usually the price is between both trendlines. If the price breaks above the upper trendline before it is recalculated, then the price would be above the trendlines. If the price breaks below the lower trendline before it's recalculated, then the price is going to be below the two trendlines.
I would just like a simple alert that says "current price for xxx/yyy just went above upper trendline" or "current price for xxx/yyy just went below the lower trendline"
It will do that for the first bar cross only; then send another alert saying that the price went back between both trendlines.
Can anyone please help and point me in the right direction. I can't seem to do this correctly. I asked in another forum, but the problem was never fully resolved.
Here is the original code. THANKS!
I was hoping you could help me add a simple alert to a code. I have tried many times, but it seems that I cannot get it right.
This particular channel indicator (from RickD BJF Trading Group) makes trendlines the way that I like trendlines to be made. I base most of my trades off of this. Usually the currency price is between the upper and lower trendlines. However, I would like to be emailed every time the price breaks out of a trendline (I would actually use my cell/text email address).
This would be simple to code, or I thought it would be simple to code, because all you would need to do is check the current price, the upper trendline price, and the lower trendline price. Usually the price is between both trendlines. If the price breaks above the upper trendline before it is recalculated, then the price would be above the trendlines. If the price breaks below the lower trendline before it's recalculated, then the price is going to be below the two trendlines.
I would just like a simple alert that says "current price for xxx/yyy just went above upper trendline" or "current price for xxx/yyy just went below the lower trendline"
It will do that for the first bar cross only; then send another alert saying that the price went back between both trendlines.
Can anyone please help and point me in the right direction. I can't seem to do this correctly. I asked in another forum, but the problem was never fully resolved.
Here is the original code. THANKS!
Inserted Code
extern int cnt = 50; extern color HHTL_color = DodgerBlue; extern color LLTL_color = DeepPink; string prefix = "xTop_"; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void init() { clear(); show(); } void deinit() { clear(); } void start() { show(); } void show() { string name = ""; double fr1, fr2; int bar1, bar2; int i = 2; for (int j=0; j < cnt; j++) { for (; i < Bars; i++) { fr1 = iFractals(NULL, 0, MODE_UPPER, i); if (fr1 > 0) { bar1 = i; break; } } for (i=i+2; i < Bars; i++) { fr2 = iFractals(NULL, 0, MODE_UPPER, i); if (fr2 > 0) { bar2 = i; break; } } name = prefix + "HHTL" + j; if (ObjectFind(name) == -1) { ObjectCreate(name, OBJ_TREND, 0, Time[bar2], fr2, Time[bar1], fr1); ObjectSet(name, OBJPROP_COLOR, HHTL_color); ObjectSet(name, OBJPROP_STYLE, STYLE_SOLID); ObjectSet(name, OBJPROP_WIDTH, 0); ObjectSet(name, OBJPROP_RAY, j==0); } else { ObjectMove(name, 0, Time[bar2], fr2); ObjectMove(name, 1, Time[bar1], fr1); } } i = 2; for (j=0; j < cnt; j++) { for (; i < Bars; i++) { fr1 = iFractals(NULL, 0, MODE_LOWER, i); if (fr1 > 0) { bar1 = i; break; } } for (i=i+2; i < Bars; i++) { fr2 = iFractals(NULL, 0, MODE_LOWER, i); if (fr2 > 0) { bar2 = i; break; } } name = prefix + "LLTL" + j; if (ObjectFind(name) == -1) { ObjectCreate(name, OBJ_TREND, 0, Time[bar2], fr2, Time[bar1], fr1); ObjectSet(name, OBJPROP_COLOR, LLTL_color); ObjectSet(name, OBJPROP_STYLE, STYLE_SOLID); ObjectSet(name, OBJPROP_WIDTH, 0); ObjectSet(name, OBJPROP_RAY, j==0); } else { ObjectMove(name, 0, Time[bar2], fr2); ObjectMove(name, 1, Time[bar1], fr1); } } } void clear() { string name = ""; int res = -1; for (int j=0; j < cnt; j++) { name = prefix + "HHTL" + j; if (ObjectFind(name) != -1) ObjectDelete(name); name = prefix + "LLTL" + j; if (ObjectFind(name) != -1) ObjectDelete(name); } }