Read the docs what import and include mean!!
Either attach the indi on the chart - that paints s.th. if it paints
and within your scrip just use iCustom(..) - no need to import or include it!!
I have read the docs and cannot find the answer that is why i have asked the forum!!"
You haven't understood my question!
I know how to attach a custom indicator MANUALLY - how do I do it automatically within a script or EA?
//+------------------------------------------------------------------+ //| Custom Moving Averages.mq4 | //| Copyright 2005-2014, MetaQuotes Software Corp. | //| https://www.mql4.com | //+------------------------------------------------------------------+ #property copyright "2005-2014, MetaQuotes Software Corp." #property link "https://www.mql4.com" #property description "Moving Average" #property strict #property indicator_chart_window #property indicator_buffers 1 #property indicator_color1 Red //--- indicator parameters input int InpMAPeriod=13; // Period input int InpMAShift=0; // Shift input ENUM_MA_METHOD InpMAMethod=MODE_SMA; // Method //--- indicator buffer double ExtLineBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit(void) { string short_name; int draw_begin=InpMAPeriod-1; //--- indicator short name switch(InpMAMethod) { case MODE_SMA : short_name="SMA("; break; case MODE_EMA : short_name="EMA("; draw_begin=0; break; case MODE_SMMA : short_name="SMMA("; break; case MODE_LWMA : short_name="LWMA("; break; default : return(INIT_FAILED); } IndicatorShortName(short_name+string(InpMAPeriod)+")"); IndicatorDigits(Digits); //--- check for input if(InpMAPeriod<2) return(INIT_FAILED); //--- drawing settings SetIndexStyle(0,DRAW_LINE); SetIndexShift(0,InpMAShift); SetIndexDrawBegin(0,draw_begin); //--- indicator buffers mapping SetIndexBuffer(0,ExtLineBuffer); //--- initialization done return(INIT_SUCCEEDED); }
so I can put all the this type of code in the script or EA again but it is already in my custom indicator I need to know how to 'call' it and draw it!
Just using iCustom(...........) gets me the data points but it doesn't draw the indicator.
That's right iCustom does not paint it only provides the values. You would have to create Objects to put the values on the chart.
To attach an indi by an EA or script use ChartApplyTemplate().
sd59: I also want to be able to draw the indicator on the chart using the EA and without having to load it manually all the time. can this be easily done using either Import or Include in the EA? What command is needed to draw the indicator on the chart? I have read the docs and cannot find the answer that is why i have asked the forum!!" |
|
|
1. I already know this & it has nothing to do with my question!
2. If this is true then thank you it has answered my question.
3. I can code and I don't want your code!! I want sensible answers in understandable English so that I can code it myself!! I do not know every single function in MQL!
4. If the docs were written by a normal human then I could understand - the examples shown are ridiculously complicated for the code being shown - show easy examples first!!
If you cannot answer in a sensible fashion please don't answer at all - you clearly have not fully understood my question and you obviously do not have an answer!
That's right iCustom does not paint it only provides the values. You would have to create Objects to put the values on the chart.
To attach an indi by an EA or script use ChartApplyTemplate().
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- 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 have a custom indicator which I will be using in an EA to establish trade levels etc;
I also want to be able to draw the indicator on the chart using the EA and without having to load it manually all the time. can this be easily done using either Import or Include in the EA?
So i'm testing it using a script first:
What command is needed to draw the indicator on the chart?
It defeats the object if i have to set index buffers etc; as all of this is already in the custom indicator.
any ideas please?