Forex



Go Back   Forex Trading > Programming > Metatrader Programming






Register
Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.

From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.

 
 
Thread Tools
 
Old 04-08-2009, 10:08 PM
Junior Member
 
Join Date: Apr 2009
Posts: 3
Longshot is on a distinguished road
Getting Ticked Off

Hi all. This is my first post and I could with some help coding an EA.

I want to capture and store a number of successive new bid prices as they come in. I can code a bit so I just need the line or lines that will get the new bids.
I have tried stuff like `Prices[i] = bid` in a for loop but I get the
same value each time until start() is called again. Is the start() function
iterated by incoming ticks?

Thanks in advance.
Longshot
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
 
Old 04-08-2009, 10:23 PM
Junior Member
 
Join Date: Oct 2006
Posts: 26
bobfourie is on a distinguished road
Thumbs up

Here you go

Code:
int start()
  {
     static double aTickData[];
     AddDataToArray(aTickData, Bid)
  }
//Adding data to the front of an array while resizing it
void AddDataToArray(double& array[], double dData)
{
//return if there is no data (server lagging)
if(dData == 0 )return;

//increase array size with 1
 ArrayResize(array,ArraySize(array)+1);

//move all values in array up on space
 for(int i = ArraySize(array) ; i>=0 ;i-- )
 {
  array[i] = array[i-1];
 }

//Add new values to front of array
   array[0]= dData;
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
 
Old 04-09-2009, 09:00 PM
Junior Member
 
Join Date: Apr 2009
Posts: 3
Longshot is on a distinguished road
More Ticks

Many thanks for your reply, bobfourie. Your code improved the situation but there`s still too much I don`t know about how these programs are controlled by the terminal that I might put the idea aside for a while.
I was trying to design an EA that ignored bars and dealt directly with incoming
prices. I wanted to store these and do some calculations on them. However, on a M30 chart I only get fresh prices every 30 mins and then some repeated ones. No other code in the EA is explicitly dealing with bars.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
 
Old 04-09-2009, 10:23 PM
Junior Member
 
Join Date: Oct 2006
Posts: 26
bobfourie is on a distinguished road
Quote:
Originally Posted by Longshot View Post
on a M30 chart I only get fresh prices every 30 mins and then some repeated ones. No other code in the EA is explicitly dealing with bars.
I'm not sure I understand you correctly. It doesn't matter which time frame you use, you will get fresh prices (ticks) every few seconds,if not, your internet connection is very slow
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
 
Old 04-10-2009, 02:20 PM
Junior Member
 
Join Date: Apr 2009
Posts: 3
Longshot is on a distinguished road
My internet connection is fine. The problem must be in the logic I`m using. How do I capture 10 fresh ticks?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
 
Old 04-10-2009, 02:48 PM
Junior Member
 
Join Date: Oct 2006
Posts: 26
bobfourie is on a distinguished road
Have change the function, have put in an extra variable so that you can choose the max size of the array, 10 in the example. Also made the return type an bool so that you know when the array have reached it max size.

Code:
int start()
  {
static double a[];
if(AddDataToMaxArray(a, Bid, 10))
{
//Array have collected enough ticks, do some thing with the array now
}

return(0);
  }
//Adding data to the front of an array while resizing it
bool AddDataToMaxArray(double& array[], double dData, int iMaxSize)
{
//return if there is no data (server lagging)
if(dData == 0 )return;

bool b = false;
//increase array size with 1
if(ArraySize(array)+1 <= iMaxSize )ArrayResize(array,ArraySize(array)+1);
else b = true;

//move all values in array up on space
 for(int i = ArraySize(array) ; i>=0 ;i-- )
 {
  array[i] = array[i-1];
 }

//Add new values to front of array
   array[0]= dData;
   
return(b);
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
 

Bookmarks
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump


All times are GMT. The time now is 02:15 AM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.