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
  #571 (permalink)  
Old 12-13-2007, 06:50 PM
Senior Member
 
Join Date: Feb 2006
Posts: 587
Michel is on a distinguished road
Quote:
Originally Posted by Slakerz View Post
Hi guys, i've been trying to figure out how to put a StopLoss.. my EA is as below,
...
Who is this CHinGsMAroonCLK ?
As I remember, this EA is nothing else than 10p3 from elCactus, but maybe I am wrong...
Check it's thread, you will probably find what you are looking for: http://www.forex-tsd.com/expert-advi...nts-3-mq4.html
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
  #572 (permalink)  
Old 12-13-2007, 11:08 PM
Beno's Avatar
Senior Member
 
Join Date: Aug 2006
Location: London
Posts: 516
Beno is on a distinguished road
I thought I had fixed it but no.

What I am trying to do is have a comment on the chart and in the journal stating which entry condition was used to open the current position.

Has this been done before and how do you do it because I have been trying for a while now but no luck and it's not as easy as I thought.

Below is my latest attempt.

any help would be great

buysig = Long || Long2 || Long3 || Long4;
sellsig = Short || Short2 || Short3 || Short4;

closebuy=sellsig;
closesell=buysig;

if (curprof>=AccountEquity()*ProfitExit/100.0) {
exit=true;
}
if (last>0 && (Time[0]-last)/(Period()*60)>=CancelOrderBars) {
remorder=true;
}
}

void CheckForOpen() {
int res,tr;

//---- sell conditions
co=CalculateCurrentOrders(Symbol());
if(sellsig && lastsig!=-1) {
if ( Short == true)Print(" Short signal taken ");
if ( Short2 == true)Print(" Short2 signal taken ");
if ( Short3 == true)Print(" Short3 signal taken ");
if ( Short4 == true)Print(" Short4 signal taken ");
co=CalculateCurrentOrders(Symbol());
if (co==0) {
res = OpenStop(OP_SELLSTOP,LotsRisk(StopLoss), Low[shift]-OrderPipsDiff*Point, StopLoss, TakeProfit1);
}
lastsig=-1;
last=Time[0];
return;
}
//---- buy conditions
co=CalculateCurrentOrders(Symbol());
if(buysig && lastsig!=1) {
if ( Long == true) Print(" Long signal taken ");
if ( Long2 == true)Print(" Long2 signal taken ");
if ( Long3 == true) Print(" Long3 signal taken ");
if ( Long4 == true)Print(" Long4 signal taken ");
co=CalculateCurrentOrders(Symbol());
if (co==0) {
res = OpenStop(OP_BUYSTOP,LotsRisk(StopLoss), High[shift]+OrderPipsDiff*Point, StopLoss, TakeProfit1);
}
last=Time[0];
lastsig=1;
return;
}
}
bool CloseAtMarket(int ticket,double lot) {
//fault tolerant market order closing
bool bres=false; int tr;
tries=0;
while (!bres && tries<OrderTriesNumber) {
RefreshRates();
bres=OrderClose(ticket,lot,OrderClosePrice(),slipp age,White);
tries++;
tr=0; while (tr<5 && !IsTradeAllowed()) { tr++; Sleep(2000); }
}
if (!bres) Print("Error closing order : ",ErrorDescription(GetLastError()));
}

int OpenStop(int mode,double lot, double prc, int SL, int TP) {
int res,tr,col;
string mail;
double openprice,sl,tp,stlev;
tries=0;
stlev=(1+MarketInfo(Symbol(),MODE_STOPLEVEL))*Poin t;
while (res<=0 && tries<OrderTriesNumber) {
tr=0; while (tr<5 && !IsTradeAllowed()) { tr++; Sleep(2000); }
RefreshRates();
if (mode==OP_SELLSTOP) {
if (prc<=Bid-stlev) openprice=prc;
else openprice=Bid-stlev;
if (SL>0) sl=openprice+SL*Point;
if (TP>0) tp=openprice-TP*Point;

col=Red;
} else
if (mode==OP_BUYSTOP) {
if (prc>=Ask+stlev) openprice=prc;
else openprice=Ask+stlev;
if (SL>0) sl=openprice-SL*Point;
if (TP>0) tp=openprice+TP*Point;

col=Blue;
} else return;
Print(Ask," ",Bid," ",Symbol()," ",mode," ",lot," ",openprice," ",sl," ",tp," ");
res=OrderSend(Symbol(),mode,lot,openprice,slippage ,sl,tp,EAName+"_"+ MagicNumber, MagicNumber,0,col);
tries++;
}
if (res<=0) Print("Error opening pending order : ",ErrorDescription(GetLastError()));
return(res);
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
  #573 (permalink)  
Old 12-14-2007, 04:39 AM
Senior Member
 
Join Date: Sep 2007
Posts: 428
jturns23 is on a distinguished road
This EA wont even compile, stoploss should be the lest of your concerns. There are 5 Variables that have random spaces in them or the first letter isn't capitalized!
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
  #574 (permalink)  
Old 12-14-2007, 05:52 AM
Member
 
Join Date: Nov 2006
Posts: 94
tiger_wong is on a distinguished road
Quote:
Originally Posted by jturns23 View Post
This EA wont even compile, stoploss should be the lest of your concerns. There are 5 Variables that have random spaces in them or the first letter isn't capitalized!
Here the fix version.
But this still can't open any position because there is no logic in the code for decide how to open long / short positions.
Attached Files
File Type: mq4 CHinGs73MAroon73CLK200_v2.6.mq4 (7.4 KB, 49 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
  #575 (permalink)  
Old 12-14-2007, 09:56 AM
Member
 
Join Date: Feb 2007
Posts: 87
BigBoppa is on a distinguished road
I would like to ask how to make an ea draw a simple line in the chart-window (like a TrailingStop). I don´t want an indikator, just the ea itself (MT4).
Is this possible?

Thank You,

Stefan
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
  #576 (permalink)  
Old 12-15-2007, 11:14 AM
Junior Member
 
Join Date: Dec 2007
Posts: 6
Slakerz is on a distinguished road
Help with this EA

Quote:
Originally Posted by Michel View Post
Who is this CHinGsMAroonCLK ?
As I remember, this EA is nothing else than 10p3 from elCactus, but maybe I am wrong...
Check it's thread, you will probably find what you are looking for: http://www.forex-tsd.com/expert-advi...nts-3-mq4.html
Ok.. so now the thing is i can'y put a stoploss for this EA.. whats the code? can help me? thanx
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
  #577 (permalink)  
Old 12-16-2007, 12:43 AM
Junior Member
 
Join Date: Apr 2007
Posts: 1
nash15 is on a distinguished road
none trading zone - code help

Hello everyone,

I trying to tweak a code but after much effort I still couldn't get it right.. if any of you guys dont mind can you have a look at this.. appreciate..

The idea is to stop the next trade if the price range is in the same zone as the previous trade. Long trade will check zone for last OPEN POSITION long trade, and short trade will check zone for last OPEN POSITION short trade.

ie. if the first LONG at 1.4000, then the second LONG will only trigger if the price move out of the zone (20 pips zone) less than 1.3990 && more than 1.4010



Thanks everyone..




//+------------------------------------------------------------------------------------------------------------------------+
//| Filter for sideways market - preventing multiple trade in similar price range and create no-trade zone |
//+------------------------------------------------------------------------------------------------------------------------+


extern int Zone1 = -10; // (lower zone)
extern int Zone2 = 10; // (upper zone)

// no trade zone between -10 and +10 from the previous trade



bool CheckZone(int type)
{
int cnt = OrdersTotal();
for (int i=0; i < cnt; i++)
{
if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
if (OrderSymbol() != Symbol()) continue;
if (OrderMagicNumber() != Magic) continue;

if (OrderType() != type) continue;

if (type == OP_BUY)
{
if( (Bid - OrderOpenPrice()) > Zone1*Point && (Bid - OrderOpenPrice()) < Zone2*Point ) return(false);
}

if (type == OP_SELL)
{
if( (OrderOpenPrice()-Ask) > Zone1*Point && (OrderOpenPrice()-Ask) < Zone2*Point ) return(false);

}
}

return (true);
}

Last edited by nash15; 12-16-2007 at 12:53 AM.
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
  #578 (permalink)  
Old 12-17-2007, 09:46 PM
arsenic786's Avatar
Senior Member
 
Join Date: Mar 2007
Posts: 156
arsenic786 is on a distinguished road
Thumbs up Resolve The EA Problem

Hello there all MQL Programmers,

Please check the following code and tell me why this is not placing the trades at my demo account. Its good EA on GJ 1m but unfortunately its not working. Can anyone fix it please and make it usable as a bug free EA.

I am thankfully in advance!
Best Regards.

//+------------------------------------------------------------------+
extern int Length1 = 3;
extern int Length2 = 10;
extern int Length3 = 16;


double Histo[];
double MaHisto[];

double up[];
double dn[];

double upMode[];
double dnMode[];

int alertBar;

int init()
{
return(0);
}

int deinit()
{
return(0);
}

int start()
{
int limit;
int counted_bars=IndicatorCounted();
if(counted_bars<0) counted_bars=0;
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;

for(int i = 0 ;i <= limit ;i++)Histo[i] = iMA(Symbol(),0,Length1,0,MODE_EMA,PRICE_CLOSE,i) - iMA(Symbol(),0,Length2,0,MODE_EMA,PRICE_CLOSE,i);

for(int j = 0 ;j <= limit ;j++)MaHisto[j] = iMAOnArray(Histo,0,Length3,0,MODE_EMA,j);

for(int m = 0 ;m <= limit ;m++)
{
if(MaHisto[m+1] <= 0 && MaHisto[m]> 0)
{
up[m] = Open[m]-(5*Point);

if(Bars > alertBar && m == 0)
{
//Alert(Symbol()+" "+Period()+" KI LONG ",Ask);
OrderSend(Symbol(),OP_BUY,0.1,Ask,3,25,15,0,0,0,Re d);
alertBar = Bars;
}
}
else if(MaHisto[m+1] >= 0 && MaHisto[m]< 0)
{
dn[m] = Open[m]+(5*Point);

if(Bars > alertBar && m == 0)
{
OrderSend(Symbol(),OP_SELL,0.1,Ask,3,25,15,0,0,0,R ed);
alertBar = Bars;
}
}
else
{
up[m] = EMPTY_VALUE;
dn[m] = EMPTY_VALUE;
}



if( MaHisto[m] > 0 )
{
upMode[m] = High[m];
dnMode[m] = Low[m];
}
else if( MaHisto[m] < 0 )
{
dnMode[m] = High[m];
upMode[m] = Low[m];
}

}
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
  #579 (permalink)  
Old 12-17-2007, 10:02 PM
Senior Member
 
Join Date: Feb 2006
Posts: 587
Michel is on a distinguished road
Quote:
Originally Posted by arsenic786 View Post
Hello there all MQL Programmers,

Please check the following code and tell me why this is not placing the trades at my demo account. Its good EA on GJ 1m but unfortunately its not working. Can anyone fix it please and make it usable as a bug free EA.

I am thankfully in advance!
Best Regards.

//+------------------------------------------------------------------+
extern int Length1 = 3;
extern int Length2 = 10;
extern int Length3 = 16;


double Histo[];
double MaHisto[];

double up[];
double dn[];

double upMode[];
double dnMode[];

int alertBar;

int init()
{
return(0);
}

int deinit()
{
return(0);
}

int start()
{
int limit;
int counted_bars=IndicatorCounted();
if(counted_bars<0) counted_bars=0;
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;

for(int i = 0 ;i <= limit ;i++)Histo[i] = iMA(Symbol(),0,Length1,0,MODE_EMA,PRICE_CLOSE,i) - iMA(Symbol(),0,Length2,0,MODE_EMA,PRICE_CLOSE,i);

for(int j = 0 ;j <= limit ;j++)MaHisto[j] = iMAOnArray(Histo,0,Length3,0,MODE_EMA,j);

for(int m = 0 ;m <= limit ;m++)
{
if(MaHisto[m+1] <= 0 && MaHisto[m]> 0)
{
up[m] = Open[m]-(5*Point);

if(Bars > alertBar && m == 0)
{
//Alert(Symbol()+" "+Period()+" KI LONG ",Ask);
OrderSend(Symbol(),OP_BUY,0.1,Ask,3,25,15,0,0,0,Re d);
alertBar = Bars;
}
}
else if(MaHisto[m+1] >= 0 && MaHisto[m]< 0)
{
dn[m] = Open[m]+(5*Point);

if(Bars > alertBar && m == 0)
{
OrderSend(Symbol(),OP_SELL,0.1,Ask,3,25,15,0,0,0,R ed);
alertBar = Bars;
}
}
else
{
up[m] = EMPTY_VALUE;
dn[m] = EMPTY_VALUE;
}



if( MaHisto[m] > 0 )
{
upMode[m] = High[m];
dnMode[m] = Low[m];
}
else if( MaHisto[m] < 0 )
{
dnMode[m] = High[m];
upMode[m] = Low[m];
}

}
return(0);
}

//+------------------------------------------------------------------+
"OrderSend(Symbol(),OP_SELL,0.1,Ask,3,25,15,0,0,0, R ed); "
You are selling at the Ask price, should be Bid.
The Comment field should be "", not 0.
25 as SL should be Bid+25*Point.
15 as TP should be Bid-15*Point.
"R ed" is not a color.
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
  #580 (permalink)  
Old 12-17-2007, 10:26 PM
arsenic786's Avatar
Senior Member
 
Join Date: Mar 2007
Posts: 156
arsenic786 is on a distinguished road
Angry

Quote:
Originally Posted by Michel View Post
"OrderSend(Symbol(),OP_SELL,0.1,Ask,3,25,15,0,0,0, R ed); "
You are selling at the Ask price, should be Bid.
The Comment field should be "", not 0.
25 as SL should be Bid+25*Point.
15 as TP should be Bid-15*Point.
"R ed" is not a color.

Thank you very much for your support!

But, I am still facing problems zero knowledge of MQL. Can you please copy paste the code in mq4 file and test it on demo and then tell me if it works fine. Your support will be counted as Kindest Help Michel.

Best Regards,
Kashif.
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 (0 members and 2 guests)
 
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 09:01 AM.



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