well is it possible??
In generally words - it's possible. Look example on Russian article 18. Тиковый индикатор в отдельном окне
Rosh,
You look like a scientist :) I guess you are one... computer scientist.
I think I understood a little bit of that code you were trying to explain. Can you post it here and provide some English annotations? we will try to decipher the best we can.
thanks.
You look like a scientist :) I guess you are one... computer scientist.
I think I understood a little bit of that code you were trying to explain. Can you post it here and provide some English annotations? we will try to decipher the best we can.
thanks.
no rosh, i dont have a clue as to what their trying to do there, but basically just
like each bar in a minute chart is created at the end of a minute, in a tick chart,
1 bar will be created when the number of ticks you have specified is reached, nothing
is done to the price....
Yes, each bar in a every time frame chart is created at the end of a specifyed peiod.
But there is way to solve this task? for example:
//+------------------------------------------------------------------+ //| Ticks.mq4 | //| MetaQuotes | //| http://www.alpari-idc.ru/ru/experts/articles/ | //+------------------------------------------------------------------+ #property copyright "Rosh" #property link "http://www.alpari-idc.ru/ru/experts/articles/" #property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 Navy //---- buffers extern int MaxDrawTicks=500; double ExtMapBuffer1[]; int myBars; int tickCounter; int delimeterCounter; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0, ExtMapBuffer1); SetIndexEmptyValue(0,0.0); Print("Обнуляем тики"); for (int i=Bars-1;i>=0;i--) ExtMapBuffer1[i]=0.0; //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| сдвинем массив | //+------------------------------------------------------------------+ void SetDelimeter() { //---- string delimeterDate=TimeToStr(Time[0]); if (myBars!=0) { Print("Ставим разделитель"); int handle=WindowFind("Ticks"); if(!ObjectCreate(delimeterDate,OBJ_VLINE,handle,Time[0],0)) { Alert("Недачная попытка создания разделителя в окне ", handle," по времени ",TimeToStr(CurTime())); Print("Ошибка №",GetLastError(),", имя разделителя ",delimeterDate); } else { ObjectSet(delimeterDate,OBJPROP_COLOR,DarkGreen); ObjectSet(delimeterDate,OBJPROP_STYLE,STYLE_DASHDOT); ObjectsRedraw(); } } //---- return(0); } //+------------------------------------------------------------------+ //| сдвинем массив | //+------------------------------------------------------------------+ void ShiftArray() { //---- int V_lines; string delimeterName; datetime firstTime; int BarFirstTime; if (tickCounter>2*MaxDrawTicks) { for (int i=tickCounter;i>=MaxDrawTicks;i--) ExtMapBuffer1[i]=0.0; tickCounter=MaxDrawTicks; } for(int cnt=tickCounter;cnt>0;cnt--) { ExtMapBuffer1[cnt]=ExtMapBuffer1[cnt-1]; } V_lines=ObjectsTotal(); for (int z=0;z<V_lines;z++) { delimeterName=ObjectName(z); if (ObjectFind(delimeterName)!=-1) { if (ObjectType(delimeterName)==OBJ_VLINE) { firstTime=ObjectGet(delimeterName,OBJPROP_TIME1); BarFirstTime=iBarShift(NULL,0,firstTime); firstTime=Time[BarFirstTime+1]; ObjectSet(delimeterName,OBJPROP_TIME1,firstTime); } } } //---- return(0); } //+------------------------------------------------------------------+ //| признак нового бара | //+------------------------------------------------------------------+ bool isNewBar() { //---- bool res=false; if (myBars!=Bars) { res=true; myBars=Bars; } //---- return(res); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); //---- if (isNewBar()) { // установить разделитель tickCounter++; SetDelimeter(); ExtMapBuffer1[0]=Bid; } else { tickCounter++; ShiftArray(); ExtMapBuffer1[0]=Bid; } //---- return(0); } //+------------------------------------------------------------------+
And more there is - Системы на основе тиковых индикаторов
thank you much Rosh, can i ask you a question? How can i modify the default Stochastic included with mt4? What I basically want to do is to change the "Price field" to be derived from ... (H+L+C+O)/4 ... how can this be achieved?
I don't know why you really need Stochastic from (H+L+C+O)/4 .
//+------------------------------------------------------------------+ //| Stochastic4Price.mq4 | //| Copyright © 2004, MetaQuotes Software Corp. | //| https://www.metaquotes.net// | //+------------------------------------------------------------------+ #property copyright "Copyright © 2004, MetaQuotes Software Corp." #property link "https://www.metaquotes.net//" #property indicator_separate_window #property indicator_minimum 0 #property indicator_maximum 100 #property indicator_buffers 2 #property indicator_color1 LightSeaGreen #property indicator_color2 Red //---- input parameters extern int KPeriod=5; extern int DPeriod=3; extern int Slowing=3; //---- buffers double MainBuffer[]; double SignalBuffer[]; double HighesBuffer[]; double LowesBuffer[]; //---- int draw_begin1=0; int draw_begin2=0; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { string short_name; //---- 2 additional buffers are used for counting. IndicatorBuffers(4); SetIndexBuffer(2, HighesBuffer); SetIndexBuffer(3, LowesBuffer); //---- indicator lines SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0, MainBuffer); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1, SignalBuffer); //---- name for DataWindow and indicator subwindow label short_name="Sto("+KPeriod+","+DPeriod+","+Slowing+")"; IndicatorShortName(short_name); SetIndexLabel(0,short_name); SetIndexLabel(1,"Signal"); //---- draw_begin1=KPeriod+Slowing; draw_begin2=draw_begin1+DPeriod; SetIndexDrawBegin(0,draw_begin1); SetIndexDrawBegin(1,draw_begin2); //---- return(0); } //+------------------------------------------------------------------+ //| Stochastic oscillator | //+------------------------------------------------------------------+ int start() { int i,k; int counted_bars=IndicatorCounted(); double price; //---- if(Bars<=draw_begin2) return(0); //---- initial zero if(counted_bars<1) { for(i=1;i<=draw_begin1;i++) MainBuffer[Bars-i]=0; for(i=1;i<=draw_begin2;i++) SignalBuffer[Bars-i]=0; } //---- minimums counting i=Bars-KPeriod; if(counted_bars>KPeriod) i=Bars-counted_bars-1; while(i>=0) { double min=1000000; k=i+KPeriod-1; while(k>=i) { price=Low[k]; if(min>price) min=price; k--; } LowesBuffer[i]=min; i--; } //---- maximums counting i=Bars-KPeriod; if(counted_bars>KPeriod) i=Bars-counted_bars-1; while(i>=0) { double max=-1000000; k=i+KPeriod-1; while(k>=i) { price=High[k]; if(max<price) max=price; k--; } HighesBuffer[i]=max; i--; } //---- %K line i=Bars-draw_begin1; if(counted_bars>draw_begin1) i=Bars-counted_bars-1; while(i>=0) { double sumlow=0.0; double sumhigh=0.0; for(k=(i+Slowing-1);k>=i;k--) { sumlow+=(Open[k]+High[k]+Low[k]+Close[k])/4-LowesBuffer[k]; sumhigh+=HighesBuffer[k]-LowesBuffer[k]; } if(sumhigh==0.0) MainBuffer[i]=100.0; else MainBuffer[i]=sumlow/sumhigh*100; i--; } //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; int limit=Bars-counted_bars; //---- signal line is simple movimg average for(i=0; i<limit; i++) SignalBuffer[i]=iMAOnArray(MainBuffer,Bars,DPeriod,0,MODE_SMA,i); //---- return(0); } //+------------------------------------------------------------------+The happiness is not in it
wow, thank you soo much Rosh, i looked for places to add this (HLCO)/4 but could
really understand where. thank you. The reason why i asked you about this was because
in my prior software, that was the setting that i had used. hmm Rosh, it seems
that this is simple moving average? Is it possible to create options like the default
stochastic indicator in mt4, like "Smoothed, Exponential" etc? tia
Hmm.... eating and scratching wants but a beginning ? :)
//+------------------------------------------------------------------+ //| Stochastic.mq4 | //| Copyright © 2004, MetaQuotes Software Corp. | //| https://www.metaquotes.net// | //+------------------------------------------------------------------+ #property copyright "Copyright © 2004, MetaQuotes Software Corp." #property link "https://www.metaquotes.net//" #property indicator_separate_window #property indicator_minimum 0 #property indicator_maximum 100 #property indicator_buffers 2 #property indicator_color1 LightSeaGreen #property indicator_color2 Red //---- input parameters extern int KPeriod=5; extern int DPeriod=3; extern int Slowing=3; extren int SmoothType=0; //---- buffers double MainBuffer[]; double SignalBuffer[]; double HighesBuffer[]; double LowesBuffer[]; //---- int draw_begin1=0; int draw_begin2=0; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { string short_name; //---- 2 additional buffers are used for counting. IndicatorBuffers(4); SetIndexBuffer(2, HighesBuffer); SetIndexBuffer(3, LowesBuffer); //---- indicator lines SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0, MainBuffer); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1, SignalBuffer); //---- name for DataWindow and indicator subwindow label short_name="Sto("+KPeriod+","+DPeriod+","+Slowing+")"; IndicatorShortName(short_name); SetIndexLabel(0,short_name); SetIndexLabel(1,"Signal"); //---- draw_begin1=KPeriod+Slowing; draw_begin2=draw_begin1+DPeriod; SetIndexDrawBegin(0,draw_begin1); SetIndexDrawBegin(1,draw_begin2); //---- return(0); } //+------------------------------------------------------------------+ //| Stochastic oscillator | //+------------------------------------------------------------------+ int start() { int i,k; int counted_bars=IndicatorCounted(); double price; //---- if(Bars<=draw_begin2) return(0); //---- initial zero if(counted_bars<1) { for(i=1;i<=draw_begin1;i++) MainBuffer[Bars-i]=0; for(i=1;i<=draw_begin2;i++) SignalBuffer[Bars-i]=0; } //---- minimums counting i=Bars-KPeriod; if(counted_bars>KPeriod) i=Bars-counted_bars-1; while(i>=0) { double min=1000000; k=i+KPeriod-1; while(k>=i) { price=Low[k]; if(min>price) min=price; k--; } LowesBuffer[i]=min; i--; } //---- maximums counting i=Bars-KPeriod; if(counted_bars>KPeriod) i=Bars-counted_bars-1; while(i>=0) { double max=-1000000; k=i+KPeriod-1; while(k>=i) { price=High[k]; if(max<price) max=price; k--; } HighesBuffer[i]=max; i--; } //---- %K line i=Bars-draw_begin1; if(counted_bars>draw_begin1) i=Bars-counted_bars-1; while(i>=0) { double sumlow=0.0; double sumhigh=0.0; for(k=(i+Slowing-1);k>=i;k--) { sumlow+=(Open[k]+High[k]+Low[k]+Close[k])/4-LowesBuffer[k]; sumhigh+=HighesBuffer[k]-LowesBuffer[k]; } if(sumhigh==0.0) MainBuffer[i]=100.0; else MainBuffer[i]=sumlow/sumhigh*100; i--; } //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; int limit=Bars-counted_bars; //---- signal line is simple movimg average for(i=0; i<limit; i++) SignalBuffer[i]=iMAOnArray(MainBuffer,Bars,DPeriod,0,SmoothType,i); //---- return(0); } //+------------------------------------------------------------------+see also Moving Average methods
|
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
Would it be possible to write some type of indicator that plots constant tick charts or constant range bars in another window? These are different forms of charting that are not time based. For example, a 100 tick bar is formed whenever price moves 100 ticks. So on little volume, no bar is formed. A constant range bar is formed whenever price moves a set number of ticks in a range. For example, a range bar set at 20 forms whenever price fills a 20 pip range. Then the next bar is started. I was told my a Metaquotes developer that it was possible. Does anyone know how to do this? Your help is much appreciated.