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 (1) Thread Tools Display Modes
  #631 (permalink)  
Old 01-19-2008, 01:50 PM
Senior Member
 
Join Date: Jan 2007
Location: not so remote
Posts: 2,242
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 02:16 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #632 (permalink)  
Old 01-19-2008, 03:58 PM
Senior Member
 
Join Date: May 2007
Posts: 150
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
  #633 (permalink)  
Old 01-19-2008, 07:37 PM
Senior Member
 
Join Date: Jan 2006
Posts: 1,119
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, 86 views)
File Type: gif UsingHistoryTotal_TesterGraph.gif (7.3 KB, 86 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #634 (permalink)  
Old 01-19-2008, 07:43 PM
Senior Member
 
Join Date: Jan 2006
Posts: 1,119
omelette is on a distinguished road
Quote:
Originally Posted by oilfxpro View Post
.....Can EA look at swaps current and swaps historical rates?

OILFXPRO
Afraid not.

PS - my reply looks misleading. I meant you cannot retrieve historical swap rates - there's no problem getting current rates...

Last edited by omelette; 01-21-2008 at 05:07 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #635 (permalink)  
Old 01-19-2008, 08:04 PM
arsenic786's Avatar
Member
 
Join Date: Mar 2007
Posts: 86
arsenic786 is on a distinguished road
Thumbs up Need MQL Code

Hello there,

I need few code that I can integrate it in an EA.

1) I need to put a restriction to my EA like that, it should not open any position between 2:00 PM to 5:00 PM. How can I do that? please give me this simple code and tell where I can place it in EA.

2) I don't want to put SL in EA to open position because of SL hunting by broker. So, I need to put a check on EA that "if total profit on opened position is +20 points then close position".

I will be very thankfully to the supporters who always support other people!

Best Regards,
Kashif.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #636 (permalink)  
Old 01-22-2008, 01:01 PM
Junior Member
 
Join Date: Nov 2007
Posts: 10
derumuro is on a distinguished road
several Orders at one time

Hi,

I want to program in a Expert Advisor the following :


I would like to open several Orders at the same time (3-6 Orders )

1. Order : Volume; T/P; S/L; T/S
.
.
.
5. Order : Volume; T/P; S/L; T/S

Can help me ?

Thanks
derumuro
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #637 (permalink)  
Old 01-22-2008, 06:15 PM
Member
 
Join Date: Jul 2006
Posts: 32
agarwalsharma is on a distinguished road
I need to learn something.

Hi all

I need a programming help for a simple code which is:

If the market price > MA value by delta pips open buy.
If the market price < MA value by delta pips open sell.

With TP SL and TS. Can any expert programmer teach me how to write the code?

Thank you
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #638 (permalink)  
Old 01-22-2008, 10:07 PM
Beno's Avatar
Senior Member
 
Join Date: Aug 2006
Location: London
Posts: 360
Beno is on a distinguished road
What do I need to do to change this code so the orders are only opened when all three indicators are in sync either uptrend (Blue) or downtrend (Red) manually this works well and is simple enough for me to follow LOL.

I have use an old ea as a template and tried to add the indis to create the right signals. at the moment orders are opened with either the TM or the HAS.

I have attached the ea and performance for the last couple of days I know it does not mean squat but it has potential. IMO

Could someone please point me in the right direction.

Cheers

Beno
Attached Images
File Type: gif the abyss.gif (50.2 KB, 109 views)
File Type: gif DetailedStatement.gif (5.5 KB, 101 views)
Attached Files
File Type: mq4 The Abyss.mq4 (10.9 KB, 15 views)
File Type: htm DetailedStatement.htm (19.6 KB, 7 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #639 (permalink)  
Old 01-23-2008, 02:25 AM
wolfe's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 722
wolfe is on a distinguished road
Is there a way to code this include function so there is NO chance that it will get "stuck" in it's loop?

Code:
int CBM(int intMagic)//CloseByMagic
{
int intOffset=0;
while(OTBM(intMagic)>0)
{
OrderSelect(intOffset,SELECT_BY_POS);
if(OrderMagicNumber()==intMagic)
{
if(OrderType()==OP_BUY) OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),999,Red);
if(OrderType()==OP_SELL) OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),999,Orange);

}
else {
intOffset++;
}
}
return(0);
}
Thanks to anyone who can help.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #640 (permalink)  
Old 01-23-2008, 03:45 AM
Senior Member
 
Join Date: Jan 2006
Posts: 1,119
omelette is on a distinguished road
Quote:
Originally Posted by wolfe View Post
Is there a way to code this include function so there is NO chance that it will get "stuck" in it's loop?

Code:
int CBM(int intMagic)//CloseByMagic
{
int intOffset=0;
int Count = OTBM(intMagic);

while(OTBM(intMagic)>0 && Count > 0)
{
OrderSelect(intOffset,SELECT_BY_POS);
if(OrderMagicNumber()==intMagic)
{
if(OrderType()==OP_BUY) OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),999,Red);
else if(OrderType()==OP_SELL) OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),999,Orange);
Count--;
}
else {
intOffset++;
}
}
return(0);
}
Thanks to anyone who can help.
Something simple like this should work.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
candle time, CHinGsMAroonCLK, coders guru, expert advisor, forex, how to code, I_XO_A_H, mechanical trading, trading

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

LinkBacks (?)
LinkBack to this Thread: http://www.forex-tsd.com/metatrader-programming/554-how-code.html
Posted By For Type Date
Need an experienced programmer? - Page 2 Post #0 Refback 09-24-2008 07:24 AM

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


All times are GMT. The time now is 09:28 AM.



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