I found what's wrong:
Usually, I create or edit a code by: "Metaeditor---file---new/open..."
But I just find out: after attach to chart, and then some changes in this code, finally more changes do not affect the chart anymore (surely I compiled !)----- but "Metaeditor--navigator--files---my code..." do ! That's weird, they should be the same code!
Usually, I create or edit a code by: "Metaeditor---file---new/open..."
But I just find out: after attach to chart, and then some changes in this code, finally more changes do not affect the chart anymore (surely I compiled !)----- but "Metaeditor--navigator--files---my code..." do ! That's weird, they should be the same code!
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
In fact , this code already works great. But I'm just tired of the simple Alert popup, with NO Symbol shown. So I changed/added some lines to try , which is the %%%%%%%%% part.
I don't know why, print, comment... whatever, nothing happens.
And, weirdly, you can see in the "----alert----" part, I changed UPBREAK alert into something else, but it still shows "UP BREAK". ---- I'm sure everytime I rewrite the code, I compile it, delete it from chart and load it again.
Any idea?
#property indicator_chart_window #import "usr32.dll" // %%%%%%%%%% int MessageBoxA(int hWnd,string lpText,string lpCaption,int uType); //%%%%%%%%%% #import //%%%%%%%%%% int PrevAlertTime = 0; int init() { return(0); } int deinit() { return(0); } //+------------------------------------------------------------------+ int start() { int i=ObjectsTotal(); int redtotal=0,j,typ1; double price1,price2,up,down; color col; string name1,name2,nameup,namedown,warn1,sym=Symbol(); warn1=sym + "Break Up"; //%%%%%%%%%% Print(sym); //%%%%%%%%%%% //----make sure exactly 2 red lines on chart--------------------- for (j=0; j<i; j++) if(ObjectGet(ObjectName(j),OBJPROP_COLOR)==255 && ObjectType(ObjectName(j))==OBJ_TREND) { redtotal++; if (redtotal==1) name1=ObjectName(j); if (redtotal==2) name2=ObjectName(j); } if (redtotal==2) { if(ObjectFind("remind")==0) ObjectDelete("remind"); } else { ObjectCreate("remind",OBJ_LABEL,0,0,0); ObjectSet("remind", OBJPROP_XDISTANCE,0); ObjectSet("remind", OBJPROP_YDISTANCE,20); ObjectSetText("remind", "Keep exactly 2 red lines on chart" ,16,"Times New Roman",Blue); return(0); // question here: what should I use, 0 or -1 ? } //--------decide which line is up / down --------------------- price1=NormalizeDouble(ObjectGetValueByShift(name1,1), MarketInfo(Symbol(),MODE_DIGITS)); price2=NormalizeDouble(ObjectGetValueByShift(name2,1), MarketInfo(Symbol(),MODE_DIGITS)); if (price2>=price1) { nameup=name2; namedown=name1; up=price2; down=price1; } else { nameup=name1; namedown=name2; up=price1; down=price2; } //-------- alert ---------------------------------------------- if (TimeCurrent() - PrevAlertTime > Period()*60/3) { if (Close[1]<=up && Close[0]>up) { MessageBoxA(NULL,"tupole","11111",0); // %%%%%%%%%% Print(Symbol()); // %%%%%%%%%% PrevAlertTime = TimeCurrent(); } if (Close[1]>=down && Close[0]<down) { Alert("DOWN BREAK",Symbol()); PrevAlertTime = TimeCurrent(); } } return(0); }