Forex
Google
New signals service!

Go Back   Forex Trading > Programming > Metatrader Programming


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #331 (permalink)  
Old 03-19-2008, 09:14 AM
Linuxser's Avatar
Moderator
 
Join Date: May 2006
Location: Helliconia (Spring)
Posts: 2,820
Blog Entries: 34
Linuxser has disabled reputation
Quote:
Originally Posted by MANSTIR View Post

do any source code is suitable on above calculations instead of mine?

please change anything inside the ea, please... i'm not a good programmer

thanks

here's the ea
Sorry, EA code? maybe here.

Auto pivot trade
__________________
Elite Manual Trading | Portfolio | Calendar | Suggestions to improve the forum | My Blog

Remember: Signatures must have three lines as maximum

Last edited by Linuxser; 03-19-2008 at 09:19 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #332 (permalink)  
Old 03-19-2008, 01:26 PM
Junior Member
 
Join Date: Mar 2008
Location: Australia
Posts: 9
Nudge is on a distinguished road
Find Trend based on last 2 bars

Hi all,

I'm just learning MQL and would like to know the easiest way to find out if a trend is going long or short based on the last 2 bars.

For example, if the close price is 1.2345 for Close[2] and the close price is 1.2350 for Close[1], and the current Close price is 1.2360 for Close[0].

Would I do something like

if(Close[2] < Close[1] && Close[1] < Close[0]) {

}

and do the same for a down trend but reversed

Or is there a more professional way to do it.

Thanks for your help
Nudge
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #333 (permalink)  
Old 03-19-2008, 06:45 PM
Senior Member
 
Join Date: Dec 2005
Location: In front of my trading desk
Posts: 344
Devil2000 is on a distinguished road
Quote:
Originally Posted by Nudge View Post
Hi all,

I'm just learning MQL and would like to know the easiest way to find out if a trend is going long or short based on the last 2 bars.

For example, if the close price is 1.2345 for Close[2] and the close price is 1.2350 for Close[1], and the current Close price is 1.2360 for Close[0].

Would I do something like

if(Close[2] < Close[1] && Close[1] < Close[0]) {

}

and do the same for a down trend but reversed

Or is there a more professional way to do it.

Thanks for your help
Nudge
What do you mean by "professional way"?
Every coder has a different logic and different way to code their ideas.
And the simpler is better! I think your code is quiet simple, I don't know how to make it simpler.
__________________
Need a professional MQL4 programmer? PM me
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #334 (permalink)  
Old 03-19-2008, 06:55 PM
Member
 
Join Date: Jan 2006
Posts: 30
DooMGuarD is on a distinguished road
Quote:
Originally Posted by Linuxser View Post
Yes of course.

Can calculate different arrays.

Something like:
well Linuxser... i have this idea for code

PHP Code:
int start()
{
  
double A iMAOnArray(GetArray(1),10,5,0,MODE_EMA,0);
  
double B iMAOnArray(GetArray(2),10,5,0,MODE_EMA,1);
  
  Print(
"A= ",A,"  B=",B);

  return(
0);
}

double *GetArray(double Factor// how to define a funcion return as array 
{
  
double Arr[10];
  
  for(
int i=0;i<10;i++) Arr[i] = i*Factor;
 
  return(
Arr);

this code is possible?

if yes, think, a lot of way for systems....

regards

Last edited by DooMGuarD; 03-19-2008 at 07:00 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #335 (permalink)  
Old 03-19-2008, 07:57 PM
Linuxser's Avatar
Moderator
 
Join Date: May 2006
Location: Helliconia (Spring)
Posts: 2,820
Blog Entries: 34
Linuxser has disabled reputation
Quote:
Originally Posted by DooMGuarD View Post
well Linuxser... i have this idea for code

PHP Code:
int start()
{
  
double A iMAOnArray(GetArray(1),10,5,0,MODE_EMA,0);
  
double B iMAOnArray(GetArray(2),10,5,0,MODE_EMA,1);
  
  Print(
"A= ",A,"  B=",B);

  return(
0);
}

double *GetArray(double Factor// how to define a funcion return as array 
{
  
double Arr[10];
  
  for(
int i=0;i<10;i++) Arr[i] = i*Factor;
 
  return(
Arr);

this code is possible?

if yes, think, a lot of way for systems....

regards
Iīm not expert, just curious. I understand logic at the first part and it's ok.

For the second array...

ArraySetAsSeries?
ArrayGetAsSeries?
__________________
Elite Manual Trading | Portfolio | Calendar | Suggestions to improve the forum | My Blog

Remember: Signatures must have three lines as maximum
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #336 (permalink)  
Old 03-19-2008, 09:50 PM
Junior Member
 
Join Date: Mar 2008
Location: Australia
Posts: 9
Nudge is on a distinguished road
Quote:
Quote:
Originally Posted by Nudge View Post
Hi all,

I'm just learning MQL and would like to know the easiest way to find out if a trend is going long or short based on the last 2 bars.

For example, if the close price is 1.2345 for Close[2] and the close price is 1.2350 for Close[1], and the current Close price is 1.2360 for Close[0].

Would I do something like

if(Close[2] < Close[1] && Close[1] < Close[0]) {

}

and do the same for a down trend but reversed

Or is there a more professional way to do it.

Thanks for your help
Nudge

Quote:
Originally Posted by Devil2000 View Post
What do you mean by "professional way"?
Every coder has a different logic and different way to code their ideas.
And the simpler is better! I think your code is quiet simple, I don't know how to make it simpler.
I thought there may be a function already in MQL that does this and I have not found it yet.

Thanks for your reply, much appreciated.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #337 (permalink)  
Old 03-19-2008, 09:57 PM
Senior Member
 
Join Date: Feb 2006
Posts: 524
Michel is on a distinguished road
Quote:
Originally Posted by DooMGuarD View Post
PHP Code:
double *GetArray(double Factor// how to define a funcion return as array 
{
  
double Arr[10];
  
  for(
int i=0;i<10;i++) Arr[i] = i*Factor;
 
  return(
Arr);

this code is possible?

if yes, think, a lot of way for systems....

regards
It seems easier to declare the array at global scoop, then any function can modify it. You also can pass the array to be modified to the fonction by reference using "&" :
PHP Code:
void MyFunc(doubleArr[]) 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #338 (permalink)  
Old 03-19-2008, 11:41 PM
Member
 
Join Date: Jan 2006
Posts: 30
DooMGuarD is on a distinguished road
rigth Michel, but i donīt want to make an array to use in call arguments... i just need something similar to "series function" in an easy language...

Quote:
Originally Posted by easy language definition
Series function
A series function is a specialized function that refers to a previous function value within its calculations. In addition, series functions update their value on every bar even if the function call is placed within a conditional structure that may not be true on a given bar. Because a series function automatically stores its own previous values and executes on every bar, it allows you to write function calculations that may be more streamlined than if you had to manage all of the resources yourself. However, it's a good idea to understand how this might affect the performance of your EasyLanguage code.

The Function Properties - General tab is used to set the function storage and execution method to Series, Simple, or Auto-Detect. When in doubt, select Auto-Detect and the compiler will select the most appropriate storage method for the function.

Example
This one line series function adds the current bar Volume to the value of the function from the previous bar. Because a series function automatically updates on every bar, this makes it easy to write a function that maintains a running total.

VolTotal = VolTotal[1] + Volume;
see this code for EasyLanguage

PHP Code:
inputs:
  
Price(Numeric), r(Numeric), s(Numeric), u(Numeric);

#EVENTS
OnDestroy EasyLanguageRtlOnDestroy;
#END ;
PBF_AVG XAverage(XAverage(XAverage(Pricer), s), u); 
XAverage is defined as a "series function" (like recursive functions, but no equal) and generate a array as return type and will be used as argument in others functions....

if i make a return type as array i can translate EasyLanguage to MT easy...

NOTE: XAverage is a exponentially weighted moving average
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #339 (permalink)  
Old 03-24-2008, 08:19 PM
Junior Member
 
Join Date: Jan 2008
Posts: 6
star90 is on a distinguished road
Mt4 Memory Usage problem with variables.

1) I am running mt4 with loops (in each loop I am assigning different values to variables and running again calculations)
2) After 20 loops I am getting values of 0 assigned to the variables instead of the values that I expect to receive and wrong calculation results.

What can be the reason? Is it because of memory and how can I release the memory in mt4 ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #340 (permalink)  
Old 03-25-2008, 03:27 PM
Junior Member
 
Join Date: Jan 2008
Location: Canada
Posts: 9
timebandit is on a distinguished road
ticket value

Hi,
When an order is open it is assigned a ticket number. When this order is modified through an EA (i.e. the EA closes a portion of the trade) does the old ticket get changed to a new ticket number?
I'm still a rookie at all this programming stuff so any help is greatly appreciated.
Thanks
Bob
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
close, eas, learn mql4 video, profit, reach

Thread Tools
Display Modes

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Learning Cycles For New Traders Dan7974 General Discussion 350 01-18-2008 06:04 PM
Learning to code for autotrading GoatT Metatrader Programming 8 01-10-2007 08:55 PM
Self learning expert mrtools Expert Advisors - Metatrader 4 32 10-22-2006 05:29 PM


All times are GMT. The time now is 07:21 AM.



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