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
  #701 (permalink)  
Old 02-18-2008, 06:04 PM
fxgrm's Avatar
Member
 
Join Date: Mar 2007
Posts: 91
fxgrm is on a distinguished road
Question Thanks Much Devil2000!

Quote:
Originally Posted by Devil2000 View Post
From the metaeditor:
Code:
bool IsDemo()
Returns TRUE if the expert runs on a demo account, otherwise returns FALSE.
Now can you tell me where to place this code?

I'm a real rookie at this stuff.

This is what shows up in Meta Editor:



extern double lot=0.01;
extern int MinGS=10;
extern double TP=10;
extern double MarginLevelAlert=1000;
extern double RepeatMinutes=60;
double MaxDrawDown = 0.0;
int magic;
int Account = 1857842;
double lot2;
double MarginPer;
datetime tob,tos,toe; //Time Out Buy, Sell, Expire



Appreciate the help.

Cheers

Last edited by fxgrm; 02-18-2008 at 06:13 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #702 (permalink)  
Old 02-18-2008, 08:00 PM
Junior Member
 
Join Date: Dec 2007
Location: Poland, Warsaw
Posts: 6
janekpietrzyk is on a distinguished road
MaOnArray

Hi,
it would like to go long if the CCI goes above it's 14 sma, and go short when it goes below it's 14 sma. The CCI's sma is generated by the MaOnArray of the CCI of course.
This is my piece of code:

double a,b;

bla, bla, bla...

int start()
{


a= iCCI(NULL, 0, 14,PRICE_WEIGHTED,0);

b=iMAOnArray(a,0,14,0,MODE_SMA,0);



// check for long position (BUY) possibility

if(NewBar1()==true && a>b)
{

bla, bla, bla...


// check for short position (SELL) possibility

if(NewBar2()==true && a<b)
{


bla, bla, bla...

There is a problem however (it's pictured below) - so is there something that's missing in the code? and how can this problem be solved?
Problem is below:
Attached Images
File Type: jpg 1.JPG (128.2 KB, 85 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #703 (permalink)  
Old 02-19-2008, 03:41 AM
Member
 
Join Date: Oct 2006
Posts: 71
Big Be is on a distinguished road
Two Stops Question

See later post.

Last edited by Big Be; 02-19-2008 at 04:04 AM. Reason: To change sequence
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #704 (permalink)  
Old 02-19-2008, 04:00 AM
Member
 
Join Date: Oct 2006
Posts: 71
Big Be is on a distinguished road
MaOnArray

Jane,
First, you need to control how many trades open.
I suggest adding
if (OrdersTotal()==0) {
before entry filters, or maybe <= 1, for 2 orders allowed.

Or if you want more than two trades at a time:
for (int i = OrdersTotal() - 1; i >= 0;i--)
(Study most EAs for this one.)

I don't think you have given enough data for one to solve it, but I have a couple more suggestions.

It is not clear what NewBar1() does and how.

Make sure your global variables are re-set as needed after an order is opened (or closed, if applicable).
I write a line for each necessary variable after the open order line.

Good hunting!

Big Be
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #705 (permalink)  
Old 02-19-2008, 04:04 AM
Member
 
Join Date: Oct 2006
Posts: 71
Big Be is on a distinguished road
Two Stops Question

I need to know how to change the Stop for HALF of my open order. My understanding is that this means opening two orders, for example .2 lots and .2 lots.

My EA bases the number of lots on a Money Management calculation.

After the stop for one order is changed (based on a price level being reached) then I would let my exit code close both orders, unless their (now different) stops are hit.

The other order retains its original stop or possibly moves it up to Break Even.

If the initial quantity of lots (from the MM function) Is odd, instead of rounding down for an odd number of lots or tenth lots, I would like to split them unevenly between the two orders.

I believe this involves Magic Numbers, and a couple lines of code here and there. Maybe there is an EA with all this that I could copy from.

Thanks for any help.

Big Be
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #706 (permalink)  
Old 02-19-2008, 07:11 AM
Junior Member
 
Join Date: Dec 2007
Location: Poland, Warsaw
Posts: 6
janekpietrzyk is on a distinguished road
OK, thanks Big Me,

I'll post the whole EA tommorow. So U can be able to take a look at it.

regards,
J
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #707 (permalink)  
Old 02-19-2008, 09:00 AM
Senior Member
 
Join Date: Jan 2006
Posts: 1,119
omelette is on a distinguished road
Quote:
Originally Posted by Big Be View Post
I need to know how to change the Stop for HALF of my open order. My understanding is that this means opening two orders, for example .2 lots and .2 lots.

My EA bases the number of lots on a Money Management calculation.

After the stop for one order is changed (based on a price level being reached) then I would let my exit code close both orders, unless their (now different) stops are hit.

The other order retains its original stop or possibly moves it up to Break Even.

If the initial quantity of lots (from the MM function) Is odd, instead of rounding down for an odd number of lots or tenth lots, I would like to split them unevenly between the two orders.

I believe this involves Magic Numbers, and a couple lines of code here and there. Maybe there is an EA with all this that I could copy from.

Thanks for any help.

Big Be
Wouldn't it be a whole lot simpler to just open 1 order and scale out of that, adjusting a 'soft' SL on the remainder. You could place a Doomsday hard-stop just in case. Not only is it far easier, you are also not giving the bucketshops something to 'aim' at.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #708 (permalink)  
Old 02-19-2008, 01:28 PM
Member
 
Join Date: Jan 2006
Posts: 30
DooMGuarD is on a distinguished road
Symbol in broker

hi all

i need to obtain all symbols in MetaTrade... How to code?

regards

charles
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #709 (permalink)  
Old 02-19-2008, 05:05 PM
Member
 
Join Date: Oct 2006
Posts: 71
Big Be is on a distinguished road
Re: Two Stops Question

Quote:
Originally Posted by omelette View Post
Wouldn't it be a whole lot simpler to just open 1 order and scale out of that, adjusting a 'soft' SL on the remainder. You could place a Doomsday hard-stop just in case. Not only is it far easier, you are also not giving the bucketshops something to 'aim' at.
Simpler, but less profitable for me. My EA rides a trend and I want both halves to have the chance to go all the way. Do you know how?

Big Be
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #710 (permalink)  
Old 02-19-2008, 11:17 PM
Junior Member
 
Join Date: Feb 2008
Location: Florida
Posts: 1
whammo is on a distinguished road
Help with EA errors

Hi, I need help with the following EA. This is my frist EA so be (gentle) please.
When I compile the file I get two warning (s) that both read:
'TotalOpenOpenOrders'-expression on global scope not allowed
This warning come after the word Max in the file.
// init variable when the expert advisor first starts running
if (init_variables == true)
{
PreviousBar = Time[0]; // record the current candle/bar open time
// place code here that you only want to run one Time
init_variables = false; // change to false so we only init
// variable once
}
// perform analysis and open orders on new candle/Bars
if(NewBar() == true)
{
// only perform analysis and close order if we only have one order Open
if(TotalOpenOrders() == Total_Open_Orders && SelectTheOrder() == True)
{
if(OrderType() == OP_BUY && TrendDetection() == BEAR)
{
OrderClose(OrderTicket(),OrderLots(),Bid,Slippage, Order_Arrow_Color);
}
if(OrderType() == OP_SELL && TrendDetection() == BULL)
{
OrderClose(OrderTicket(),OrderLots(),Ask,Slippage, Order_Arrow_Color);
}

}

// only perform analysis and open new order if we have not reached
// our Total_Open_Orders Max
if(TotalOpenOrders() < Total_Open_Orders)
{

// open buy
if(TrendDetection() == BULL)
{
// open Order

OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Stop_L oss*Point,Take_Profit
*Point,Order_Comment,Magic,0,Order_Arrow_Color);

}

//open sell
if(TrendDetection() == BEAR)
{



// open Order

OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,Stop_ Loss*Point,Take_Profit
*Point,Order_Comment,Magic,0,Order_Arrow_Color);

}
}

// when back testing only display chart info every
// candle/bar sowe do not slow down back tests
if(IsTesting() == true)

{

Display_Info();
}
}

// when not back testing display chart info every tick
if(IsTesting() == false)

{
Display_Info();
}

return(0);
}
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 11:59 AM.



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