Query Current Price Action

 

Is it possible to query the current moving price action, and not just the OHLC?

I tried: 

MathAbs (Price[0] - Price[1].close > 0.0002) 

It doesnt work because I have no OHLC on the Price[0].

I also tried:

MathAbs ((PositionGetDouble (POSITION_PRICE_CURRENT) - PriceDataTable[1].open) > 0.00002) 

... but this just stopped all my trades

Is there a way to query current price action?

Thanking you in advance

 
TheForexGamer:

Is it possible to query the current moving price action, and not just the OHLC?

I tried: 

It doesnt work because I have no OHLC on the Price[0].

I also tried:

... but this just stopped all my trades

Is there a way to query current price action?

Thanking you in advance

You are mixing "apples" with "orranges"! You do not seem to be understanding the underlying data structures and processes and the required coding, so I would suggest you do more research by reading the documentation or maybe a book on MQL5 programming ...

Forum on trading, automated trading systems and testing trading strategies

Something Interesting to Read

Sergey Golubev, 2017.09.16 05:48

Expert Advisor Programming for MetaTrader 5


This book will teach you the following concepts:

  • Learn the basics of MQL5, including variables and data types, operators, functions, event handlers, and object-oriented programming.
  • Place, modify and close market and pending orders.
  • Calculate, verify and add stop loss and take profit prices to an open position.
  • Add a flexible trailing stop and/or break even stop to your strategy.
  • Manage your trade risk with money management.
  • Use pending orders to scale in and out of positions.
  • Use price, time and indicator data in your expert advisors.
  • Control program execution by trading on new bar open, and add flexible trade timers to your strategies.
  • Walk through the creation of several basic trading strategies from start to finish.
  • Inform the user with dialog boxes, email alerts, mobile notifications and sounds.
  • Draw trend lines, arrows and text labels on the chart.
  • Read and write data to CSV files.
  • Learn the basics of creating indicators, scripts and libraries in MetaEditor.
  • Debug, test and optimize your trading strategy.
  • And much more!

Whether you’re an experienced programmer moving from MQL4, or a novice just starting with MQL5, this book will give you the foundation to quickly program fully-featured and robust trading systems.

 

Well there are other good books as well.

But then this would turn into an advertisement campaign.

 
Marco vd Heijden: Well there are other good books as well. But then this would turn into an advertisement campaign.
Yes, that is why I used a "pocket" to direct to the "Something Interesting to Read" thread with other such books (as per the Instructions given to me by a moderator). I use this one as reference, because this is the one I read back in the day, so it is the only one I can vouch for.
 

I realise the things above dont work (the first one i knew wouldn't work but did it as an example to explain what im trying to do), the second was a guess.


What about:

MqlTick  m_tick;

double last_price = m_tick.last;

SymbolInfoTick(_Symbol,m_tick);

then:

MathAbs((m_tick.last - PriceDataTable[1].close) > 0.0007)


I came here to be pointed in the right direction really. I have tried learning by reading books but i find the best way is to set myself a project and then learn the bits i need to make the project work. So if someone could give some tips or syntax to look at (that would take me to where i want to go), I would appreciate that..

 

...although that book does sound good!

 
TheForexGamer: I realise the things above dont work (the first one i knew wouldn't work but did it as an example to explain what im trying to do), the second was a guess.

What about:

MqlTick  m_tick;

double last_price = m_tick.last;

SymbolInfoTick(_Symbol,m_tick);

then:

MathAbs((m_tick.last - PriceDataTable[1].close) > 0.0007)

I came here to be pointed in the right direction really. I have tried learning by reading books but i find the best way is to set myself a project and then learn the bits i need to make the project work. So if someone could give some tips or syntax to look at (that would take me to where i want to go), I would appreciate that..

In order for us to help, you have to show more of your code or else we will not be able to understand the context of your question.

For example, we have no idea what are those variables "Price[]" or "PriceDataTable[]". How are they defined? How are they populated with data? etc.

Without some context and just showing two or three lines of code, is like you show us a car-key and asking us to show you how to drive your car.