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
  #621 (permalink)  
Old 01-18-2008, 06:03 PM
Dan7974's Avatar
Senior Member
 
Join Date: Jul 2006
Posts: 264
Dan7974 is on a distinguished road
How do I know the profit of the previous trade? And the lots, and the side?
__________________
God Bless Everyone, and their trading logic.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #622 (permalink)  
Old 01-18-2008, 06:16 PM
Senior Member
 
Join Date: Jan 2006
Posts: 1,084
omelette is on a distinguished road
Quote:
Originally Posted by Dan7974 View Post
How do I know the profit of the previous trade? And the lots, and the side?
Use OrdersHistoryTotal() instead of OrdersTotal(). Then use OrderProfit(), OrderLots() etc. You must make sure that historical quotes for the timeperiod you are interested in are loaded though, and I think you can only do this manually - right-click on the 'Orders History' tab and select 'All History'.

Should have added that you need to use 'MODE_HISTORY' with OrderSelect()...

Last edited by omelette; 01-18-2008 at 06:21 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #623 (permalink)  
Old 01-18-2008, 07:12 PM
Senior Member
 
Join Date: Feb 2006
Posts: 513
Michel is on a distinguished road
Quote:
Originally Posted by omelette View Post
Use OrdersHistoryTotal() instead of OrdersTotal(). Then use OrderProfit(), OrderLots() etc. You must make sure that historical quotes for the timeperiod you are interested in are loaded though, and I think you can only do this manually - right-click on the 'Orders History' tab and select 'All History'.

Should have added that you need to use 'MODE_HISTORY' with OrderSelect()...
Hi Omelette,
Do you know that BT have a problem looking in the history: it looks on the real history, not the one of the BT. I asked Metaquote few months ago about this bug but they didn't have any answer.... Maybe now it's fixed...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #624 (permalink)  
Old 01-19-2008, 06:51 AM
Banned
 
Join Date: Nov 2007
Posts: 374
oilfxpro is on a distinguished road
Hi

How do u code an interest rate tightening cycle on one currency ,and a interest rate reduction cycle on another currency?

Can EA look at swaps current and swaps historical rates?

OILFXPRO
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #625 (permalink)  
Old 01-19-2008, 11:45 AM
Junior Member
 
Join Date: Dec 2007
Posts: 7
manu29 is on a distinguished road
Help on function call

Hi,

I would like to replace the code of this indicator :

int start()
{
int bar, limit, i;
int counted_bars=IndicatorCounted();

if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;

//Hull average computation
for(i=0; i<limit; i++)
TempBuf1[i]=2*iMA(NULL,0,HalfHullPeriod,0,MODE_LWMA,PRICE_CLO SE,i)-iMA(NULL,0,HullPeriod,0,MODE_LWMA,PRICE_CLOSE,i);
for(i=0; i<limit; i++)
HullBuf[i]=iMAOnArray(TempBuf1,0,SqrtHullPeriod,0,MODE_LWMA, i);

//----
return(0);
}

by a call at a function like that :

double ComputeHull(double MyArray[], int MyPeriod)
{
double MyTemp[];
double result = -1;
int i;

int HalfPeriod = MathRound(MyPeriod/2);
int SqrtPeriod = MathRound(MathSqrt(MyPeriod));

//Copy Close Values to CloseTemp
ArrayResize(MyTemp, SqrtPeriod);
ArraySetAsSeries(MyTemp, true);

//HMA value computation
for(i=0; i<SqrtPeriod; i++)
{
MyTemp[i] = 2*iMAOnArray(MyArray, 0, HalfPeriod, 0, MODE_LWMA, i) - iMAOnArray(MyArray, 0, MyPeriod, 0, MODE_LWMA, i);
}
result = iMAOnArray(MyTemp, 0, SqrtPeriod, 0, MODE_LWMA, 0);

//---- done
return(result);
}

int start()
{
double CloseTemp[];
int bar, limit, i;
int counted_bars=IndicatorCounted();

if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;

ArrayResize(CloseTemp, HullPeriod+SqrtHullPeriod);
ArraySetAsSeries(CloseTemp, true);

for(i=0; i<limit; i++)
{
ArrayCopy(CloseTemp, Close, 0, i, HullPeriod+SqrtHullPeriod);
HullAntBuf[i]=ComputeHull(CloseTemp, HullPeriod);
}

//----
return(0);
}

I don't understand why the result is not the same. It is not a spécific problem about the HMA just i'd like to ompute my indicator in a spécific function where the array is passed in argument.

I've attached source code of an indicator which display the two curves, it's seems that it is the second call to iMAOnArray which done different results.

Please help me i don't understand the problem
Attached Files
File Type: mq4 HULL_ANTICIP.mq4 (3.8 KB, 1 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #626 (permalink)  
Old 01-19-2008, 12:04 PM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
Check out Formal parameters - MQL4 Documentation
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #627 (permalink)  
Old 01-19-2008, 12:36 PM
Junior Member
 
Join Date: Dec 2007
Posts: 7
manu29 is on a distinguished road
Thanks a lot for your reply. Is not a problem with arguments, the calculation in the loop is correct. I think the problem is with the second call to iMAonArray outside the loop in function.

Regards
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #628 (permalink)  
Old 01-19-2008, 12:50 PM
Senior Member
 
Join Date: Jan 2007
Location: not so remote
Posts: 1,802
fxbs is on a distinguished road
Best way to add MaxBarsToCount (History) to the limit

whan we limit MaxBarsToCount (History) sometimes it require to add Correction, etc
is the best (safest, easiest, universal) way exists?
----------------------

like here we have light fisher 4 stoch smothing:
----------

int start()
{
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
int limit=Bars-counted_bars;
if(limit>maxbars)limit=maxbars;
if (limit>Bars-lenth-1)limit=Bars-lenth-1;
//----
for (int shift = limit; shift>=0;shift--)
{
AuxBuffer[shift]=(iStochastic(NULL,0,lenth,2,1,MODE_SMA,0,MODE_MAI N,shift)/100-0.5)
+0.5*AuxBuffer[shift+1];

FishBuffer[shift]= 0.25* MathLog((1+AuxBuffer[shift])/(1-AuxBuffer[shift]))+
0.5*FishBuffer[shift+1];
SignalBuffer[shift]=FishBuffer[shift+1];

}

//----
return(0);
}
------------------------

for fisher limit f-la:

int limit;
int counted_bars=IndicatorCounted();

if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;

for(int i=limit; i>=0; i--)
{
....

for Stoch:


int start()
{
int i,k;
int counted_bars=IndicatorCounted();
double price;
//----
if(Bars<=draw_begin2) return(0);
//---- initial zero
if(counted_bars<1)
{
for(i=1;i<=draw_begin1;i++) MainBuffer[Bars-i]=0;
for(i=1;i<=draw_begin2;i++) SignalBuffer[Bars-i]=0;
}
//---- minimums counting
i=Bars-KPeriod;
if(counted_bars>KPeriod) i=Bars-counted_bars-1;
while(i>=0)
{
double min=1000000;
k=i+KPeriod-1;
while(k>=i)
{
price=Low[k];
if(min>price) min=price;
k--;
}
LowesBuffer[i]=min;
i--;
}
....


p.s. in attached indicator, based on clean fisher transform and Stoch; MaxBars needs to be straighten-up a bit... (when MaxBars out - no problem)
Attached Files
File Type: mq4 Trans_Stoch_smz_limitMaxBars_test.mq4 (2.8 KB, 10 views)

Last edited by fxbs; 01-19-2008 at 01:16 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #629 (permalink)  
Old 01-19-2008, 02:58 PM
Senior Member
 
Join Date: May 2007
Posts: 140
dvarrin is on a distinguished road
Hi,

Thanks a lot to all of you. It is working fine now and only one order per bar is opened. What is nice with an EA like this is that we can use the "Open price only" option for backtesting, which is faster than the "per tick" one.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #630 (permalink)  
Old 01-19-2008, 06:37 PM
Senior Member
 
Join Date: Jan 2006
Posts: 1,084
omelette is on a distinguished road
Quote:
Originally Posted by Michel View Post
Hi Omelette,
Do you know that BT have a problem looking in the history: it looks on the real history, not the one of the BT. I asked Metaquote few months ago about this bug but they didn't have any answer.... Maybe now it's fixed...
Michel, thank for the heads-up. Wow, I didn't know that - and I'd rate that as a huge bug!!!

To check this (with MT 208), I used OrdersHistoryTotal() info. to decide trade direction on a martingaler, and used 'conventional means' on another version - the equity curve for both 'should' be identical. This is what I found.........

I have also just checked with the latest Metatrader and the bug is still there - unbelieveable.....
Attached Images
File Type: gif NotUsingHistoryTotal_TesterGraph.gif (6.2 KB, 85 views)
File Type: gif UsingHistoryTotal_TesterGraph.gif (7.3 KB, 85 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

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 On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to code this? iscuba11 Metatrader 4 mql 4 - Development course 1 08-03-2007 04:22 PM


All times are GMT. The time now is 01:01 PM.



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