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
  #491 (permalink)  
Old 11-23-2007, 11:34 PM
wolfe's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 702
wolfe is on a distinguished road
Quote:
Originally Posted by Beno View Post
Gidday I am slowly fixing the errors in some if my ea's ( and learning alot on the way) but what does this mean.
2007.10.24 21:22:24 1998.11.20 06:00 The Abyss GBPJPY,Daily: invalid double number as parameter 6 for OrderSend function

I can't find anything on that error what should I be looking at.
int OrderSend( string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment=NULL, int magic=0, datetime expiration=0, color arrow_color=CLR_NONE)

As you can see parameter six is the stoploss. Make sure your stoploss is defined as an int. Next, make sure in your OrderSend() command that you are multiplying the stoploss by point. This converts to the right double for the currency you are trading.

Example for long:
ticketa=OrderSend(Symbol(),OP_BUY,lotsize,Ask,slip ,Ask-intStopLoss*Point,Ask+intTakeProfit*Point,"Comment ",magic,0,Green);

Example for short:
ticketb=OrderSend(Symbol(),OP_SELL,lotsize,Bid,sli p,Bid+intStopLoss*Point,Bid-intTakeProfit*Point,"Comment",magic,0,Blue);

Hope this helps.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #492 (permalink)  
Old 11-24-2007, 09:36 AM
Beno's Avatar
Senior Member
 
Join Date: Aug 2006
Location: London
Posts: 287
Beno is on a distinguished road
Thanks Wolfe

That helped alot but has open a new problem lol it now buys but no sell well not in the right place. I have been trying to buy what all three indi are blue and sell when all red.
I think I have picked the right name "The Abyss" for the ea. as that is where I am sitting trying to code my way out. LOL


2007.11.24 10:14:44 2007.11.23 12:00 The Abyss EURUSD,H4: Error opening SELL order : 0

void CheckForSignals() {


double TML=iCustom(NULL,0,"TrendManager",TM_Period,TM_Shi ft,0,shift);
double TMS=iCustom(NULL,0,"TrendManager",TM_Period,TM_Shi ft,1,shift);
double hasOpenLong=iCustom(NULL,0,"Heiken_Ashi_Smoothed", MaMetod,MaPeriod,MaPeriod2,1,shift) ;
double hasCloseLong=iCustom(NULL,0,"Heiken_Ashi_Smoothed" ,MaMetod,MaPeriod,MaPeriod2,3,shift) ;
double hasOpenShort=iCustom(NULL,0,"Heiken_Ashi_Smoothed" ,MaMetod,MaPeriod,MaPeriod2,0,shift) ;
double hasCloseShort=iCustom(NULL,0,"Heiken_Ashi_Smoothed ",MaMetod,MaPeriod,MaPeriod2,2,shift) ;
double SDLL=iCustom(NULL,0,"Slope Direction Line",period,method,price,0,shift);
double SDLS=iCustom(NULL,0,"Slope Direction Line",period,method,price,1,shift);




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


bool Long1 = TML;
bool Short1 = TMS;
bool Long2 = SDLL;
bool Short2 = SDLS;
bool Long3 = hasOpenLong > hasCloseLong;
bool Short3 = hasOpenShort < hasCloseShort;

buysig = Long1 && Long2 && Long3;
sellsig = Short1 && Short2 && Short3;

closebuy=sellsig;
closesell=buysig;

}

void CheckForOpen() {

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

int res,ord;
double entry,stop;

ord=CalculateCurrentOrders();

if (ord!=0) CheckForClose();

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

int OpenAtMarket(int mode,double lot) {
int tr,col;
double openprice;
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;
}
OrderSend(Symbol(),mode,lot,openprice,slippage,sl, tp,EAName+Magic,Magic,0,col);

}
return;


//+------------------------------------------------------------------+
//| Check for close order conditions |
//+------------------------------------------------------------------+
void CheckForClose() {
int total;
//----
total=OrdersTotal();
for(int i=total;i>=0;i--)
{
if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue;
if(OrderMagicNumber()!=Magic || OrderSymbol()!=Symbol()) continue;
//---- check order type
if(OrderType()==OP_BUY && closebuy) CloseAtMarket(OrderTicket(),OrderLots());
if(OrderType()==OP_SELL && closesell) CloseAtMarket(OrderTicket(),OrderLots());
}
}

bool CloseAtMarket(int ticket,double lot) {
bool bres=false; int tr;
tr=0; while (tr<5 && !IsTradeAllowed()) { tr++; Sleep(2000); }
RefreshRates();
bres=OrderClose(ticket,lot,OrderClosePrice(),slipp age,White);
if (!bres) Print("Error closing order : ",(GetLastError()));

}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #493 (permalink)  
Old 11-24-2007, 12:03 PM
Senior Member
 
Join Date: Feb 2006
Posts: 519
Michel is on a distinguished road
Quote:
Originally Posted by Julia View Post
Thanks Michel.
But what if the code is in an indicator code?

Is it:

if(Close[pos]>iHigh(Symbol(),PERIOD_M5,[pos+1])?????
Yes, it may be that; all depend of what you are intended to do...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #494 (permalink)  
Old 11-24-2007, 04:37 PM
Junior Member
 
Join Date: Nov 2007
Posts: 1
bali123 is on a distinguished road
Question Help Plz - Convert These Into Mq4 - Thanks Alot

Dear all:

I'm building a system I think it is very good, I tested the idea before for 3 months, Now I'm trying to coding an indicator which will be asap in the forum so we can test it and it will really will make good money i think:

Plz help me for now to convert these lines into mql4 coding:

1- I have vairable X , this will have a value and I'm calculating it now
SO We have X as an Integer

2- the indicator must check the currnet GMT Time, It must be 6:00am GMT - Time Frame 1 H

-- check GMT TIME 6:00am, WHEN this candle close, we need to calculate the following Variable Of this candle:
High - Low = A
A / 2 = B
B - High = C = SL
D = X * 30%
Buy_Entry= D + C
Buy_Target= C + (X * 60%)
Sell_Entry= C - D
Sell _Target= C - (X * 60%)

Then:
I want to drow the result as lines on the chart with GreaN Area for buy and red Area for Short According to Entry for Buy and Sell and SL

these must be automaticly apear as soon as GMT 6:00 candle finished , Time Frame 1H, so caluculation must be according to 6:00 to 6:59am GMT Candle high and low

PLZ Convert this to MQL4, so i can test it and get back again to puplish the result

THANKS ALOT
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #495 (permalink)  
Old 11-24-2007, 08:44 PM
wolfe's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 702
wolfe is on a distinguished road
Quote:
Originally Posted by Beno View Post
Thanks Wolfe

That helped alot but has open a new problem lol it now buys but no sell well not in the right place. I have been trying to buy what all three indi are blue and sell when all red.
I think I have picked the right name "The Abyss" for the ea. as that is where I am sitting trying to code my way out. LOL
Beno, I'm not sure about this one. I have usually not had good experience with using color changing indicators in EA's. Open your data window with your indicators attached and find out what numerical value is returned for each color. That may help your coding, also make sure you are calling the correct indicator buffer at the right time. (I'm sure you have already done that) You may have better luck with help if you post the entire EA, if you really need help. Also, personally I would code it with 2 separate Ordersend() functions, one dedicated to shorts, and one dedicated to longs. That's just my opinion, it makes things easier to follow.

Good luck, we all have had our own versions of "the Abyss"!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #496 (permalink)  
Old 11-24-2007, 09:23 PM
Beno's Avatar
Senior Member
 
Join Date: Aug 2006
Location: London
Posts: 287
Beno is on a distinguished road
Cheers Wolfe

I am going to try the 2 Ordersend option to see what happens. once I get this going I will post it.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #497 (permalink)  
Old 11-24-2007, 10:11 PM
Beno's Avatar
Senior Member
 
Join Date: Aug 2006
Location: London
Posts: 287
Beno is on a distinguished road
Gidday Wolfe

Attached is The Abyss EA it needs some work doing to it. I am still working on it but some more help By some one who knows what they are doing would be great.


cheers

Beno
Attached Files
File Type: mq4 The Abyss.mq4 (10.1 KB, 11 views)
File Type: mq4 Heiken_Ashi_Smoothed.mq4 (4.2 KB, 5 views)
File Type: mq4 Slope Direction Line.mq4 (4.1 KB, 5 views)

Last edited by newdigital; 11-26-2007 at 07:02 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #498 (permalink)  
Old 11-25-2007, 10:53 AM
Senior Member
 
Join Date: Oct 2006
Posts: 104
antone is on a distinguished road
i need a little help.. how do i make it work? i tried but it won't read the mins? i i should use something else aside from TimeHour but what?

Quote:
if (TimeHour (Clocks) == 7:15) {B = 1; }
if (TimeHour (Clocks) == 7:30) {B = 2;}
if (TimeHour (Clocks) == 7:45) {B= 3;}
if (TimeHour (Clocks) == 8) {B = 4;}
if (TimeHour (Clocks) == 8:15) {B = 5;}
if (TimeHour (Clocks) == 8:30) {B = 6;}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #499 (permalink)  
Old 11-25-2007, 11:02 AM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
Maybe you meant something like the following:
PHP Code:
if ( TimeHourClocks ) == ) {
    
MathFloorTimeMinuteClocks ) / 15 );
} else if ( 
TimeHourClocks ) == ) {
    
MathFloorTimeMinuteClocks ) / 15 ) + 4;

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #500 (permalink)  
Old 11-25-2007, 07:38 PM
Senior Member
 
Join Date: Mar 2006
Location: La Verne,CA
Posts: 552
MrPip is on a distinguished road
Quote:
Originally Posted by ralph.ronnquist View Post
Maybe you meant something like the following:
PHP Code:
if ( TimeHourClocks ) == ) {
    
MathFloorTimeMinuteClocks ) / 15 );
} else if ( 
TimeHourClocks ) == ) {
    
MathFloorTimeMinuteClocks ) / 15 ) + 4;

Or maybe

if (TimeHour(Clocks) == 7)
{
switch (TimeMinute(Clocks)
{
case 15 : B = 1;
break;
case 30 : B = 2;
break;
case 45 : B = 3;
}
}

if (TimeHour(Clocks) == 8)
{
switch (TimkeMinute(Clocks)
{
case 0 : B = 4;
break;
case 15 : B = 5;
break;
case 30 : B = 6;

}
}

Otherwise 7:17 would also set a value of 1 to B.

Robert

Last edited by MrPip; 11-25-2007 at 07:39 PM. Reason: fix typo
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
CHinGsMAroonCLK, I_XO_A_H

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

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


All times are GMT. The time now is 02:20 PM.



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