• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 7:18pm
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 7:18pm
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

moutaki Mq4+fibo grid Mq4=profit+ease 39 replies

Howto Avoid Shorter/Partial Sessions... 2 replies

Howto get a Candle (High/Low/Open/Close) at any specific time 4 replies

Howto on volume ='mt4'|vol!eurusd 3 replies

[Need Help] Howto get Fibonacci value? 2 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
  • 1
Attachments: Howto to get (current and last few bars) Price in mq4 EA
Exit Attachments

Howto to get (current and last few bars) Price in mq4 EA

  • Post #1
  • Quote
  • First Post: Edited at 8:34am May 26, 2009 8:33am | Edited at 8:34am
  •  n000b
  • | Joined Mar 2009 | Status: The Chick Magnet | 187 Posts
Hi!

This probably is a very basic question, but unfortunately all the EAs I have looked at, I can't find any example of getting the price of the instrument currently the EA is attached to. I also want to have price (High/Low/Open/Close) for some bar earlier e.g. last 10 bars.

Thanks in Advance.
If it floats, flies, or f%^ks, rent it, it's cheaper.
  • Post #2
  • Quote
  • Edited at 8:56am May 26, 2009 8:44am | Edited at 8:56am
  •  FOREXflash
  • | Commercial Member | Joined Sep 2008 | 955 Posts
Current bar price;

double OpenPrice=Open[0];
double ClosePrice=Close[0];
double HighPrice=High[0];
double LowPrice=Low[0];

Last bar price;

double OpenPrice=Open[1];
double ClosePrice=Close[1];
double HighPrice=High[1];
double LowPrice=Low[1];

etc............

For every backup in price you need to add [number] how long you want to look back.......
last say you want to look 10th bar before current one, you will code this;

double OpenPrice=Open[9];
.....the number 9 is ok becouse you are counting from zero bar (9+current bar is 10 bars)!!!

In most of the codes(especialy indicators) you will see ; double OpenPrice=Open[i];
take a note that you need to have initialized i ......int i; ...so i represents a zero bar!!!
For every bar back you want to look, just add u number to i...........

double OpenPrice=Open[i]; // CURRENT BAR
double OpenPrice=Open[i+1]; // LAST BAR
double OpenPrice=Open[i+2]; // CURRENT BAR-2
double OpenPrice=Open[i+9]; // CURRENT BAR-9
ETC..........


Regards
forexflash
 
 
  • Post #3
  • Quote
  • May 26, 2009 9:26am May 26, 2009 9:26am
  •  n000b
  • | Joined Mar 2009 | Status: The Chick Magnet | 187 Posts
Thanks FOREXflash, much appreciated! exactly what I was looking for.
If it floats, flies, or f%^ks, rent it, it's cheaper.
 
 
  • Post #4
  • Quote
  • Feb 14, 2017 4:53am Feb 14, 2017 4:53am
  •  jhersont07
  • | Joined Feb 2017 | Status: Junior Member | 4 Posts
How can I know the high, close, open, low of a candle, using a vertical line, that when moving the vertical line gives the information of the candle?
I just have to recognize the sail on the line and give me the information about the sail. The error is red

#property indicator_chart_window extern color Ncolor=DeepPink; input ENUM_LINE_STYLE Style=STYLE_DOT; extern bool Alerta = True; extern bool Notifipush = True; int init() { return(0); } int deinit() { return(0); } int start() { ObjectCreate("0",OBJ_VLINE,0,Time[0],0); ObjectSet("0", OBJPROP_STYLE, Style); ObjectSet("0", OBJPROP_COLOR, Ncolor); datetime line0 =ObjectGetValueByShift("0", 0); double open=Open[line0]; double close=Close[line0]; double high=High[line0]; double low= Low[line0]; string comentario = ""; comentario = comentario +" "+"RETROCESO"+"\n"; comentario = comentario +" "+" "+"OPEN."+" "+"+"+open + "\n"; comentario = comentario +" "+" "+"CLOSE."+" "+"-"+close+ "\n"; comentario = comentario +" "+" "+"HIGH."+" "+"-"+high+ "\n"; comentario = comentario +" "+" "+"LOW."+" "+"-"+low+ "\n"; Comment(comentario); return(0); }
 
 
  • Post #5
  • Quote
  • Feb 14, 2017 11:05am Feb 14, 2017 11:05am
  •  mladen
  • Joined Apr 2007 | Status: ... | 783 Posts
Quoting jhersont07
Disliked
How can I know the high, close, open, low of a candle, using a vertical line, that when moving the vertical line gives the information of the candle? I just have to recognize the sail on the line and give me the information about the sail. The error is red #property indicator_chart_window extern color Ncolor=DeepPink; input ENUM_LINE_STYLE Style=STYLE_DOT; extern bool Alerta = True; extern bool Notifipush = True; int init() { return(0); } int deinit() { return(0); } int start() { ObjectCreate("0",OBJ_VLINE,0,Time[0],0); ObjectSet("0", OBJPROP_STYLE,...
Ignored
All you need is a time of the vertical line and then use that time to get the bar at that time (using iBarShift(NULL,0,TimeOfVerticalLine))
 
 
  • Post #6
  • Quote
  • Feb 19, 2017 1:42pm Feb 19, 2017 1:42pm
  •  jhersont07
  • | Joined Feb 2017 | Status: Junior Member | 4 Posts
I tried as you told me but it does not work well, I attach the indicator, I just need to drag the line in the different candles and this has to give me the information of the candle. The only thing I need is to get the values of the candle from the vertical line.
I tried as you told me but it does not work well, I attach the indicator, I just need to drag the line in the different candles and this has to give me the information of the candle. The only thing I need is to get the values of the candle from the vertical line.
Attached File
File Type: mq4 info candles.mq4   2 KB | 1,127 downloads
 
 
  • Post #7
  • Quote
  • Last Post: Jan 14, 2019 1:15pm Jan 14, 2019 1:15pm
  •  psychosisvs
  • | Joined Jan 2019 | Status: Junior Member | 1 Post
Hello,

A simple question as I'm a bit confused..

If Close[0] returns the close price of the current bar, wouldn't it also be the same as the bid price(in the case that the chart is drawn by the bid price)?

And if so, if I'm looking for a certain candle type like a Hammer candle, I would have to check the previous bar's - [1] prices and not the current one's?
Since the current candle has not yet taken it's final shape.
 
 
  • Platform Tech
  • /
  • Howto to get (current and last few bars) Price in mq4 EA
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2022