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
  #1431 (permalink)  
Old 11-10-2008, 09:21 PM
Junior Member
 
Join Date: Oct 2008
Posts: 6
tehgar is on a distinguished road
Can anyone answer an MQL4 question for me?

I was wondering is there any way in MQL4 to have functionality like eval() where you can have a string that contains MQL4 code and have it evaluated as code instead of a string?
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
  #1432 (permalink)  
Old 11-10-2008, 09:21 PM
EBK EBK is offline
Junior Member
 
Join Date: May 2008
Posts: 13
EBK is on a distinguished road
Oh,sorry I've wronlgy express my opinion.

I want to code (but I'm not able to do) something that will stop EA trading (or part of ea trading) if the equity is under a value.

Thanks for your help Roger09, but I don't need to display rhe equity on the chart

Last edited by EBK; 11-10-2008 at 09:24 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
  #1433 (permalink)  
Old 11-11-2008, 10:23 PM
Member
 
Join Date: Dec 2007
Location: Outside Stockholm
Posts: 45
ingvar_e is on a distinguished road
Question on timeframes

In an EA I use iCCI with 1 Hour timeframe like

cci = iCCI(NULL,PERIOD_H1,CCIPeriod,PRICE_TYPICAL,1);

If I run the EA in 1H I will get a specific value. If I run the EA in a 15M I expect to get the same value.

On IBFX I get the same value. On Alpari not.

Seems strange

Ingvar
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
  #1434 (permalink)  
Old 11-12-2008, 02:49 AM
wolfe's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 818
wolfe is on a distinguished road
Quote:
Originally Posted by ingvar_e View Post
In an EA I use iCCI with 1 Hour timeframe like

cci = iCCI(NULL,PERIOD_H1,CCIPeriod,PRICE_TYPICAL,1);

If I run the EA in 1H I will get a specific value. If I run the EA in a 15M I expect to get the same value.

On IBFX I get the same value. On Alpari not.

Seems strange

Ingvar
By calling PERIOD_H1 in your indicator call you should only get H1 data. That IS strange.
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
  #1435 (permalink)  
Old 11-12-2008, 03:10 PM
Member
 
Join Date: Sep 2006
Posts: 65
sbwent is on a distinguished road
Help please. Trying to get data from closed trades.

I am trying to get data from closed trades. My code works fine as long as I am only trading one pair, but with multiples it screws up somehow.

for(i=OrdersHistoryTotal(); i>0; i--)
{
if(totalOrders==0 && Magic==OrderMagicNumber() &&
OrderSelect(i-1 , SELECT_BY_POS,MODE_HISTORY)==true)
{
CloseTime = OrderCloseTime();
OpenTime = OrderOpenTime();
OrderLots = OrderLots();
Ticket=OrderTicket();

}

Can someone help me out with this please? It gives correct value for the last trade closed if the Magic matches, but if the last closed trade is a different currency pair then it gives me the wrong ticket data.

Thanks heaps,

Steve
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
  #1436 (permalink)  
Old 11-12-2008, 04:40 PM
Senior Member
 
Join Date: Feb 2006
Posts: 587
Michel is on a distinguished road
this is wrong : if(totalOrders==0 && Magic==OrderMagicNumber() &&
OrderSelect(i-1 , SELECT_BY_POS,MODE_HISTORY)==true)
because you are calling OrderMagicNumber() before OrderSelect(), so it probably refers to the previous call.
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
  #1437 (permalink)  
Old 11-12-2008, 05:54 PM
Senior Member
 
Join Date: Oct 2008
Location: Vancouver, BC
Posts: 158
Roger09 is on a distinguished road
Quote:
Originally Posted by EBK View Post
Oh,sorry I've wronlgy express my opinion.

I want to code (but I'm not able to do) something that will stop EA trading (or part of ea trading) if the equity is under a value.

Thanks for your help Roger09, but I don't need to display rhe equity on the chart
Try this EA
CloseAllBuySell - MQL4 Code Base

Use its idea and make a code with something as

if (AccountEquity()<YourValue) closeallorders();
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
  #1438 (permalink)  
Old 11-15-2008, 03:25 PM
Beno's Avatar
Senior Member
 
Join Date: Aug 2006
Location: London
Posts: 516
Beno is on a distinguished road
Could somebody please add the EMA trailing stop to the sample Moving Average EA

EMA trailing set to 1

Then change the entry to
Buy=Open[1]>ma && Close[1]>ma;
Sell=Open[1]<ma && Close[1]<ma;

This should make a very good simple scalper.

Cheers

Beno
Attached Files
File Type: mq4 EMATrailingStop_v1.mq4 (4.1 KB, 21 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
  #1439 (permalink)  
Old 11-16-2008, 12:58 AM
Junior Member
 
Join Date: Oct 2008
Posts: 24
tk748 is on a distinguished road
Help with Changing Script Code

Can anyone help me change the code below to move a SL to zero + or - a set number of pips? The Set Zero SL script by elihayun works great to move stop loss to break even but I would like it to move my stoploss to break even plus 10, 20 or whatever pips. Can anyone help with this?

//+------------------------------------------------------------------+
//| Set Zero SL.mq4 |
//| Copyright © 2006, Eli Hayun |
//| xing yu zhang yiming yuan at elihayun.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Eli Hayun"
#property link "http://www.elihayun.com"

//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
//----
string curr = Symbol();
int ot = OrdersTotal();
int ords[200], ordType[200], ordTicket[200]; double ordLots[200];
string ordComments[200];
int ix=0;
for (int i=0; i<ot; i++)
{
int o = OrderSelect(i, SELECT_BY_POS);
if (OrderSymbol() == Symbol())
if ((OrderType() == OP_BUY) || (OrderType() == OP_SELL))
{
double sl = 0;
if ((OrderType() == OP_BUY) && (OrderStopLoss() < OrderOpenPrice()))
sl = OrderOpenPrice() ;
if ((OrderType() == OP_SELL) && (OrderStopLoss() > OrderOpenPrice()))
sl = OrderOpenPrice() ;

if (sl != 0)
OrderModify(OrderTicket(), OrderOpenPrice(), sl, OrderTakeProfit(), 0);
}
}
//----
return(0);
}


Thanks for any help you can give, Tom.
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
  #1440 (permalink)  
Old 11-16-2008, 06:29 PM
Senior Member
 
Join Date: Oct 2008
Location: Vancouver, BC
Posts: 158
Roger09 is on a distinguished road
Add at the beginning of program
extern int pips=2;//(or your number of pips)
then replace

Code:
if ((OrderType() == OP_BUY) && (OrderStopLoss() < OrderOpenPrice()))
sl = OrderOpenPrice() ;
if ((OrderType() == OP_SELL) && (OrderStopLoss() > OrderOpenPrice()))
sl = OrderOpenPrice() ;
to

Code:
if ((OrderType() == OP_BUY) && (OrderStopLoss() < OrderOpenPrice()))
sl = OrderOpenPrice() +pips*Point;
if ((OrderType() == OP_SELL) && (OrderStopLoss() > OrderOpenPrice()))
sl = OrderOpenPrice() -pips*Point;
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 01:21 PM.



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