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 Thread Tools Display Modes
  #1001 (permalink)  
Old 06-10-2008, 12:39 PM
Junior Member
 
Join Date: May 2008
Posts: 26
payback is on a distinguished road
Unhappy boolean match error

Hi all, i have this error and i don't understand how to figure out, i think it's a problem of matching different types of variables

here is the snippet of the code


double
BuyCondition,
SellCondition,
StopLong,
StopSell;

the indicators are

double indicator1,
indicator2
indicator 3; (but is int)

so i want those conditions
PHP Code:
StopLong  = ((SellValueCurrent !=&& SellValueCurrent2 !=0) || (TrendEnvDown != EMPTY_VALUE));
   
StopSell  = ((BuyValueCurrent !=&& BuyValueCurrent2 !=0) || (TrendEnvUp != EMPTY_VALUE)); 
so why sometimes i don't have 0 when i need 1 and sometimes i have both1 when or one of them should bhe 1? this now for me make no sense at all why is wrong? please help me!!!


p.s. sellvalue and buyvalue are double
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1002 (permalink)  
Old 06-10-2008, 12:50 PM
IN10TION's Avatar
Senior Member
 
Join Date: Mar 2007
Posts: 472
Blog Entries: 1
IN10TION is on a distinguished road
need more code to fix this...
if you wish, publish your mq4

Quote:
Originally Posted by payback View Post
Hi all, i have this error and i don't understand how to figure out, i think it's a problem of matching different types of variables

here is the snippet of the code


double
BuyCondition,
SellCondition,
StopLong,
StopSell;

the indicators are

double indicator1,
indicator2
indicator 3; (but is int)

so i want those conditions
PHP Code:
StopLong  = ((SellValueCurrent !=&& SellValueCurrent2 !=0) || (TrendEnvDown != EMPTY_VALUE));
   
StopSell  = ((BuyValueCurrent !=&& BuyValueCurrent2 !=0) || (TrendEnvUp != EMPTY_VALUE)); 
so why sometimes i don't have 0 when i need 1 and sometimes i have both1 when or one of them should bhe 1? this now for me make no sense at all why is wrong? please help me!!!


p.s. sellvalue and buyvalue are double
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1003 (permalink)  
Old 06-10-2008, 01:05 PM
Junior Member
 
Join Date: Jun 2008
Posts: 9
panteraschoice is on a distinguished road
OrderClose error

Something goes wrong. The demo account was wiped out completely.

Here is a small part from the expert log, with hundreds of those "invalid price for OrderClose function" :

GBPJPY at 209.23 sl: 212.23 tp: 208.23 ok
10:00:04 2730_BasketVentilatorVoorProg_2 GBPCHF,H1: invalid price 2.02750000
for OrderClose function
10:00:04 2730_BasketVentilatorVoorProg_2 EURUSD,H1: invalid price 1.55750000
for OrderClose function
10:00:04 2730_BasketVentilatorVoorProg_2 GBPCHF,H1: close #11685361 sell
0.10 GBPCHF at 2.0270 sl: 2.0570 tp: 2.0170 at price 2.0275
10:00:05 2730_BasketVentilatorVoorProg_2 USDCHF,H1: invalid price 1.03350000
for OrderClose function
10:00:05 2730_BasketVentilatorVoorProg_2 EURUSD,H1: invalid price 1.55740000
for OrderClose function

this is the part in the ea for the OrderClose,
I do not see what is wrong in it, maybe someone can help?

//---------------------
int l_ord_total_72 = OrdersTotal();
for (int l_pos_76 = 0; l_pos_76 < l_ord_total_72; l_pos_76++) {
if (OrderSelect(l_pos_76, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() == Symbol()) {
l_cmd_80 = OrderType();
if (l_cmd_80 == OP_BUY) {
l_count_56++;
if (l_isar_48 > Close[0]) OrderClose(OrderTicket(), OrderLots(), Bid, 3, Violet);
}
if (l_cmd_80 == OP_SELL) {
l_count_60++;
if (l_isar_48 < Close[0]) OrderClose(OrderTicket(), OrderLots(), Ask, 3, Violet);
}
}
}
}
//--------------------

Compiling does not give an error.

Last edited by panteraschoice; 06-10-2008 at 01:10 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1004 (permalink)  
Old 06-10-2008, 01:09 PM
Kalenzo's Avatar
Senior Member
 
Join Date: Dec 2005
Location: Bydgoszcz - Poland
Posts: 693
Kalenzo is on a distinguished road
Quote:
Originally Posted by panteraschoice View Post
Something goes wrong. The demo account was wiped out completely.

Here is a small part from the expert log, with hundreds of those "invalid price for OrderClose function" :

GBPJPY at 209.23 sl: 212.23 tp: 208.23 ok
10:00:04 2730_BasketVentilatorVoorProg_2 GBPCHF,H1: invalid price 2.02750000
for OrderClose function
10:00:04 2730_BasketVentilatorVoorProg_2 EURUSD,H1: invalid price 1.55750000
for OrderClose function
10:00:04 2730_BasketVentilatorVoorProg_2 GBPCHF,H1: close #11685361 sell
0.10 GBPCHF at 2.0270 sl: 2.0570 tp: 2.0170 at price 2.0275
10:00:05 2730_BasketVentilatorVoorProg_2 USDCHF,H1: invalid price 1.03350000
for OrderClose function
10:00:05 2730_BasketVentilatorVoorProg_2 EURUSD,H1: invalid price 1.55740000
for OrderClose function

this is the part in the ea for the OrderClose,
I do not see what is wrong in it, maybe someone can help?

//---------------------
int l_ord_total_72 = OrdersTotal();
for (int l_pos_76 = 0; l_pos_76 < l_ord_total_72; l_pos_76++) {
if (OrderSelect(l_pos_76, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() == Symbol()) {
l_cmd_80 = OrderType();
if (l_cmd_80 == OP_BUY) {
l_count_56++;
if (l_isar_48 > Close[0]) OrderClose(OrderTicket(), OrderLots(), Bid, 3, Violet);
}
if (l_cmd_80 == OP_SELL) {
l_count_60++;
if (l_isar_48 < Close[0]) OrderClose(OrderTicket(), OrderLots(), Ask, 3, Violet);
}
}
}
}
//--------------------
Maybe you got new prices from broker, try to use RefreshRates function before OrderClose if you will get error.
__________________
You need proffesional mql coder? Contact me! I will help you!
........................................
http://www.fxservice.eu/
........................................
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1005 (permalink)  
Old 06-10-2008, 01:48 PM
Junior Member
 
Join Date: May 2008
Posts: 26
payback is on a distinguished road
Quote:
Originally Posted by IN10TION View Post
need more code to fix this...
if you wish, publish your mq4
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!
Reply With Quote
  #1006 (permalink)  
Old 06-10-2008, 02: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!
Reply With Quote
  #1007 (permalink)  
Old 06-10-2008, 02:20 PM
IN10TION's Avatar
Senior Member
 
Join Date: Mar 2007
Posts: 472
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!
Reply With Quote
  #1008 (permalink)  
Old 06-10-2008, 04:26 PM
Junior Member
 
Join Date: May 2008
Posts: 26
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!
Reply With Quote
  #1009 (permalink)  
Old 06-10-2008, 04:55 PM
IN10TION's Avatar
Senior Member
 
Join Date: Mar 2007
Posts: 472
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!
Reply With Quote
  #1010 (permalink)  
Old 06-10-2008, 06:00 PM
Junior Member
 
Join Date: May 2008
Posts: 26
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 06:03 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

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 On
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 04:22 PM


All times are GMT. The time now is 06:26 AM.