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
  #461 (permalink)  
Old 11-03-2007, 05:03 PM
Senior Member
 
Join Date: Mar 2006
Location: La Verne,CA
Posts: 560
MrPip is on a distinguished road
Beno,
You could use code similar to above post for not trading. Just check if current day is the number of days later for closing from the open day. The code could be modified to use hours or minutes as well.

Another way would be to calculate the time to close the trade as exit_time when the trade is open. Then to exit just check the exit_time in your check exit code.

You would need to use the proper formula to add the correct value to the open time to obtain the close time. This would use the number of minutes per bar * the number of bars later to close added to the OrderOpenTime().

Hope this helps.

Robert

Quote:
Originally Posted by Beno View Post
Gidday

I am looking for some help I can't seem to work out how to exit a position in a certian number of bars/days. eg I go long on monday and the system exits on the close 5 bars/days later.

Any help would be good


Cheers

Beno
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
  #462 (permalink)  
Old 11-03-2007, 05:13 PM
Beno's Avatar
Senior Member
 
Join Date: Aug 2006
Location: London
Posts: 516
Beno is on a distinguished road
Thanks MrPip

I mostly get where you are coming from, I will give it ago and ask again if I get stuck.

cheers
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
  #463 (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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #464 (permalink)  
Old 11-04-2007, 09:48 PM
Beno's Avatar
Senior Member
 
Join Date: Aug 2006
Location: London
Posts: 516
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #465 (permalink)  
Old 11-05-2007, 06:23 AM
Member
 
Join Date: Feb 2006
Posts: 63
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #466 (permalink)  
Old 11-05-2007, 01:14 PM
yyc196's Avatar
Senior Member
 
Join Date: Dec 2006
Location: Earth
Posts: 198
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, 27 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
  #467 (permalink)  
Old 11-05-2007, 08:41 PM
Beno's Avatar
Senior Member
 
Join Date: Aug 2006
Location: London
Posts: 516
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, 54 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
  #468 (permalink)  
Old 11-05-2007, 08:58 PM
Senior Member
 
Join Date: Mar 2006
Location: La Verne,CA
Posts: 560
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #469 (permalink)  
Old 11-05-2007, 09:01 PM
Beno's Avatar
Senior Member
 
Join Date: Aug 2006
Location: London
Posts: 516
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #470 (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!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: 1 (0 members and 1 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 10:24 AM.



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