no file.
Do they all reference the same corner?
That explains why no response. I have an idea. I will put into src in multple responses here.
No, there are 3 or 4 that reference 0, 3 that reference 1 and 1 that references 2.
// Declaration section: //+------------------------------------------------------------------+ //| test_positions.mq4 | //| Copyright © 2010, Investors Haven | //| http://www.InvestorsHaven.com | //+------------------------------------------------------------------+ #property copyright "Copyright © 2010, Investors Haven" #property link "http://www.InvestorsHaven.com" extern bool Both = false; extern string __NOTIFICATIONS = "----"; extern bool EnableMarginNotification = true; // Notifications for turning on/off label generation extern bool EnableClosedNotification = true; extern bool EnableLeverageNotification = true; extern bool EnableTimeNotification = true; extern bool EnableSpreadMaxNotification = true; extern bool EnableStatusNotification = true; extern bool EnableTimeStatusNotification = true; extern bool EnableMaxDDProtNotification = true; extern bool EnableBalEqtyPcntNotification = true; extern bool EnableMAXSpreadNotification = true; extern bool EnableMAXAvgDDNotification = true; // string strSpreadMax = "strSpreadMax"; // Strings just for test data. string strLeverage = "strLeverage"; string strMarginMin = "strMarginMin"; string strClosed = "strClosed"; string strStatus = "strStatus"; string strTimeStatus = "strTimeStatus"; string strMAXDDProt = "strMAXDDProt"; string strBalEqtyPcnt = "strBalEqtyPcnt"; string strMAXSpread = "strMAXSpread"; string strMAXAvgDD = "strMAXAvgDD"; // color clrSpreadMax = SkyBlue; // Setting colors color clrLeverage = SkyBlue; color clrMarginMin = Red; color clrClosed = SkyBlue; color clrStatus = Red; // variable color clrTimeStatus = Red; // variable color clrMAXDDProt = SkyBlue; color clrBalEqtyPcnt = SkyBlue; color clrMAXSpread = SkyBlue; color clrMAXAvgDD = SkyBlue; // extern int XSpreadMax = 0; // All X location values. extern int XLeverage = 0; extern int XMarginMin = 200; extern int XClosed = 0; extern int XStatus = 0; extern int XTimeStatus = 0; extern int XMAXDDProt = 0; extern int XBalEqtyPcnt = 200; extern int XMAXSpread = 700; extern int XMAXAvgDD = 10; // extern int YSpreadMax = 120; // All y location values. extern int YLeverage = 60; extern int YMarginMin = 20; extern int YClosed = 80; extern int YStatus = 20; extern int YTimeStatus = 10; extern int YMAXDDProt = 100; extern int YBalEqtyPcnt = 10; extern int YMAXSpread = 10; extern int YMAXAvgDD = 10;
That explains why no response. I have an idea. I will put into src in multple responses here.
No, there are 3 or 4 that reference 0, 3 that reference 1 and 1 that references 2.
// Init and deinit section: //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- // Create the objects for the labels // if they are enabled. if (EnableMarginNotification) { if(!ObjectCreate("Obj_MarginMinText", OBJ_LABEL, 0, 0, 0)) { Print("error: can't create text_object! code #",GetLastError()); return(0); } } if (EnableClosedNotification) { if(!ObjectCreate("Obj_ClosedText", OBJ_LABEL, 0, 0, 0)) { Print("error: can't create text_object! code #",GetLastError()); return(0); } } if (EnableLeverageNotification) { if(!ObjectCreate("Obj_LeverageText", OBJ_LABEL, 0, 0, 0)) { Print("error: can't create text_object! code #",GetLastError()); return(0); } } if (EnableSpreadMaxNotification) { if(!ObjectCreate("Obj_SpreadMaxText", OBJ_LABEL, 0, 0, 0)) { Print("error: can't create text_object! code #",GetLastError()); return(0); } } if (EnableStatusNotification) { if(!ObjectCreate("Obj_StatusText", OBJ_LABEL, 0, 0, 0)) { Print("error: can't create text_object! code #",GetLastError()); return(0); } } if (EnableTimeStatusNotification) { if(!ObjectCreate("Obj_TimeStatusText", OBJ_LABEL, 0, 0, 0)) { Print("error: can't create text_object! code #",GetLastError()); return(0); } } if (EnableMaxDDProtNotification) { if(!ObjectCreate("Obj_MaxDDProtText", OBJ_LABEL, 0, 0, 0)) { Print("error: can't create text_object! code #",GetLastError()); return(0); } } if (EnableBalEqtyPcntNotification) { if(!ObjectCreate("Obj_BalEqtyPcntText", OBJ_LABEL, 0, 0, 0)) { Print("error: can't create text_object! code #",GetLastError()); return(0); } } if (EnableMAXSpreadNotification) { if(!ObjectCreate("Obj_MAXSpreadText", OBJ_LABEL, 0, 0, 0)) { Print("error: can't create text_object! code #",GetLastError()); return(0); } } if (EnableMAXAvgDDNotification) { if(!ObjectCreate("Obj_MAXAvgDDText", OBJ_LABEL, 0, 0, 0)) { Print("error: can't create text_object! code #",GetLastError()); return(0); } } //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- // Remove the following rem tags to clean up objects. //DeleteAllObjects(); //---- return(0); }
// Start Section: //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- if (Both == true) { // testing both the cleanup and the display ShowAllObjects(); Sleep(10000); ClearAllObjects(); } else { // Just testing the display, default. ShowAllObjects(); } //---- return(0); } //+------------------------------------------------------------------+
// DeleteteAllObjects Function and clear function used to hide data when not in use: void DeleteAllObjects() { // Delete all objects created by the indicator for (int i = ObjectsTotal() - 1; i >= 0; i--) { string name = ObjectName(i); ObjectDelete(name); } } //+------------------------------------------------------------------+ //| ClearAllObjects | //+------------------------------------------------------------------+ void ClearAllObjects() { // Clearing the labels by setting text to "" // and changing color to background. if (EnableMarginNotification) { strMarginMin = " "; ObjectSet("Obj_MarginMinText", OBJPROP_CORNER, 0); ObjectSet("Obj_MarginMinText", OBJPROP_XDISTANCE, XMarginMin); ObjectSet("Obj_MarginMinText", OBJPROP_YDISTANCE, YMarginMin); ObjectSetText("Obj_MarginMinText", strMarginMin, 12, "Arial", Black); } if (EnableClosedNotification) { strClosed = " "; ObjectSet("Obj_ClosedText", OBJPROP_CORNER, 0); ObjectSet("Obj_ClosedText", OBJPROP_XDISTANCE, XClosed); ObjectSet("Obj_ClosedText", OBJPROP_YDISTANCE, YClosed); ObjectSetText("Obj_ClosedText", strClosed, 12, "Arial", Black); } if (EnableSpreadMaxNotification) { strSpreadMax = " "; // reset text ObjectSet("Obj_SpreadMaxText", OBJPROP_CORNER, 0); ObjectSet("Obj_SpreadMaxText", OBJPROP_XDISTANCE, XSpreadMax); ObjectSet("Obj_SpreadMaxText", OBJPROP_YDISTANCE, YSpreadMax); ObjectSetText("Obj_SpreadMaxText", strSpreadMax, 12, "Arial", Black); } if (EnableStatusNotification) { strStatus = " "; ObjectSet("Obj_StatusText", OBJPROP_CORNER, 0); ObjectSet("Obj_StatusText", OBJPROP_XDISTANCE, XStatus); ObjectSet("Obj_StatusText", OBJPROP_YDISTANCE, YStatus); ObjectSetText("Obj_StatusText", strStatus, 12, "Arial", Black); } if (EnableTimeStatusNotification) { strTimeStatus = " "; ObjectSet("Obj_TimeStatusText", OBJPROP_CORNER, 2); ObjectSet("Obj_TimeStatusText", OBJPROP_XDISTANCE, XTimeStatus); ObjectSet("Obj_TimeStatusText", OBJPROP_YDISTANCE, YTimeStatus); ObjectSetText("Obj_TimeStatusText", strTimeStatus, 12, "Arial", Black); } if (EnableMaxDDProtNotification) { strMAXDDProt = " "; ObjectSet("Obj_MaxDDProtText", OBJPROP_CORNER, 2); ObjectSet("Obj_MaxDDProtText", OBJPROP_XDISTANCE, XMAXDDProt); ObjectSet("Obj_MaxDDProtText", OBJPROP_YDISTANCE, YMAXDDProt); ObjectSetText("Obj_MaxDDProtText", strMAXDDProt, 12, "Arial", Black); } if (EnableLeverageNotification) { strLeverage = " "; ObjectSet("Obj_LeverageText", OBJPROP_CORNER, 0); ObjectSet("Obj_LeverageText", OBJPROP_XDISTANCE, XLeverage); ObjectSet("Obj_LeverageText", OBJPROP_YDISTANCE, YLeverage); ObjectSetText("Obj_LeverageText", strLeverage, 12, "Arial", Black); } if (EnableBalEqtyPcntNotification) { strBalEqtyPcnt = "Balance/Equity Percentage: "; ObjectSet("Obj_BalEqtyPcntText", OBJPROP_CORNER, 2); ObjectSet("Obj_BalEqtyPcntText", OBJPROP_XDISTANCE, XBalEqtyPcnt); ObjectSet("Obj_BalEqtyPcntText", OBJPROP_YDISTANCE, YBalEqtyPcnt); ObjectSetText("Obj_BalEqtyPcntText", strBalEqtyPcnt, 12, "Arial", Black); } if (EnableMAXSpreadNotification) { strMAXSpread = "MAX Spread: "; ObjectSet("Obj_MAXSpreadText", OBJPROP_CORNER, 2); ObjectSet("Obj_MAXSpreadText", OBJPROP_XDISTANCE, XMAXSpread); ObjectSet("Obj_MAXSpreadText", OBJPROP_YDISTANCE, YMAXSpread); ObjectSetText("Obj_MAXSpreadText", strMAXSpread, 12, "Arial", Black); } }
// ShowAll, the main function that displays the labels: void ShowAllObjects() { // Because we are using test data, string lines here are commented out. // This has no effect on the diaplay. // strSpreadMax = "SpreadMax has been exceeded, no trading."; ObjectSet("Obj_SpreadMaxText", OBJPROP_CORNER, 0); ObjectSet("Obj_SpreadMaxText", OBJPROP_XDISTANCE, XSpreadMax); ObjectSet("Obj_SpreadMaxText", OBJPROP_YDISTANCE, YSpreadMax); ObjectSetText("Obj_SpreadMaxText", strSpreadMax, 12, "Arial", clrSpreadMax); // strLeverage = "Account leverage is too high for this EA, your margin wil be at risk. We will not allow trading at this leverage level, our max is 100:1"; ObjectSet("Obj_LeverageText", OBJPROP_CORNER, 0); ObjectSet("Obj_LeverageText", OBJPROP_XDISTANCE, XLeverage); ObjectSet("Obj_LeverageText", OBJPROP_YDISTANCE, YLeverage); ObjectSetText("Obj_LeverageText", strLeverage, 12, "Arial", clrLeverage); // strMarginMin = "Low margin level, no new trades"; ObjectSet("Obj_MarginMinText", OBJPROP_CORNER, 0); ObjectSet("Obj_MarginMinText", OBJPROP_XDISTANCE, XMarginMin); ObjectSet("Obj_MarginMinText", OBJPROP_YDISTANCE, YMarginMin); ObjectSetText("Obj_MarginMinText", strMarginMin, 12, "Arial", clrMarginMin); // string strClosed = "Closing all trades for the week."; ObjectSet("Obj_ClosedText", OBJPROP_CORNER, 0); ObjectSet("Obj_ClosedText", OBJPROP_XDISTANCE, XClosed); ObjectSet("Obj_ClosedText", OBJPROP_YDISTANCE, YClosed); ObjectSetText("Obj_ClosedText", strClosed, 12, "Arial", clrClosed); // strStatus = "Initializing EA..."; ObjectSet("Obj_StatusText", OBJPROP_CORNER, 0); ObjectSet("Obj_StatusText", OBJPROP_XDISTANCE, XStatus); ObjectSet("Obj_StatusText", OBJPROP_YDISTANCE, YStatus); ObjectSetText("Obj_StatusText", strStatus, 12, "Arial", clrStatus); // Here is where the problem is, or should be. // strTimeStatus = "Time Status: Waiting"; ObjectSet("Obj_TimeStatusText", OBJPROP_CORNER, 2); ObjectSet("Obj_TimeStatusTextt", OBJPROP_XDISTANCE, XTimeStatus); ObjectSet("Obj_TimeStatusText", OBJPROP_YDISTANCE, YTimeStatus); ObjectSetText("Obj_TimeStatusText", strTimeStatus, 12, "Arial", clrTimeStatus); // strMAXDDProt = StringConcatenate("MaxDrawdown is set to: $", 23, "."); //-1 * MaxDrawdownInCash ObjectSet("Obj_MaxDDProtText", OBJPROP_CORNER, 0); ObjectSet("Obj_MaxDDProtText", OBJPROP_XDISTANCE, XMAXDDProt); ObjectSet("Obj_MaxDDProtText", OBJPROP_YDISTANCE, YMAXDDProt); ObjectSetText("Obj_MaxDDProtText", strMAXDDProt, 12, "Arial", clrMAXDDProt); // strBalEqtyPcnt = tmpStr; ObjectSet("Obj_BalEqtyPcntText", OBJPROP_CORNER, 2); ObjectSet("Obj_BalEqtyPcntText", OBJPROP_XDISTANCE,XBalEqtyPcnt); ObjectSet("Obj_BalEqtyPcntText", OBJPROP_YDISTANCE, YBalEqtyPcnt); ObjectSetText("Obj_BalEqtyPcntText", strBalEqtyPcnt, 12, "Arial", clrBalEqtyPcnt); // strMAXSpread = StringConcatenate("Spread: ", // DoubleToStr(MarketInfo(Symbol(),MODE_SPREAD), 2), // ", MAX Spread: ", // DoubleToStr(MAXSpread, 2), // ", TradeSpread: ", // DoubleToStr(TradeSpread, 2)); ObjectSet("Obj_MAXSpreadText", OBJPROP_CORNER, 2); ObjectSet("Obj_MAXSpreadText", OBJPROP_XDISTANCE, XMAXSpread); ObjectSet("Obj_MAXSpreadText", OBJPROP_YDISTANCE, YMAXSpread); ObjectSetText("Obj_MAXSpreadText", strMAXSpread, 12, "Arial", clrMAXSpread); // strMAXAvgDD = StringConcatenate("MAX Avg DD: In Pips: ", DoubleToStr(MAXAvgPips, Digits), " In Cash: ", DoubleToStr(MAXAvgCash, 2)); ObjectSet("Obj_MAXAvgDDText", OBJPROP_CORNER, 3); ObjectSet("Obj_MAXAvgDDText", OBJPROP_XDISTANCE, XMAXAvgDD); ObjectSet("Obj_MAXAvgDDText", OBJPROP_YDISTANCE, YMAXAvgDD); ObjectSetText("Obj_MAXAvgDDText", strMAXAvgDD, 12, "Arial", clrMAXAvgDD); }
I don't understand what happened between this last weekend and now, I haven't changed any of the code, but now it not only shows the labels correctly on the demo charts, live charts, but also on the tester charts. Strange to say the least. Thanks for looking into this for me, but at the moment it seems to be working just fine.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I was in the process of updating an EA that had several labels. Just adding another one and moving them to new locations on the chart. All of them were relocated fine, but one of them that resided in the bottom-left corner. Ironically, the location settings didn't change from when it was working to now where it is not working. It is freaky because the old original EA still works and everything is in it's place. The new version kicks the label to the right about 200 points. If you edit the label on the chart, it will show a 200 point value. This drove me nuts for hours, so I stripped the code out of the EA and put it into another EA that just does the display manipulation. I further took all the converted all the x,y's into variables so I could edit them from the config instead of having to re compile each time. In this new test EA, I was able to place them all, but the bottom-left corner. Now I have not been able to run it in real time or forward testing. But in back testing this issue sticks out like a sore thumb.
Question is: Is this a bug in the tester, bug in my code or just a freak of nature? The file is too large to drop in here, so I am attaching it.
The label causing the problem is Obj_TimeStatusText
Note: The DeleteAllObjects has been rem'd out so the objects can remain on chart for analysis.
Ideal position 2, 0, 10.