This forum is in read-only mode now. You may discuss your questions on forums of MQL4.community and MQL5.community
how to find yesterday for pivot point calculationBack to topics list |
|
jimf
2005.02.07 16:25
i am writing an EA to allow me to put a pivot point on my charts.
I would like to have it generic so it may appear on any given chart. In order to achieve this i must get the high low and close from yesterdays trading session but not necessarily have the 1 day chart open. I'm not having much luck. Can someone point me in the right direction? thanks jimf |
|
Shrak
2005.02.11 23:13
which version of mt?
in mt4 its easy this would be your indicator (i had that already written myself and threw a few things out, so it should match your needs) //+------------------------------------------------------------------+ //| Caramilla EQ.mq4 | //| xxxxxxxxxxxxxxx | //| http://www.xxxxxxxxxx.org | //+------------------------------------------------------------------+ #property copyright "Shrak" #property link "http://www.xxxxxxxxxxx.org" #property indicator_chart_window #property indicator_buffers 1 double Buff0[]; datetime ThisArr[]; double BH[50]; double BL[50]; double BC[50]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_LINE, EMPTY, 1, Blue); SetIndexBuffer(0,Buff0); SetIndexLabel(0,"Pivot"); SetIndexDrawBegin(0,0); //---- //start(); return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- TODO: add your code here //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); ArrayResize(ThisArr, Bars); ArrayCopySeries(ThisArr, MODE_TIME); ArrayCopySeries(BH, MODE_HIGH, Symbol(), PERIOD_D1); ArrayCopySeries(BL, MODE_LOW, Symbol(), PERIOD_D1); ArrayCopySeries(BC, MODE_CLOSE, Symbol(), PERIOD_D1); //---- TODO: add your code here int od = 0; int dd = 0; double Pivot; for (int i = 0; i <= Bars; i++) { if (TimeDay(ThisArr[i]) != od) { dd++; Pivot = (BH[dd] + BC[dd] + BL[dd])/3; od = TimeDay(ThisArr[i]); } Buff0[i] = Pivot ; } //---- return(0); } //+------------------------------------------------------------------+ in mt3 its more difficult;) you need to first run all bars back and save all the highs and lows of a day... then you go the bars from left to right back to the most actual and everyday a new day is started you calculate the new pivot... i also wrote an indicator for mt3 but that is very slow... because of the 2 for-loops... shrak |
|
jimf
2005.02.14 05:40
thank you shrak.....
i am sorry to say that i am using an older version of mt (3 i think). i appreceiate your code example as well as your suggestion for collecting the information necessary to find 'yesterday'. it is as awkward as i suspected, but.... i'll get on it soon. thanks again jimf |
Download MetaTrader 5 (450 Kb, web installer) — a new terminal for financial markets
