get last value´s

 

Hey there

I am quite new to mql5 but i already programmed in c++/java/php.

I am not sure why my code isnt executed, thats why i am asking here:

void OnTick()
  {
   MqlTick last_tick;
//---
   if(SymbolInfoTick(Symbol(),last_tick))
     {
      Print(last_tick.time,": Bid = ",last_tick.bid,
            " Ask = ",last_tick.ask);
     }
   else Print("SymbolInfoTick() failed, error = ",GetLastError());
//---
  }

first of all, i just want to get the last bid- and ask-price.

This code i saved in: MQL5 / Experts / bot1.mq5

When i load it, i get this in my journal: "expert bot1 (CADCHF,M1) loaded successfully.

But there is no output in "expert"-tab, why?

Greetings

 
nikoscher:

Hey there

I am quite new to mql5 but i already programmed in c++/java/php.

I am not sure why my code isnt executed, thats why i am asking here:

first of all, i just want to get the last bid- and ask-price.

This code i saved in: MQL5 / Experts / bot1.mq5

When i load it, i get this in my journal: "expert bot1 (CADCHF,M1) loaded successfully.

But there is no output in "expert"-tab, why?

Greetings

Welcome to mql5.com forum,

Market is currently closed. There is no tick, so OnTick() event handler is never executed.

 
angevoyageur:

Welcome to mql5.com forum,

Market is currently closed. There is no tick, so OnTick() event handler is never executed.

ah ok of course...one more question:

Is there any possibility to choose the periodicity in code?

Or do i have to configure it in MT5 every time?


Greetings!

 
nikoscher:

ah ok of course...one more question:

Is there any possibility to choose the periodicity in code?

Or do i have to configure it in MT5 every time?


Greetings!

You mean change the timeframe of a chart ? You can change the periodicity of a chart, see ChartSetSymbolPeriod()

Documentation on MQL5: Chart Operations / ChartSetSymbolPeriod
Documentation on MQL5: Chart Operations / ChartSetSymbolPeriod
  • www.mql5.com
Chart Operations / ChartSetSymbolPeriod - Documentation on MQL5
 
angevoyageur:

You mean change the timeframe of a chart ? You can change the periodicity of a chart, see ChartSetSymbolPeriod()

yea thanks u very much
 

mhm ok, but is there any chance of getting two last ask-prices every tick?

like this strucuture:

1. 18:00

=> get ask prices (17:59 ; 18:00)

2. 18:01

=> get ask prices (18:00 ; 18:01)

2. 18:02

=> get ask prices (18:01 ; 18:02)

anybody know´s how to do this using onTick? greetings!

 

sorry i need to change my question:

i dont want the last ask price "onTick", because the last ask-price is changing every moment right?

What i need, is the last stabil ask-price,

so i cant use "onTick" or?

any advices? greetings!

 
nikoscher:

sorry i need to change my question:

i dont want the last ask price "onTick", because the last ask-price is changing every moment right?

What i need, is the last stabil ask-price,

so i cant use "onTick" or?

any advices? greetings!

What is the "last stabil ask-price" ?
 

sorry my fault(english knowledge..),

i just ask again, is it possible to get value´s of last two minutes? :

this strucuture:

1. 18:00

=> get ask prices (17:59 ; 18:00)

2. 18:01

=> get ask prices (18:00 ; 18:01)

2. 18:02

=> get ask prices (18:01 ; 18:02)

can i get them using onTick ? greetings!
 
nikoscher:

sorry my fault(english knowledge..),

i just ask again, is it possible to get value´s of last two minutes? :

this strucuture:

1. 18:00

=> get ask prices (17:59 ; 18:00)

2. 18:01

=> get ask prices (18:00 ; 18:01)

2. 18:02

=> get ask prices (18:01 ; 18:02)

can i get them using onTick ? greetings!

Ask price aren't save in history data. You can get Bid price and apply saved spread (highest of 1 minute).

   double price[1];
   int spread[1];
   CopyOpen(_Symbol,PERIOD_M1,D'2014.02.17 17:49',1,price);
   CopySpread(_Symbol,PERIOD_M1,D'2014.02.17 17:49',1,spread);
   double ask=price[0]+spread[0]*_Point;