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
  #481 (permalink)  
Old 11-23-2007, 10:13 AM
AQUILEZ's Avatar
Member
 
Join Date: Jul 2006
Posts: 64
AQUILEZ is on a distinguished road
Multiple Trades

How to open multiple trades on the same EA & same pair
how the EA can treat a open position independent from each other in the same pair?
Example if we use a moving average Like principal indicator for enter the market but at the time wen enter the market goes again us and moving average triger a different signal how to open a new position with out closing the previous trade regardless if loss or not.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #482 (permalink)  
Old 11-23-2007, 11:41 AM
AQUILEZ's Avatar
Member
 
Join Date: Jul 2006
Posts: 64
AQUILEZ is on a distinguished road
Problem Statement

start() Disadvantage of a looped Expert Advisor is the impossibility to open the setup panel. Try to loop an EA - and you won't be able to set it up.
The same idea can be successfully realized using a script. This means an infinite loop can be organized in a script. But there are no parameters to be set up in scripts.

MagicNumber
extern int Expert_ID = 1234;
int _MagicNumber = 0;

int init()
{
int Period_ID = 0;
switch ( Period() )
{
case PERIOD_MN1: Period_ID = 9; break;
case PERIOD_W1: Period_ID = 8; break;
case PERIOD_D1: Period_ID = 7; break;
case PERIOD_H4: Period_ID = 6; break;
case PERIOD_H1: Period_ID = 5; break;
case PERIOD_M30: Period_ID = 4; break;
case PERIOD_M15: Period_ID = 3; break;
case PERIOD_M5: Period_ID = 2; break;
case PERIOD_M1: Period_ID = 1; break;
}
_MagicNumber = Expert_ID * 10 + Period_ID;

But how about in the same time frame??????
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #483 (permalink)  
Old 11-23-2007, 12:14 PM
Junior Member
 
Join Date: Nov 2007
Posts: 13
miquest is on a distinguished road
Help code this Great EA

It's Great and it's good, need help coding this EA sumtin like this, can anyone please help me, would really appreciate it please......

Indicators

Gann_hilo_activator 4HR-------for confirmation of overall trend

Gann_hilo_activator 1HR-------for signal

5 simple moving averages (SMA)—for determining the point of entry

Entry signals

Buy signal (1)

If the price opens above the Gann_hilo_activator 1HR and the Gann_hilo_activator 4HR confirms the trend, then buy if the value of 5 SMA is greater than or equal (≥) to the price.


Buy signal (2)

If the Buy signal (1) condition still holds and the price retraces by a predetermined number of pips then buy another lot e.g. for EUR/USD =32pips.

Sell signal (1)

If the price opens below the Gann_hilo_activator 1HR and the Gann_hilo_activator 4HR confirms the trend, then sell if the value of 5 SMA is less than or equal (≤) to the price.

Sell signal (2)

If the Sell signal (1) condition still holds and the price retraces by a predetermined number of pips then sell another lot e.g. for USD/CAD=46pips.


Exit signals

Close Buy signals

If the price opens below the Gann_hilo_activator 1HR

Close sell signals

If the price opens above the Gann_hilo_activator 1HR

External parameters

By default

--------------------------

Trailing stops =

Stop loss =

Take profit =

extern double Lots = 0.01; // I trade a microlots using a mini account

extern int Slippage = 3;

extern bool StopLossMode = True;

extern int StopLoss = 17; //

extern bool TakeProfitMode = false;

extern int TakeProfit = 60;

extern bool TrailingStopMode = True;

extern int TrailingStop = 37;

Money management code not risking more than 1.2% on one pair of currency at a time and maximum amount of capital at risk is 10%

Gann_hilo_activator 4HR-------for confirmation of overall trend


Gann_hilo_activator 1HR-------for signal

5 simple moving averages (SMA)—for determining the point of entry

my_EA_@_my_own_risk

Hello sir, this is my system that I use and will like to turn in into an EA

Indicators

Gann_hilo_activator 4HR-------for confirmation of overall trend

Gann_hilo_activator 1HR-------for signal

5 simple moving averages (SMA)—for determining the point of entry

Entry signals

Buy signal (1)

If the price opens above the Gann_hilo_activator 1HR and the Gann_hilo_activator 4HR confirms the trend, then buy if the value of 5 SMA is greater than or equal (≥) to the price.


Buy signal (2)

If the Buy signal (1) condition still holds and the price retraces by a predetermined number of pips then buy another lot e.g. for EUR/USD =32pips.

Sell signal (1)

If the price opens below the Gann_hilo_activator 1HR and the Gann_hilo_activator 4HR confirms the trend, then sell if the value of 5 SMA is less than or equal (≤) to the price.

Sell signal (2)

If the Sell signal (1) condition still holds and the price retraces by a predetermined number of pips then sell another lot e.g. for USD/CAD=46pips.


Exit signals

Close Buy signals

If the price opens below the Gann_hilo_activator 1HR

Close sell signals

If the price opens above the Gann_hilo_activator 1HR

External parameters

By default

--------------------------

Trailing stops = 17

Stop loss = 37

Take profit = false

extern double Lots = 0.01; // I trade a microlots using a mini account

extern int Slippage = 3;

extern bool StopLossMode = True;

extern int StopLoss = 17; //

extern bool TakeProfitMode = false;

extern int TakeProfit = 60;

extern bool TrailingStopMode = True;

extern int TrailingStop = 37;

Money management code not risking more than 1.2% on one pair of currency at a time and maximum amount of capital at risk is 10%
Attached Files
File Type: doc mt ea.doc (73.0 KB, 8 views)
File Type: mq4 ###Gann_HiLo_Activator_v2###.mq4 (3.2 KB, 22 views)

Last edited by miquest; 11-23-2007 at 03:09 PM. Reason: correct sumtin
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #484 (permalink)  
Old 11-23-2007, 06:45 PM
wolfe's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 682
wolfe is on a distinguished road
Quote:
Originally Posted by AQUILEZ View Post
How to open multiple trades on the same EA & same pair
how the EA can treat a open position independent from each other in the same pair?
Example if we use a moving average Like principal indicator for enter the market but at the time wen enter the market goes again us and moving average triger a different signal how to open a new position with out closing the previous trade regardless if loss or not.
Assign every order a unique ticket number and separate magic number. Only close orders by magic number.

You could then use Orderselect() to get the info of that specific ticket, when your criteria is met, close your order by magic number.

Hope this helps.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #485 (permalink)  
Old 11-23-2007, 08:55 PM
Julia's Avatar
Junior Member
 
Join Date: Aug 2007
Posts: 17
Julia is on a distinguished road
Time code help????????????

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)
{
.........
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #486 (permalink)  
Old 11-23-2007, 09:36 PM
Beno's Avatar
Senior Member
 
Join Date: Aug 2006
Location: London
Posts: 256
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!
Reply With Quote
  #487 (permalink)  
Old 11-23-2007, 09:49 PM
Junior Member
 
Join Date: Oct 2006
Posts: 24
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, 8 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #488 (permalink)  
Old 11-23-2007, 10:10 PM
Senior Member
 
Join Date: Feb 2006
Posts: 513
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!
Reply With Quote
  #489 (permalink)  
Old 11-23-2007, 10:38 PM
Senior Member
 
Join Date: Feb 2006
Posts: 513
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!
Reply With Quote
  #490 (permalink)  
Old 11-23-2007, 10: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!
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 10:29 PM.



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