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
  #491 (permalink)  
Old 11-23-2007, 10:36 PM
Beno's Avatar
Senior Member
 
Join Date: Aug 2006
Location: London
Posts: 516
Beno is on a distinguished road
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.
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
  #492 (permalink)  
Old 11-23-2007, 10:49 PM
Junior Member
 
Join Date: Oct 2006
Posts: 25
natsirte is on a distinguished road
Recover a data type from an indicator

Hi
Is it possible to recover a data type from an indicator (3 MA Cross w alert) to put it in a EA?

This is what I want to do :
In the indicator (3 MA Cross w alert) I put a data type :
double execute_trade = "ok_buy" or execute_trade = "ok_sell" here :

************Indicator ************
if ((fasterMAnow > slowerMAnow &&
fasterMAprevious <= slowerMAprevious &&
fasterMAafter > slowerMAafter &&
mediumMAnow > slowerMAnow )
||
(fasterMAnow > slowerMAnow &&
mediumMAnow > slowerMAnow &&
mediumMAprevious <= slowerMAprevious &&
mediumMAafter > slowerMAafter ))
{
CrossUp[i] = Low[i] - Range*0.5;
string execute_trade = "ok_buy";
}

if ((fasterMAnow < slowerMAnow &&
fasterMAprevious >= slowerMAprevious &&
fasterMAafter < slowerMAafter &&
mediumMAnow < slowerMAnow )
||
(fasterMAnow < slowerMAnow &&
mediumMAnow < slowerMAnow &&
mediumMAprevious >= slowerMAprevious &&
mediumMAafter < slowerMAafter ))
{
CrossDown[i] = High[i] + Range*0.5;
execute_trade = "ok_sell";
}

************************

and I'd like to recover "excute_trade" in my EA like this :


***********EA***************


if (excute_trade== "ok_buy")
Order = SIGNAL_BUY;

if (excute_trade== "ok_sell")
Order = SIGNAL_SELL;



****************************

But I don't know how to do

help please

Best regards
Attached Files
File Type: mq4 3 MA Cross w_Alert v2.mq4 (5.9 KB, 22 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
  #493 (permalink)  
Old 11-23-2007, 11:10 PM
Senior Member
 
Join Date: Feb 2006
Posts: 587
Michel is on a distinguished road
Quote:
Originally Posted by Julia View Post
Can someone be so kind and tell me how to code the following code?:

If my Ea is turned on the M30 chart, I want the code to say:

if(on the M5 timeframe, today's close is>yesterday's close)
{
.........
}
Today's close is the current BID; yesterday's close is timeframe independent, so doesn't matter M30 or M5 timeframe.

PHP Code:
if(Bid iClose(NULL,PERIOD_D1,1))
{
...

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
  #494 (permalink)  
Old 11-23-2007, 11:38 PM
Senior Member
 
Join Date: Feb 2006
Posts: 587
Michel is on a distinguished road
Quote:
Originally Posted by natsirte View Post
Hi
Is it possible to recover a data type from an indicator (3 MA Cross w alert) to put it in a EA?

This is what I want to do :
In the indicator (3 MA Cross w alert) I put a data type :
double execute_trade = "ok_buy" or execute_trade = "ok_sell" here :

************Indicator ************
if ((fasterMAnow > slowerMAnow &&
fasterMAprevious <= slowerMAprevious &&
fasterMAafter > slowerMAafter &&
mediumMAnow > slowerMAnow )
||
(fasterMAnow > slowerMAnow &&
mediumMAnow > slowerMAnow &&
mediumMAprevious <= slowerMAprevious &&
mediumMAafter > slowerMAafter ))
{
CrossUp[i] = Low[i] - Range*0.5;
string execute_trade = "ok_buy";
}

if ((fasterMAnow < slowerMAnow &&
fasterMAprevious >= slowerMAprevious &&
fasterMAafter < slowerMAafter &&
mediumMAnow < slowerMAnow )
||
(fasterMAnow < slowerMAnow &&
mediumMAnow < slowerMAnow &&
mediumMAprevious >= slowerMAprevious &&
mediumMAafter < slowerMAafter ))
{
CrossDown[i] = High[i] + Range*0.5;
execute_trade = "ok_sell";
}

************************

and I'd like to recover "excute_trade" in my EA like this :


***********EA***************


if (excute_trade== "ok_buy")
Order = SIGNAL_BUY;

if (excute_trade== "ok_sell")
Order = SIGNAL_SELL;



****************************

But I don't know how to do

help please

Best regards
You must use iCustom function to retrieve the value of the buffers (ie the arrows);
Quote:
double iCustom( string symbol, int timeframe, string name, ..., int mode, int shift)
Calculates the specified custom indicator and returns its value. The custom indicator must be compiled (*.EX4 file) and be in the terminal_directory\experts\indicators directory.
Parameters:
symbol - Symbol the data of which should be used to calculate indicator. NULL means current symbol.
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0 means the current chart timeframe.
name - Custom indicator compiled program name.
... - Parameters set (if necessary). The passed parameters and their order must correspond with the desclaration order and the type of extern variables of the custom indicator.
mode - Line index. Can be from 0 to 7 and must correspond with the index used by one of SetIndexBuffer functions.
shift - Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago).

Sample:
double val=iCustom(NULL, 0, "SampleInd",13,1,0);

I your case the syntax should be :
PHP Code:
if(iCustom(NULL0"3 MA Cross w_Alert v2"p1, , ,     , p1000) > 0)    // Buy
{
   ...
}
if(
iCustom(NULL0"3 MA Cross w_Alert v2"p1, , ,     , p1010) > 0)    // Sell
{
   ...

The parameteres p1 to p10 are the values to send to the indicator as the extern parametres. For example, p1 means the value to be assigned to FasterMA, p2 to FasterShift, and so on up to the last extern declaration p10 SoundAlert. See the indicator's code to know the order and the signification of them.
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
  #495 (permalink)  
Old 11-23-2007, 11:56 PM
Julia's Avatar
Junior Member
 
Join Date: Aug 2007
Posts: 17
Julia is on a distinguished road
Thanks Michel.
But what if the code is in an indicator code?

Is it:

if(Close[pos]>iHigh(Symbol(),PERIOD_M5,[pos+1])?????
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
  #496 (permalink)  
Old 11-24-2007, 12:34 AM
wolfe's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 818
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #497 (permalink)  
Old 11-24-2007, 10:36 AM
Beno's Avatar
Senior Member
 
Join Date: Aug 2006
Location: London
Posts: 516
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #498 (permalink)  
Old 11-24-2007, 01:03 PM
Senior Member
 
Join Date: Feb 2006
Posts: 587
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #499 (permalink)  
Old 11-24-2007, 05: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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #500 (permalink)  
Old 11-24-2007, 09:44 PM
wolfe's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 818
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!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 07:05 AM.



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