That is the way to do it.
--
Alternatively, set up a chart as you like it, the old way, and save a template of it, then apply the template to new charts.
Thanks phy for replying.
Actually I already use templates like you suggested but I figured I can learn some mql4 while making my charting more simple. Here is some code I have been working on. It only has the buffers. Am I doing this right?
Actually I already use templates like you suggested but I figured I can learn some mql4 while making my charting more simple. Here is some code I have been working on. It only has the buffers. Am I doing this right?
#property copyright "GNU" #property link "http://www.metaquotes.net" #property indicator_buffers 5 #property indicator_separate_window //buffers; double Sto0[], Sto1[], Sto2[], Sto3[], Sto4[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { SetIndexBuffer (0, Sto0); SetIndexStyle (0, DRAW_LINE); SetIndexBuffer (1, Sto1); SetIndexStyle (1, DRAW_LINE); SetIndexBuffer (2, Sto2): SetIndexStyle (2, DRAW_LINE); // and so on until Sto4? and if I want each to have different color I do it here? //---- indicators //---- return(0); }If this is ok- I guess the next step would be to using the iStochastic function so the buffers will know where to get the information from. Is this the right way of thinking?
Also, while trying to read code examples, I often run into i, j, n. What are these? I'm guessing i has something to do with bars amount.
I copied some code I found here. But still its not working- what I am doing wrong? If I can't get one stochastics done how am I supposed to do 5? :(
#property link "http://www.metatrader.info" #property indicator_chart_window #property indicator_buffers 1 #property indicator_color1 Red //---- inputs double ExtMapBuffer1[];//+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,ExtMapBuffer1); //---- return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); if (counted_bars<0) return(-1); if (counted_bars>0) counted_bars--; int pos=Bars-counted_bars; while(pos>=0) { ExtMapBuffer1[pos]= iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_SIGNAL,0); pos--; } //---- return(0); }
Find and study 2 changes
#property link "http://www.metatrader.info" #property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 Red //---- inputs double ExtMapBuffer1[];//+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,ExtMapBuffer1); //---- return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); if (counted_bars<0) return(-1); if (counted_bars>0) counted_bars--; int pos=Bars-counted_bars; while(pos>=0) { ExtMapBuffer1[pos]= iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_SIGNAL,pos); pos--; } //---- return(0); }
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
I am new to MQL4. I have been reading up on MQL4 for a while now and finally its coming, slowly. Anyway, before I start a wild goose chase, I will use this tread as a mentor- if that's cool with everyone. So I'm not asking anyone to make the indicator for me, just to guide me along the proper direction.
Custom indicator:
I am sick of dragging 5 stochastic indicators and manually set them to 5 different time frames (all on one chart.) So I want to build an indicator that will have 5 stochastics set so I have to drag one indicator once.
Question: Will I be going into the right direction if I use the iStochastic function 5 times with 5 different buffers that draw each buffer? I read that you can have up to 8 buffers and by using iStochastic, I will save alot of time writing code.
I want to thank everyone in advance for helping or mentoring me. I hope for any noobs like me, this tread will serve to help you to learn MQL4.