Forex



Go Back   Forex Trading > Programming > MetaTrader
Forex Forum Register More recent Blogs Calendar Advertising Others Help






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.

Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
  • Elite Section
    Get access to private discussions, specialized support, indicators and trading systems reported every week.
  • Advanced Elite Section
    For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
See more

Reply
Thread Tools Display Modes
  #1971 (permalink)  
Old 08-06-2009, 05:45 AM
Senior Member
 
Join Date: Apr 2008
Location: Rawalpindi
Posts: 106
arshadFX is on a distinguished road
Quote:
Originally Posted by toiii View Post
whoa..
thanks guys..
how about buy stop and sell stop?
just change "BUY" over there?
just want 2 positions only for 1 pairs, not more than that..
sorry, still newbie..
Read this
MQL4 Tutorial
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!
Reply With Quote
  #1972 (permalink)  
Old 08-06-2009, 07:40 AM
Junior Member
 
Join Date: May 2009
Posts: 9
liew_stanley is on a distinguished road
Is this correct coding ?

extern double TakeProfit=100;
extern double Lots=1;
extern double TrailingStop=35;

extern int ShortEma = 5;
extern int LongEma = 34;

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

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

int Crossed (double line1 , double line2)
{
static int last_direction = 0;
static int current_direction = 0;

if(line1>line2)current_direction = 1; //up
if(line1<line2)current_direction = 2; //down



if(current_direction != last_direction) //changed
{
last_direction = current_direction;
return (last_direction);
}
else
{
return (0);
}
}


//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
int total;
double shortEma, longEma;
shortEma = iCustom(NULL,0,"Test_Demo",13,0,0);
longEma = iCustom(NULL,0,"Test_Demo",54,0,0);
Print("shortEma = " + shortEma + " : longEma = " + longEma);

int isCrossed = 0;
isCrossed = Crossed (LongEma,ShortEma);

total = OrdersTotal();
if(total < 1)
{
if(isCrossed == 1)
{
1=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeP rofit*Point,"My EA",12345,0,Green);
if(1>0)
{
if(OrderSelect(1,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
return(0);
}
if(isCrossed == 2)
{

2=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point,"My EA",12345,0,Red);
if(2>0)
{
if(OrderSelect(2,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
}
else Print("Error opening SELL order : ",GetLastError());
return(0);
}
return(0);
}
}



i've got an error saying 1 & 2 unexpected token, what is that mean ? can guide me ?

Thanks
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!
Reply With Quote
  #1973 (permalink)  
Old 08-06-2009, 07:51 AM
Senior Member
 
Join Date: Oct 2008
Location: Vancouver, BC
Posts: 158
Roger09 is on a distinguished road
I guess you deleted something and forgot:
Code:
2=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point,"My EA",12345,0,Red);
if(2>0)
it's nonsense.
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!
Reply With Quote
  #1974 (permalink)  
Old 08-06-2009, 07:58 AM
Senior Member
 
Join Date: Apr 2008
Location: Rawalpindi
Posts: 106
arshadFX is on a distinguished road
Quote:
Originally Posted by liew_stanley View Post
extern double TakeProfit=100;
extern double Lots=1;
extern double TrailingStop=35;

i've got an error saying 1 & 2 unexpected token, what is that mean ? can guide me ?

Thanks
Delete 1=, and 2= before OrderSend(....
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!
Reply With Quote
  #1975 (permalink)  
Old 08-06-2009, 10:50 AM
dr.house7's Avatar
Senior Member
 
Join Date: Apr 2009
Location: Italy
Posts: 186
dr.house7 is on a distinguished road
Wink

Quote:
Originally Posted by arshadFX View Post
1, add bool flag after trading criteria triggered
2, check bool flag before placing order
3, after placing order bool flag should be reset
4, reset the flag in init() too
Thanks man
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!
Reply With Quote
  #1976 (permalink)  
Old 08-06-2009, 12:41 PM
Junior Member
 
Join Date: May 2009
Posts: 9
liew_stanley is on a distinguished road
MQL Guide needed =^_^=

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 White
#property indicator_color2 White

extern int Fast.MA.Period = 5;
extern int Slow.MA.Period = 34;
extern int Signal.period = 5;

//---- buffers
double Buffer1[],
Buffer2[],
b2[],
b3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators

// two additional buffers used for counting

IndicatorBuffers(4);


IndicatorShortName("MA3_54");

SetIndexStyle(0,DRAW_ARROW,STYLE_SOLID,3);
SetIndexArrow(0,242); // down 226 234 242
SetIndexBuffer(0,b2);

SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID,3);
SetIndexArrow(1,241); //UP 225 233 241
SetIndexBuffer(1,b3);

// These buffers are not plotted, just used to determine arrows

SetIndexBuffer (2,Buffer1);
SetIndexBuffer (3,Buffer2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{


//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int i, counted_bars=IndicatorCounted();
double MA5,MA34;
int limit=Bars-counted_bars;
Print(" print limit = ", limit);
if(counted_bars>0) limit++;


// Main line
for(i=0; i<limit; i++)
{
MA5=iMA(NULL,0,Fast.MA.Period,0,MODE_SMA,PRICE_MED IAN,i);
MA34=iMA(NULL,0,Slow.MA.Period,0,MODE_SMA,PRICE_ME DIAN,i);

Buffer1[i]=MA5-MA34;
}

// Signal line

for(i=0; i<limit; i++)
{
Buffer2[i]=iMAOnArray(Buffer1,Bars,Signal.period,0,MODE_LWMA ,i);
}

// Arrows

for(i=0; i<limit; i++)
{
if(Buffer1[i] > Buffer2[i] && Buffer1[i-1] < Buffer2[i-1])
b2[i] = High[i]+10*Point;
if(Buffer1[i] < Buffer2[i] && Buffer1[i-1] > Buffer2[i-1])
b3[i] = Low[i]-10*Point;
}

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

Can you teach me how to create EA based on this indis ? when the arrow appear on the screen and that's the time EA auto enter position, can it be done ? please guide me as i'm keen in learning =^_^=
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!
Reply With Quote
  #1977 (permalink)  
Old 08-06-2009, 01:01 PM
Senior Member
 
Join Date: Apr 2008
Location: Rawalpindi
Posts: 106
arshadFX is on a distinguished road
Good Reference

Quote:
Originally Posted by liew_stanley View Post
#property indicator_chart_window
#property indicator_buffers 2
............guide me as i'm keen in learning =^_^=
See this guide really good material MQL4 Tutorial
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!
Reply With Quote
  #1978 (permalink)  
Old 08-06-2009, 01:07 PM
Junior Member
 
Join Date: May 2009
Posts: 9
liew_stanley is on a distinguished road
The indis looks like this

Here is the above mentioned arrow signal, need someone to guide me on the EA coding

Thanks anyone out there =^_^=
Attached Images
File Type: jpg untitled.JPG (80.0 KB, 59 views)
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!
Reply With Quote
  #1979 (permalink)  
Old 08-06-2009, 05:40 PM
Junior Member
 
Join Date: May 2009
Posts: 9
liew_stanley is on a distinguished road
Can anyone help me code this into a simple EA ?

Hi guys, can anyone help me code this indis into EA ? Only a simple EA that enter position when the arrows appear on the screen, very much appreciated if could help me on a simple EA. =^_^= thanks

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 White
#property indicator_color2 White

extern int Fast.MA.Period = 5;
extern int Slow.MA.Period = 34;
extern int Signal.period = 5;

//---- buffers
double Buffer1[],
Buffer2[],
b2[],
b3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators

// two additional buffers used for counting

IndicatorBuffers(4);


IndicatorShortName("Elliott Wave Oscillator");

SetIndexStyle(0,DRAW_ARROW,STYLE_SOLID,3);
SetIndexArrow(0,242); // down 226 234 242
SetIndexBuffer(0,b2);

SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID,3);
SetIndexArrow(1,241); //UP 225 233 241
SetIndexBuffer(1,b3);

//

SetIndexBuffer (2,Buffer1);
SetIndexBuffer (3,Buffer2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int i, counted_bars=IndicatorCounted();
double MA5,MA34;
int limit=Bars-counted_bars;
Print(" print limit = ", limit);
if(counted_bars>0) limit++;


// Main line
for(i=0; i<limit; i++)
{
MA5=iMA(NULL,0,Fast.MA.Period,0,MODE_SMA,PRICE_MED IAN,i);
MA34=iMA(NULL,0,Slow.MA.Period,0,MODE_SMA,PRICE_ME DIAN,i);

Buffer1[i]=MA5-MA34;
}

// Signal line

for(i=0; i<limit; i++)
{
Buffer2[i]=iMAOnArray(Buffer1,Bars,Signal.period,0,MODE_LWMA ,i);
}

// Arrows

for(i=0; i<limit; i++)
{
if(Buffer1[i] > Buffer2[i] && Buffer1[i-1] < Buffer2[i-1])
b2[i] = High[i]+10*Point;
if(Buffer1[i] < Buffer2[i] && Buffer1[i-1] > Buffer2[i-1])
b3[i] = Low[i]-10*Point;
}

//----
return(0);
}
//+------------------------------------------------------------------+
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!
Reply With Quote
  #1980 (permalink)  
Old 08-07-2009, 06:05 AM
Member
 
Join Date: Jul 2006
Location: Denver, Colorado
Posts: 51
AirforceMook is on a distinguished road
Multi-Order code?

Does anyone have good code for trading multiple orders when running up against the maxlot barrier?

IE Broker only allows lots of 5, and you want to trade 10, so the function will trade 2 x 5 lot orders instead.

I'm looking for more than just a simple loop here. The problem is that a simple loop will not always fully complete, and you could be left with only a partial order open.
__________________
//AirforceMook//
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!
Reply With Quote
Reply

Bookmarks

Tags
#include, candle time, CHinGsMAroonCLK, code, coders guru, conditionally, dll, eli hayun, Eur_harvester.ex4, expert adviser, expert advisor, forex, higher high, how to code, indicator, I_XO_A_H, kehedge, mechanical trading, metatrader command line, mt4, MT4-LevelStop-Reverse, OrderReliable.mqh, programming, rectangle tool, trading, volty channel stop


Currently Active Users Viewing This Thread: 2 (1 members and 1 guests)
360648
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
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 04:01 PM.



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