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
  #1011 (permalink)  
Old 06-10-2008, 03:18 PM
Junior Member
 
Join Date: Jun 2008
Posts: 9
panteraschoice is on a distinguished road
Quote:
Originally Posted by Kalenzo View Post
Maybe you got new prices from broker, try to use RefreshRates function before OrderClose if you will get error.
yes, thank you!
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
  #1012 (permalink)  
Old 06-10-2008, 03:20 PM
IN10TION's Avatar
Senior Member
 
Join Date: Mar 2007
Posts: 651
Blog Entries: 1
IN10TION is on a distinguished road
depending on what the iCustom indicators are sending out...

double buyvaluecurrent = iCustom(indicator1);
double buyvaluecurrent2 = iCustom(indicator2);
double sellvaluecurrent = iCustom(indicator1);

int trenendvup = iCustom(indicator3);

so...

if((buyvaluecurrent !=0 && buyvaluecurrent2 !=0) && (trendenvup !=0)) {buycondition=0;}

if((buyvaluecurrent !=0 && buyvaluecurrent2 !=0) && (trendenvup !=1)) {buycondition=1;}


you can't get a bool into your buycondition only by using "&&" and some conditions, use if() function...

hope this helps, otherwise it's a little step closer


Quote:
Originally Posted by payback View Post
no i don't want to publish all but i think is a problem with the types match of variables i'll try to explain more

indicator1 e 2 are double right

so i have buyvaluecurrent = icustom(indicator1 etc etc);
buyvaluecurrent2 = icustom(indicator2 etc etc);
sellvaluecurrent = icustom(indicator1 etc etc); //doubles right?
trenendvup =icustom (indicator3 etc etc) ; //int
and so on

so buycondition= ((buyvaluecurrent !=0 && buyvaluecurrent2 !=0) && (trendenvup != Empty_Value);

this statment works only sometimes and also could be a problem, so my question is why? i want that buycondition returns 1 or 0 no matter of what type is bool or double
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
  #1013 (permalink)  
Old 06-10-2008, 05:26 PM
Member
 
Join Date: May 2008
Posts: 31
payback is on a distinguished road
mmmm please explain more about this
also i tried boolean and if() but at a first look didn't work
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
  #1014 (permalink)  
Old 06-10-2008, 05:55 PM
IN10TION's Avatar
Senior Member
 
Join Date: Mar 2007
Posts: 651
Blog Entries: 1
IN10TION is on a distinguished road
I can't explain more if I don't see more...
but you have to follow the basics...


double a=iCustom(indiA);
double b=iCustum(indiB);
double c=iCustom(indiC);

int ORDer=0;

if( a==1 && b>0 && c!=0 ) ORDer=1;
if( a==-1 && b<0 && c!=0 ) ORDer=-1;

if(ORDer==1) BUY();
if(ORDer==-1) SELL();


Quote:
Originally Posted by payback View Post
mmmm please explain more about this
also i tried boolean and if() but at a first look didn't work
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
  #1015 (permalink)  
Old 06-10-2008, 07:00 PM
Member
 
Join Date: May 2008
Posts: 31
payback is on a distinguished road
ok ok ok!
here is more!
PHP Code:
double
         BuyValueCurrent
,
         
SellValuePrevious,
         
SellValueCurrent,
         
         
BuyValuePrevious2,
         
BuyValueCurrent2,
         
SellValuePrevious2,
         
SellValueCurrent2,
         
BuyValueCurrent1min,
         
BuyValueCurrent5min,
         
BuyValueCurrent21min,
         
BuyValueCurrent25min,
         
SellValueCurrent1min,
         
SellValueCurrent5min,
         
SellValueCurrent21min,
         
SellValueCurrent25min,
         
         
TrendEnvUp,
         
TrendEnvDown,
         
TrendEnvUp1min,
         
TrendEnvUp5min,
         
TrendEnvDown1min,
         
TrendEnvDown5min,
         
        
Compra,
         
Vendi,
         
StopLong,
         
StopSell

the icustom funcions and buy sell

PHP Code:

 BuyValuePrevious  
iCustom(NULL,TimeFrame,IndicatorName1,NumBars,0,2);
   
BuyValueCurrent iCustom(NULL,0,IndicatorName1,NumBars,1,0);  
   
   
BuyValuePrevious2  iCustom(NULL,TimeFrame,IndicatorName2,NumBars,0,2);  
   
BuyValueCurrent2 iCustom(NULL,0,IndicatorName2,NumBars,0,0);  
   
   
SellValuePrevious iCustom(NULL,TimeFrame,IndicatorName1,NumBars,1,2);
   
SellValueCurrent  iCustom(NULL,0,IndicatorName1,NumBars,0,0);
   
   
SellValuePrevious2 iCustom(NULL,TimeFrame,IndicatorName1,NumBars,1,2);  
   
SellValueCurrent2 iCustom(NULL,0,IndicatorName2,NumBars,1,0);  
   
   
BuyValueCurrent1min iCustom(NULL,1,IndicatorName1,NumBars,1,0);
   
BuyValueCurrent5min iCustom(NULL,5,IndicatorName1,NumBars,1,0);
   
BuyValueCurrent21min iCustom(NULL,1,IndicatorName2,NumBars,0,0);
   
BuyValueCurrent25min iCustom(NULL,5,IndicatorName2,NumBars,0,0);
   
SellValueCurrent1min  iCustom(NULL,1,IndicatorName1,NumBars,0,0);
   
SellValueCurrent5min  iCustom(NULL,5,IndicatorName1,NumBars,0,0);
   
SellValueCurrent21min iCustom(NULL,1,IndicatorName2,NumBars,1,0);
   
SellValueCurrent25min iCustom(NULL,5,IndicatorName2,NumBars,1,0);
   
   
   
   
TrendEnvUp         iCustom(NULL,0,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,0,0); // trendenvelopes 
   
TrendEnvDown         iCustom(NULL,0,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,1,0); // trendenvelopes 
   
TrendEnvUp1min         iCustom(NULL,1,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,0,0);
   
TrendEnvUp5min         iCustom(NULL,5,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,0,0);
   
TrendEnvDown1min         iCustom(NULL,1,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,1,0);
   
TrendEnvDown5min         iCustom(NULL,5,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,1,0);
   
   
   
   
BuyCondition    = (BuyValueCurrent !=&& BuyValueCurrent2 !=&& TrendEnvUp != EMPTY_VALUE)&& (BuyValueCurrent1min !=&& BuyValueCurrent21min !=&& TrendEnvUp1min != EMPTY_VALUE) && (BuyValueCurrent5min !=&& BuyValueCurrent25min !=&& TrendEnvUp5min != EMPTY_VALUE) ;
   
SellCondition     = (SellValueCurrent !=&& SellValueCurrent2 !=&& TrendEnvDown != EMPTY_VALUE)&& (SellValueCurrent1min != && SellValueCurrent21min != && TrendEnvDown1min != EMPTY_VALUE)&& (SellValueCurrent5min != && SellValueCurrent25min != && TrendEnvDown5min != EMPTY_VALUE) ;
   
StopLong  = ((SellValueCurrent !=&& SellValueCurrent2 !=0) || (TrendEnvDown != EMPTY_VALUE));
   
StopSell  = ((BuyValueCurrent !=&& BuyValueCurrent2 !=0) || (TrendEnvUp != EMPTY_VALUE)); 
the exit condition

PHP Code:


StopBuy  
= (SellValueCurrent !=&& SellValueCurrent2 !=|| TrendEnvDown != EMPTY_VALUE);
StopSell  = (BuyValueCurrent !=&& BuyValueCurrent2 !=|| TrendEnvUp != EMPTY_VALUE); 

Last edited by payback; 06-10-2008 at 07:03 PM.
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
  #1016 (permalink)  
Old 06-10-2008, 07:40 PM
IN10TION's Avatar
Senior Member
 
Join Date: Mar 2007
Posts: 651
Blog Entries: 1
IN10TION is on a distinguished road
change these...

so, all the conditions are false and stay false till the if() conditions are true.
Remove the StopLong & StopSell in "double", every other "double" can stay.
This will do it for you!

bool BuyCondition=false;
bool SellCondition=false;
bool StopLong=false;
bool StopSell=false;

if((BuyValueCurrent !=0 && BuyValueCurrent2 !=0 && TrendEnvUp != EMPTY_VALUE) && (BuyValueCurrent1min !=0 && BuyValueCurrent21min !=0 && TrendEnvUp1min != EMPTY_VALUE) && (BuyValueCurrent5min !=0 && BuyValueCurrent25min !=0 && TrendEnvUp5min != EMPTY_VALUE)) {BuyCondition=true;}
if((SellValueCurrent !=0 && SellValueCurrent2 !=0 && TrendEnvDown != EMPTY_VALUE) && (SellValueCurrent1min != 0 && SellValueCurrent21min != 0 && TrendEnvDown1min != EMPTY_VALUE) && (SellValueCurrent5min != 0 && SellValueCurrent25min != 0 && TrendEnvDown5min != EMPTY_VALUE)) {SellCondition=true;}
if((SellValueCurrent !=0 && SellValueCurrent2 !=0) || (TrendEnvDown != EMPTY_VALUE)) {StopLong=true;}
if((BuyValueCurrent !=0 && BuyValueCurrent2 !=0) || (TrendEnvUp != EMPTY_VALUE)) {StopSell=true;}



Quote:
Originally Posted by payback View Post
ok ok ok!
here is more!
PHP Code:
double
         BuyValueCurrent
,
         
SellValuePrevious,
         
SellValueCurrent,
         
         
BuyValuePrevious2,
         
BuyValueCurrent2,
         
SellValuePrevious2,
         
SellValueCurrent2,
         
BuyValueCurrent1min,
         
BuyValueCurrent5min,
         
BuyValueCurrent21min,
         
BuyValueCurrent25min,
         
SellValueCurrent1min,
         
SellValueCurrent5min,
         
SellValueCurrent21min,
         
SellValueCurrent25min,
         
         
TrendEnvUp,
         
TrendEnvDown,
         
TrendEnvUp1min,
         
TrendEnvUp5min,
         
TrendEnvDown1min,
         
TrendEnvDown5min,
         
        
Compra,
         
Vendi,
         
StopLong,
         
StopSell
the icustom funcions and buy sell

PHP Code:

 BuyValuePrevious  
iCustom(NULL,TimeFrame,IndicatorName1,NumBars,0,2);
   
BuyValueCurrent iCustom(NULL,0,IndicatorName1,NumBars,1,0);  
   
   
BuyValuePrevious2  iCustom(NULL,TimeFrame,IndicatorName2,NumBars,0,2);  
   
BuyValueCurrent2 iCustom(NULL,0,IndicatorName2,NumBars,0,0);  
   
   
SellValuePrevious iCustom(NULL,TimeFrame,IndicatorName1,NumBars,1,2);
   
SellValueCurrent  iCustom(NULL,0,IndicatorName1,NumBars,0,0);
   
   
SellValuePrevious2 iCustom(NULL,TimeFrame,IndicatorName1,NumBars,1,2);  
   
SellValueCurrent2 iCustom(NULL,0,IndicatorName2,NumBars,1,0);  
   
   
BuyValueCurrent1min iCustom(NULL,1,IndicatorName1,NumBars,1,0);
   
BuyValueCurrent5min iCustom(NULL,5,IndicatorName1,NumBars,1,0);
   
BuyValueCurrent21min iCustom(NULL,1,IndicatorName2,NumBars,0,0);
   
BuyValueCurrent25min iCustom(NULL,5,IndicatorName2,NumBars,0,0);
   
SellValueCurrent1min  iCustom(NULL,1,IndicatorName1,NumBars,0,0);
   
SellValueCurrent5min  iCustom(NULL,5,IndicatorName1,NumBars,0,0);
   
SellValueCurrent21min iCustom(NULL,1,IndicatorName2,NumBars,1,0);
   
SellValueCurrent25min iCustom(NULL,5,IndicatorName2,NumBars,1,0);
   
   
   
   
TrendEnvUp         iCustom(NULL,0,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,0,0); // trendenvelopes 
   
TrendEnvDown         iCustom(NULL,0,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,1,0); // trendenvelopes 
   
TrendEnvUp1min         iCustom(NULL,1,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,0,0);
   
TrendEnvUp5min         iCustom(NULL,5,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,0,0);
   
TrendEnvDown1min         iCustom(NULL,1,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,1,0);
   
TrendEnvDown5min         iCustom(NULL,5,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,1,0);
   
   
   
   
BuyCondition    = (BuyValueCurrent !=&& BuyValueCurrent2 !=&& TrendEnvUp != EMPTY_VALUE)&& (BuyValueCurrent1min !=&& BuyValueCurrent21min !=&& TrendEnvUp1min != EMPTY_VALUE) && (BuyValueCurrent5min !=&& BuyValueCurrent25min !=&& TrendEnvUp5min != EMPTY_VALUE) ;
   
SellCondition     = (SellValueCurrent !=&& SellValueCurrent2 !=&& TrendEnvDown != EMPTY_VALUE)&& (SellValueCurrent1min != && SellValueCurrent21min != && TrendEnvDown1min != EMPTY_VALUE)&& (SellValueCurrent5min != && SellValueCurrent25min != && TrendEnvDown5min != EMPTY_VALUE) ;
   
StopLong  = ((SellValueCurrent !=&& SellValueCurrent2 !=0) || (TrendEnvDown != EMPTY_VALUE));
   
StopSell  = ((BuyValueCurrent !=&& BuyValueCurrent2 !=0) || (TrendEnvUp != EMPTY_VALUE)); 
the exit condition

PHP Code:


StopBuy  
= (SellValueCurrent !=&& SellValueCurrent2 !=|| TrendEnvDown != EMPTY_VALUE);
StopSell  = (BuyValueCurrent !=&& BuyValueCurrent2 !=|| TrendEnvUp != EMPTY_VALUE); 

Last edited by IN10TION; 06-10-2008 at 07:46 PM.
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
  #1017 (permalink)  
Old 06-10-2008, 08:16 PM
Member
 
Join Date: May 2008
Posts: 31
payback is on a distinguished road
thanks i will try this evening!
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
  #1018 (permalink)  
Old 06-10-2008, 08:19 PM
Member
 
Join Date: May 2008
Posts: 31
payback is on a distinguished road
one stupid question everything inside the {} is your comment or i have to write it? and why? why {;} and not {}; ?
also can i still use this statment right?

PHP Code:
if(SellCondition)
      {
         
ticket        subOpenOrder(OP_SELL,NewStopLossSell,TakeProfit,TicketComment); // open SELL order
         
subCheckError(ticket,"SELL");
         
LastTrade     "SELL";
         return(
0); 

or i have to write:

PHP Code:
if(SellCondition true)
      {
         
ticket        subOpenOrder(OP_SELL,NewStopLossSell,TakeProfit,TicketComment); // open SELL order
         
subCheckError(ticket,"SELL");
         
LastTrade     "SELL";
         return(
0); 

Last edited by payback; 06-10-2008 at 08:35 PM.
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
  #1019 (permalink)  
Old 06-10-2008, 09:11 PM
Junior Member
 
Join Date: Oct 2006
Posts: 12
forexcel is on a distinguished road
Help Needed to code a simple ea, please...

Hello All,

I'd like to thank everyone who has help me in the past. Righ now, i have a new request.
Can someone help me code this ea and here are the parameters:

My ea is based on an doji bar and an inside bar.

For an Inside bar :

Place a BUY-STOP/BUY-LIMIT at the HIGH of the next bar
Place a SELL-STOP/SELL-LIMIT at the LOW of the next bar

Clarifications :
Inside Bar is bar 0 (zero)
The next Bar is where we going to to place buy and sell limit or stop
The bar after next is where the long or short will be triggered.

On a one hour chart, if we have an inside bar at 9 AM, then we place our BUY-STOP or LIMIT and SELL-Stop otr LIMIT at the high and low of the 10 AM bar. The long or shor will be triggered at the 11 AM bar providing that price goes higher or lower than the 10 AM bar.


For a Doji bar :

Place a BUY-STOP/BUY-LIMIT at the HIGH of the previous bar
Place a SELL-STOP/SELL-LIMIT at the LOW of the previou bar

Clarifications :
Doji Bar is bar 0 (zero)
The Previoust Bar or Bar before the doji bar is where we going to to place buy and sell limit or stop at the high and low.
The bar after the doji bar is where the long or short will be triggered.

On a one hour chart, if we have doji bar at 9 AM, then we place our BUY-STOP or LIMIT and SELL-Stop otr LIMIT at the high and low of the 8 AM bar. The long or shor will be triggered at the 10 AM bar providing that price goes higher or lower than the 8 AM bar.


...maybe, it's not that simple. If it was i would have done it 2 weeks ago.

Thanks in advance!

Best Regards,

forexcel
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
  #1020 (permalink)  
Old 06-10-2008, 10:30 PM
IN10TION's Avatar
Senior Member
 
Join Date: Mar 2007
Posts: 651
Blog Entries: 1
IN10TION is on a distinguished road
these are not comments, this is code.
they are a part of your if() statement.

if(SellCondition){
...
return(0);
}

if(SellCondition==true){
...
return(0);
}

both statements are ok, you can use one of them...
but see that every if() statement close with }
it doesn't show in your code that you provide here.

other example:
if(a==b){c=1; d=2; return(0);}


Quote:
Originally Posted by payback View Post
one stupid question everything inside the {} is your comment or i have to write it? and why? why {;} and not {}; ?
also can i still use this statment right?

PHP Code:
if(SellCondition)
      {
         
ticket        subOpenOrder(OP_SELL,NewStopLossSell,TakeProfit,TicketComment); // open SELL order
         
subCheckError(ticket,"SELL");
         
LastTrade     "SELL";
         return(
0); 
or i have to write:

PHP Code:
if(SellCondition true)
      {
         
ticket        subOpenOrder(OP_SELL,NewStopLossSell,TakeProfit,TicketComment); // open SELL order
         
subCheckError(ticket,"SELL");
         
LastTrade     "SELL";
         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
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: 3 (0 members and 3 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:30 PM.



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