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
  #1991 (permalink)  
Old 08-17-2009, 08:00 PM
SPACECHIMP's Avatar
Member
 
Join Date: Feb 2006
Location: West Michigan, USA.
Posts: 86
SPACECHIMP is on a distinguished road
SIMPLE Coding question

OrderSelect(5555, SELECT_BY_TICKET);
RefreshRates();
if (Ask >= (OrderOpenPrice()+ (5 * Point)) && OrderLots() == 2 && (OrderType() == OP_BUY)) {
OrderClose(5555,1,Ask,10,Red); }

if (Bid <= (OrderOpenPrice()- (5 * Point)) && OrderLots() == 2 && (OrderType() == OP_SELL)) {
OrderClose(5555,1,Bid,10,Blue); }


Still trying to learn...

would this work for basically closing half (2 lots down to 1) of a position when the price hits 5 pips away from open price?


THANKS!!!!!!
__________________
www.LiveTeamTrading.com
The FIRST LIVE Team trading Network Community for FOREX TRADERS! Ask me about Getting an Invite!
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
  #1992 (permalink)  
Old 08-18-2009, 12:38 AM
Senior Member
 
Join Date: Nov 2006
Posts: 308
luxinterior is on a distinguished road
Looks about right. It's a bit messy though. You could also use OrderProfit depending on what you actually want to achieve.

Lux

PS: Forgot to mention to watch out for 5 decimal place brokers. Everything needs to be multiplied by 10 so in your example 5 would be 50. Good luck!
__________________
Build An Expert Advisor. FREE E-course As Seen On TV
ForexArea.com
Users of Gap Trader from 'Forex-Assistant' MUST Read This

Last edited by luxinterior; 08-18-2009 at 12:45 AM.
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
  #1993 (permalink)  
Old 08-18-2009, 05:28 AM
SPACECHIMP's Avatar
Member
 
Join Date: Feb 2006
Location: West Michigan, USA.
Posts: 86
SPACECHIMP is on a distinguished road
Quote:
Originally Posted by luxinterior View Post
Looks about right. It's a bit messy though. You could also use OrderProfit depending on what you actually want to achieve.

Lux

PS: Forgot to mention to watch out for 5 decimal place brokers. Everything needs to be multiplied by 10 so in your example 5 would be 50. Good luck!
Thanks LUX

Problem is that I have it running just to debug on a 1 minute GBP/USD chart with Windsor direct and it is Not closing 1 lot when it hits the 5 pips so I don't know what the deal is.

ALSO,
I'm trying to close a buy and immediately open a Sell and THAT"S NOT GOING to well either.
It works and then it doesn't...
I WISH THIS WAS ALOT easier to program

if (*******************) {
RefreshRates();
OrderSelect(5555,SELECT_BY_TICKET);
if (OrdersTotal() > 0 && OrderType()==OP_BUY) {OrderClose(5555, OrderLots(), Bid, Slippage, MediumSeaGreen);
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy");}
Sleep(1500);
RefreshRates();
if (OrdersTotal() ==0) Ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, 10, 0, 0, "Sell(#" + MagicNumber + ")", MagicNumber, 0, DeepPink);
if(Ticket<0)Print("OrderSend failed with error #",GetLastError());
}
__________________
www.LiveTeamTrading.com
The FIRST LIVE Team trading Network Community for FOREX TRADERS! Ask me about Getting an Invite!
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
  #1994 (permalink)  
Old 08-22-2009, 03:02 AM
newcoder's Avatar
Junior Member
 
Join Date: Jul 2009
Posts: 12
newcoder is on a distinguished road
Debugging Indicators

I am new to this language and I am trying to write an indicator. I am having problems since there is no debugger. I tried to use the Print() but nothing gets printed. Using the Alert() I get ZERO as an output for the buffer[1] . Can anyone explain this to me please. How can I use the Print() and Alert() to debugg without getting all ZEROs. If anyone has any ideas please let me know. Thanks so much.

tigger.longtail@gmail.com


ExtMapBuffer1[i] = iMA(NULL,0,ExtParam1,0,MODE_EMA,PRICE_CLOSE,i);
ExtMapBuffer2[i] = iMA(NULL,0,ExtParam2,0,MODE_EMA,PRICE_CLOSE,i);
CurrentBar = Time[i];

if( ExtMapBuffer1[i] >= ExtMapBuffer2[i] && CurrentBar == Time[i] && Flag == 0)
{

Alert("ExtMapBuffer1[i] =", ExtMapBuffer1[i]," Short is Above. ",Hour()," Minute ",Minute());

Alert("ExtMapBuffer2[i] =", ExtMapBuffer2[i]," Short is Above. ",Hour()," Minute ",Minute());


Print("ExtMapBuffer1[i] = ", ExtMapBuffer1[i]);
Print("ExtMapBuffer2[i] = ", ExtMapBuffer2[i]);
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
  #1995 (permalink)  
Old 08-22-2009, 12:13 PM
dr.house7's Avatar
Senior Member
 
Join Date: Apr 2009
Location: Italy
Posts: 186
dr.house7 is on a distinguished road
Question

how is it possible in a simple calculation to round up to a result ?
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
  #1996 (permalink)  
Old 08-22-2009, 07:25 PM
wolfe's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 818
wolfe is on a distinguished road
Quote:
Originally Posted by dr.house7 View Post
how is it possible in a simple calculation to round up to a result ?
Depends on what you want to do:

double MathRound( double value)
Returns value rounded to the nearest integer of the specified numeric value.

double MathFloor( double x)
The MathFloor function returns a numeric value representing the largest integer that is less than or equal to x.

double MathCeil( double x)
The MathCeil function returns a numeric value representing the smallest integer that exceeds or equals to x.

double NormalizeDouble( double value, int digits)
Rounds the floating point value to the given precision. Returns normalized value of the double type.
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
  #1997 (permalink)  
Old 08-24-2009, 10:02 PM
Junior Member
 
Join Date: May 2008
Posts: 21
plasmapants is on a distinguished road
Hi,

I would like some help programming an additional input to this ea.

It is a basic grid/mart sys that places pending orders above and below the starting price at equal increments where the tp for buy orders is the same value as sl for sell orders and viceversa.

From what i can work out It currently calculates the tp/sl as (4 * pip increment) from the price at which you start the ea.

I would like an input which would allow me to adjust tp/sl by X number of pips.

ie (4 x pip increment) + X,

thanks for your help.
Attached Files
File Type: mq4 mGRID EA.mq4 (9.3 KB, 4 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
  #1998 (permalink)  
Old 08-25-2009, 02:08 PM
Junior Member
 
Join Date: Nov 2007
Posts: 21
derumuro is on a distinguished road
Help wanted wait x-Bars

Hi all,

how you can program the following :

if close latest Order, wait x-Bars to open new Order ?

Thanks !

Regards
derumuro
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
  #1999 (permalink)  
Old 08-25-2009, 08:42 PM
Junior Member
 
Join Date: Jul 2009
Posts: 8
jerzzhere is on a distinguished road
Counting bars

I'm trying to get my EA to count the number of bars within a given period (i.e.; last 20 bars) that closed bullish and bearish. I came up with this while statement but it doesn't work, it always prints Bull Bars:0 Bear Bars:20. Any thoughts on what I am doing wrong?


// Count bull and bear bars
double open, close;
int bull_bars=0, bear_bars=0;
int bar_count=20; // Bars to count

if(Volume[0] == 1){ // Only check on open of new bar

int bars=0;
while(bars < bar_count){
open=iOpen(NULL,0,bars);
close=iOpen(NULL,0,bars);

if(open<close){bull_bars++;} else {bear_bars++;}

bars++;
}

Print("Bull Bars: ", bull_bars, " Bear Bars: ", bear_bars);
}
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
  #2000 (permalink)  
Old 08-25-2009, 09:11 PM
Junior Member
 
Join Date: Jul 2009
Posts: 8
jerzzhere is on a distinguished road
err, I figured it out. I changed my while to this and it works

while(bar_count > i){
open=iOpen(NULL,0,i);
close=iClose(NULL,0,i);

if(open<close){bull_bars++;}
if(open>close){bear_bars++;}

i++;
}
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: 2 (0 members and 2 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 04:15 AM.



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