Hi,
thanks for your answer. You were right: when I'm changing timeframes the lines and corresponding text appears. However, when the template is freshly loaded the objects are created (I can see them in the object list) but not visible (even if I click on "Show" in the object list)...I'm a bit clueless here..
EDIT: As I'm new to MQL - is there something like a command line to output errors. Or at least a log or something?
Hi,
thanks for your answer. You were right: when I'm changing timeframes the lines and corresponding text appears. However, when the template is freshly loaded the objects are created (I can see them in the object list) but not visible (even if I click on "Show" in the object list)...I'm a bit clueless here..
EDIT: As I'm new to MQL - is there something like a command line to output errors. Or at least a log or something?
You have probably created the Template on a different pair, so the trendlines will be off screen on a different pair . . . for example GBPUSD vs USDJPY.
If you want to log stuff just use Print(); it outputs to the Journal tab if you are using the Strategy Tester and to the Experts tab if you are running in Demo or Live (and also in the corresponding log files in tester/logs and experts/logs).
Ah okay. Cheers. I thought whenever I load a template containing indicators it will run as a new instance ... So there is no way to avoid this? Is a template always bound to a specific pair?
What is making your issue a problem is partly because your Indicator is using Objects not Indicator buffers and Indicator lines, you can get round this in a number of ways :
- make sure the trendlines are not on the chart when you save the template
- delete the trendline Objects within init()
but really what you should do is use ObjectFind to determine if the trendline objects exist before you try to create them again . . . if they do exist then just use ObjectSet to change their position or other attributes, if they don't exist then go ahead and create them.
void TLine( string name, datetime T0, double P0, datetime T1, double P1, color clr, double V0=INF, double V1=INF, bool ray=false){ if (!Show.Objects) return; #define WINDOW_MAIN 0 if (ObjectMove( name, 0, T0, P0 )) ObjectMove(name, 1, T1, P1); else if (!ObjectCreate( name, OBJ_TREND, WINDOW_MAIN, T0, P0, T1, P1 )) Alert("ObjectCreate(",name,",TREND) failed: ", GetLastError() ); else if (!ObjectSet( name, OBJPROP_RAY, ray )) Alert("ObjectSet(", name, ",Ray) failed: ", GetLastError()); if (!ObjectSet(name, OBJPROP_COLOR, clr )) // Allow color change Alert("ObjectSet(", name, ",Color) [4] failed: ", GetLastError()); if (V0 == INF || V0 == P0){ string P0t = PriceToStr(P0); if (MathAbs(P0 - P1) >= Point) P0t = StringConcatenate(P0t, " to ", PriceToStr(P1)); } else if (V0 == V1) P0t = StringConcatenate(V0,""); // Suppress trailing to else P0t = StringConcatenate(V0, " to ", V1); if (!ObjectSetText(name, P0t, 10)) Alert("ObjectSetText(",name,") [2] failed: ", GetLastError()); } // V0, V1 is used only for price overlays
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hey Guys,
short question: I've written a custom indicator (see below) just drawing 3 trendlines. Everything works just fine. However, when adding the indicator to my template and apllying this template to a different currency pair the lines are not drawn. Then, when i open the indicator list clicking edit on my custom indicator and ok the lines are drawn -.- Any ideas? Thanks in advance :)
EDIT: It might have something to do with my check variable? Like it is still set to true when loading the template or something like this? No idea ...