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
  #461 (permalink)  
Old 11-04-2007, 11:40 AM
Senior Member
 
Join Date: Oct 2006
Posts: 104
antone is on a distinguished road
Quote:
Originally Posted by MrPip View Post
Corrections in Red below.

Robert

Thank you Robert.. that helped..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #462 (permalink)  
Old 11-04-2007, 09:48 PM
Beno's Avatar
Senior Member
 
Join Date: Aug 2006
Location: London
Posts: 361
Beno is on a distinguished road
Can anybody see the error? I can't see where the error is in this code. I keep getting. Any help in pointing this out would be great. Thanks

LongSig Variable not defined

//+------------------------------------------------------------------+
//| Calculate open positions |
//+------------------------------------------------------------------+
int CalculateCurrentOrders() {
buys=0; sells=0;
string symbol=Symbol();
//----
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false ) continue;
if(OrderSymbol()==Symbol() && OrderMagicNumber()==expertId)
{
if(OrderType()==OP_BUY || OrderType()==OP_BUYSTOP) buys++;
if(OrderType()==OP_SELL || OrderType()==OP_SELLSTOP) sells++;
}
}
//---- return orders volume
if(buys>0) return(buys);
else return(-sells);
}

//+------------------------------------------------------------------+
//| Check for open order conditions |
//+------------------------------------------------------------------+
void CheckForSignals() {

buysig=false;
sellsig=false;
closebuy=false;
closesell=false;



double MOM = iCustom (NULL,0,"Momentum-ZL",MOMPeriod,0,shift);
double SRL = iCustom (NULL,0,"MT4-LevelStop-Reverse-vBO-4",UseATRMode,NonATRStopPips,ATRPeriod, ATRMultiplier,ATRSmoothing,UpArrowColor,DnArrowCol or,ArrowDistance,233);
double SRS = iCustom (NULL,0,"MT4-LevelStop-Reverse-vBO-4",UseATRMode,NonATRStopPips,ATRPeriod, ATRMultiplier,ATRSmoothing,UpArrowColor,DnArrowCol or,ArrowDistance,234);
double QQE_RsiMa = iCustom(NULL,0,"QQE",0,shift);
double QQE_TrLevelSlow = iCustom(NULL,0,"QQE", 1, shift);
double QQE_RsiMaPrev = iCustom(NULL,0,"QQE",0,shift + 1);
double QQE_TrLevelSlowPrev = iCustom(NULL,0,"QQE", 1, shift + 1);
double Pivot = iCustom (NULL,0,"Pivot Points Multitimeframe",midpivots,Fhr,daily,weekly,monthly ,1,shift)



bool LongSig = QQE_RsiMaPrev < QQE_TrLevelSlowPrev && QQE_RsiMa > QQE_TrLevelSlow >50.0;
bool ShortSig = QQE_RsiMaPrev > QQE_TrLevelSlowPrev && QQE_RsiMa < QQE_TrLevelSlow<50.0;
bool LongSig2 = MOM>0.0;
bool ShortSig2 = MOM<0.0;
bool LongSig3 = SRL>Pivot;
bool ShortSig3 = SRS<Pivot;

buysig = LongSig && LongSig2 && LongSig3;
sellsig = ShortSig && ShortSig2 && ShortSig3;

closebuy=sellsig;
closesell=buysig;

}
void CheckForOpen() {

if (last==Time[0]) return;

int res,ord;
double entry,stop,profit;

ord=CalculateCurrentOrders();

if (ord!=0) CheckForClose();

ord=CalculateCurrentOrders();

//---- buy conditions
if (buys<ConsecutiveTrades && buysig) {
res=OpenAtMarket(OP_BUY,Lots);
if (res<0) Print("Error opening BUY order : ",ErrorDescription(GetLastError()));
else last=Time[0];
}
//---- sell conditions
if (-sells<ConsecutiveTrades && sellsig) {
res=OpenAtMarket(OP_SELL,Lots);
if (res<=0) Print("Error opening SELL order : ",ErrorDescription(GetLastError()));
else last=Time[0];
}
}

int OpenAtMarket(int mode,double lot) {
int res,tr,col;
double openprice,sl,tp;
tries=0;
while (res<=0 && tries<OrderTriesNumber) {
tr=0; while (tr<5 && !IsTradeAllowed()) { tr++; Sleep(2000); }
RefreshRates();
if (mode==OP_SELL) {
openprice=Bid;
col=Red;
} else {
//openprice=nd(Ask);
openprice=Ask;
col=Blue;
}
res=OrderSend(Symbol(),mode,lot,openprice,slippage ,sl,tp,EAName+expertId,expertId,0,col);
tries++;
}
return(res);
}


Fixed IT

Last edited by Beno; 11-05-2007 at 08:43 PM. Reason: Sorted it out
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #463 (permalink)  
Old 11-05-2007, 06:23 AM
Member
 
Join Date: Feb 2006
Posts: 53
icm63 is on a distinguished road
Bar count down with MTF indictaors

MTF = multi time frame indicators

double BarCountDownInSec()
{
double g;
g=Time[0]+Period()*60-TimeCurrent();
return(g);
}

The above function gives the second count down for bars in the current chart. So if placed on a 5 min chart, it will show second count down for each 5 min bar.

Q: How do I get seconds count down for a 15 minute bar (ie 3x 5 min bars), when I am in a 5 min chart, so a count down of 15 minutes from 6.00 to 6.15. then 6.15 to 6.30, while I am in a 5 min chart ???
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #464 (permalink)  
Old 11-05-2007, 01:14 PM
yyc196's Avatar
Senior Member
 
Join Date: Dec 2006
Location: Earth
Posts: 197
yyc196 is on a distinguished road
Unhappy Problem with my programming (BUG)

Hi,

Can someone help to clear the bug for me. I was almost there just that the draw histogram don't appears unless i conpile the code again.

Please help!!! Please Please Please

Regards
Attached Files
File Type: mq4 Stoch_Project.mq4 (4.4 KB, 13 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #465 (permalink)  
Old 11-05-2007, 08:41 PM
Beno's Avatar
Senior Member
 
Join Date: Aug 2006
Location: London
Posts: 361
Beno is on a distinguished road
icustom problem

What is the string name of this indi that I should use for an iCustom part of an EA
I have tried
MT4-LevelStop-Reverse-vBO-4
MT4-LevelStop-Reverse-
MT4-LevelStop-Reverse
vBO-4
vB0.4
vtsbh2483-
MT4-LevelStop-Reverse-" + INDICATOR_VERSION + "(

So I have no idea what to do next.

or do I need to put in the ATRMode,Manual Mode etc String Names

Any help would be great
Attached Files
File Type: mq4 MT4-LevelStop-Reverse-vB0-4.mq4 (11.7 KB, 26 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #466 (permalink)  
Old 11-05-2007, 08:58 PM
Senior Member
 
Join Date: Mar 2006
Location: La Verne,CA
Posts: 556
MrPip is on a distinguished road
Try the first on your list with a number zero 0 instead of a letter O for vB0-4.
Robert

Quote:
Originally Posted by Beno View Post
What is the string name of this indi that I should use for an iCustom part of an EA
I have tried
MT4-LevelStop-Reverse-vBO-4
MT4-LevelStop-Reverse-
MT4-LevelStop-Reverse
vBO-4
vB0.4
vtsbh2483-
MT4-LevelStop-Reverse-" + INDICATOR_VERSION + "(

So I have no idea what to do next.

or do I need to put in the ATRMode,Manual Mode etc String Names

Any help would be great
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #467 (permalink)  
Old 11-05-2007, 09:01 PM
Beno's Avatar
Senior Member
 
Join Date: Aug 2006
Location: London
Posts: 361
Beno is on a distinguished road
Thanks Mr Pips

Sorted it
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #468 (permalink)  
Old 11-06-2007, 07:29 AM
Senior Member
 
Join Date: Oct 2006
Posts: 104
antone is on a distinguished road
Quote:
Originally Posted by MrPip View Post
Corrections in Red below.

Robert
i tried this but it seems not to work.. i only want one trade per day..

Quote:
for(int a=0;a<OrdersTotal();a++)
{
if (OrderSelect(a,SELECT_BY_POS,MODE_TRADES) == true)
{
if (OrderSymbol()== Symbol() && OrderMagicNumber()== Magic_Number)
{
if (TimeDay(OrderOpenTime()) >= TimeDay(TimeCurrent())) Trade = false;
if (TimeDay(OrderOpenTime()) < TimeDay(TimeCurrent())) Trade = true;
}
}
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #469 (permalink)  
Old 11-06-2007, 10:16 AM
Senior Member
 
Join Date: Mar 2006
Location: La Verne,CA
Posts: 556
MrPip is on a distinguished road
Quote:
Originally Posted by antone View Post
i tried this but it seems not to work.. i only want one trade per day..
I have used this in other EAs and it works correctly.
I check for trade closed today instead of open today.

Usage in start is

if (LastTradeClosedToday()) return(0);

// code here to open new trades


//+------------------------------------------------------------------+
//| LastTradeClosedToday |
//| Check History to see if last trade closed today |
//+------------------------------------------------------------------+

bool LastTradeClosedToday()
{
int cnt, total;
bool Closed;


total = HistoryTotal();
for (cnt = total - 1; cnt >= 0; cnt--)
{
OrderSelect (cnt, SELECT_BY_POS, MODE_HISTORY);

if(OrderSymbol()!=Symbol()) continue;
if (OrderMagicNumber() != MagicNumber) continue;

Closed = false;
if (OrderType() == OP_BUY)
{
if (TimeDay(OrderCloseTime()) == TimeDay(TimeCurrent()))
{
Closed = true;
}
cnt = 0;
}
if (OrderType() == OP_SELL)
{
if (TimeDay(OrderCloseTime()) == TimeDay(TimeCurrent()))
{
Closed = true;
}
cnt = 0;
}

}

return (Closed);
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #470 (permalink)  
Old 11-06-2007, 01:00 PM
Senior Member
 
Join Date: Oct 2006
Posts: 104
antone is on a distinguished road
Quote:
Originally Posted by MrPip View Post
I have used this in other EAs and it works correctly.
I check for trade closed today instead of open today.

Usage in start is

if (LastTradeClosedToday()) return(0);

// code here to open new trades


//+------------------------------------------------------------------+
//| LastTradeClosedToday |
//| Check History to see if last trade closed today |
//+------------------------------------------------------------------+

bool LastTradeClosedToday()
{
int cnt, total;
bool Closed;


total = HistoryTotal();
for (cnt = total - 1; cnt >= 0; cnt--)
{
OrderSelect (cnt, SELECT_BY_POS, MODE_HISTORY);

if(OrderSymbol()!=Symbol()) continue;
if (OrderMagicNumber() != MagicNumber) continue;

Closed = false;
if (OrderType() == OP_BUY)
{
if (TimeDay(OrderCloseTime()) == TimeDay(TimeCurrent()))
{
Closed = true;
}
cnt = 0;
}
if (OrderType() == OP_SELL)
{
if (TimeDay(OrderCloseTime()) == TimeDay(TimeCurrent()))
{
Closed = true;
}
cnt = 0;
}

}

return (Closed);
}
ok i will try.. thanks mr pips.. your of great help..
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


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 04:44 AM.



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