Ask! - page 18

 

retrieving the t_1 bid and ask values

Hello,

I am a newbie in programming and I don't know how to retrieve the value for the previous tick : previous ask and bid values.

Thank you for your help.

 

Ask and Bid history - witchazel

witchazel:
hello, i am working on an EA .... .... i would do if ask[-1] =iCustom but i cant fiure it out here as Ask and Bid do not have history

I have the same question, would like to retrieve ask[-1] and bid[-1]and don't knw how to do so.

If you have a solution, please post it.

Many thanks.

 
 
 
 

Hi FireDave, Thanks for the warm welcome. Glad to see you here too. Are you a Moderator here ?

DayTrSuccess,

this should get you started:

// Fill your array

MyArray[][3];

ArrayInitialize(MyArray,0);

for (int cnt=OrdersTotal()-1;cnt>=0;cnt--)

{ OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if (OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)

{ MyArray[cnt][0]=OrderTicket();

if (OrderType()==OP_BUY)

{ MyArray[cnt][1]=1; // Buy

MyArray[cnt][2]=OrderOpenPrice();

}

else

{ MyArray[cnt][1]=2; // Sell

MyArray[cnt][2]=OrderOpenPrice();

}

}

}

// Search your array for OrderTicket

int MyArrayIndex=ArrayBsearch(MyArray,OrderTicket(),WHOLE_ARRAY,0,MODE_ASCEND);

if (MyArray[MyArrayIndex][0]==OrderTicket())

{ // Your code here

}

 
Yannis:
Hi FireDave, Thanks for the warm welcome. Glad to see you here too. Are you a Moderator here ?

Nope, just another holy-grail-searcher

 

Thank you Yannis

Yannis:

DayTrSuccess,

this should get you started:

.......................

}

Thank you. I'll use it.

 
 

witchazel,

I don't understand what do you mean with "will it give me the close of the last change?". Open/High/Low/Close concerns price bars. So yes, Close[1] will give you the close for previous bar on the time frame your chart is currently on. You can use iClose(NULL,0,Shift) (iOpen/iHigh/iLow) to get these values on time frame other than the one you're on. "0" stands for "current" time frame and "shift" for the bars back. Replace "0" with the time frame you need (1,5,15,30,60,240....) and shift with the number of bars back, you can even replace "NULL" to "GBPUSD" if your current chart is EURUSD but you need to address GBP previous close.

iClose(NULL,1,1) will give the close of your current pair, on 1 min chart, 1 bar back.

I would consider spending some time reading the threads addressing MT4 coding, i think CodesGuru has an excellent one for new coders, as well as Metaeditor help file and free experts and indicators posted allover the place.

Yannis

Reason: