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
  #661 (permalink)  
Old 01-31-2008, 05:22 PM
Senior Member
 
Join Date: Mar 2006
Posts: 137
criss73 is on a distinguished road
Help with EA!

I've got this EA i'm using but needs additional tweaking. Is there anybody that can add an option to shut down the EA after a take profit. Also, i've noticed that it doesn't open a position if it gets a "requote". How can I rectify this problem? For example: EA opens a buy@.10 stops out then opens a Sell@.20 stops out and doesn't open a buy@.4 because of "requote".

Thnx
Attached Files
File Type: mq4 Breakthrough 1b.mq4 (5.1 KB, 23 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
  #662 (permalink)  
Old 02-02-2008, 03:56 PM
nittany1's Avatar
Senior Member
 
Join Date: Dec 2006
Location: Sarasota, FL
Posts: 207
nittany1 is on a distinguished road
counter?

I've been programming indicators for so many months that I'm a little deficient in experts but I'm intending to solve that. Along the way I need a little help. In my expert that I threw together I have it check at bar close if there is a condition that would warrant closing the trade.

I start with a global variable,

Code:
//--- Global variable
datetime PreviousBar;   // record candle/bar time
and set one bool in init()

Code:
int init()
  {
   do_this = true;
  }
blah blah boring stuff.... etc, etc
then in the main loop I have:
Code:
   if(do_this == true)
   {
      PreviousBar = Time[0];     
      do_this= false;    // so it does this only once only
   }

   if(NewBar() == true)
   {
      if(TotalOpenOrders() == blah blah close my order you crazy monkey)
   }
and outside the main loop I have:

Code:
//--- returns true if current bar just formed
bool NewBar()
{
   if(PreviousBar<Time[0])
   {
      PreviousBar = Time[0];
      return(true);
   }
   else
   {
      return(false);
   }
   return(false);  
}
OK so it is setup to do once per bar. What I want to do is have a function that increments 90 seconds or 60 seconds or whatever, then sets a bool to true after it's incremented that time. Basically I want to check the indicators every 60, 90, 120 seconds or whatever instead of at bar close. How do I do that?

Thanks for any help,

- nittany1
__________________
The best things in life come from open source development.
Myspace Facebook My Indicators: Trade Assistant Trend Friend ToR CCI Helper
Holder of US Patent 6,774,788

Last edited by nittany1; 02-02-2008 at 04:14 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
  #663 (permalink)  
Old 02-02-2008, 05:41 PM
Senior Member
 
Join Date: Jan 2006
Posts: 1,119
omelette is on a distinguished road
Quote:
Originally Posted by nittany1 View Post
I've been programming indicators for so many months that I'm a little deficient in experts but I'm intending to solve that. Along the way I need a little help. In my expert that I threw together I have it check at bar close if there is a condition that would warrant closing the trade.

I start with a global variable,

Code:
//--- Global variable
datetime PreviousBar;   // record candle/bar time
and set one bool in init()

Code:
int init()
  {
   do_this = true;
  }
blah blah boring stuff.... etc, etc
then in the main loop I have:
Code:
   if(do_this == true)
   {
      PreviousBar = Time[0];     
      do_this= false;    // so it does this only once only
   }

   if(NewBar() == true)
   {
      if(TotalOpenOrders() == blah blah close my order you crazy monkey)
   }
and outside the main loop I have:

Code:
//--- returns true if current bar just formed
bool NewBar()
{
   if(PreviousBar<Time[0])
   {
      PreviousBar = Time[0];
      return(true);
   }
   else
   {
      return(false);
   }
   return(false);  
}
OK so it is setup to do once per bar. What I want to do is have a function that increments 90 seconds or 60 seconds or whatever, then sets a bool to true after it's incremented that time. Basically I want to check the indicators every 60, 90, 120 seconds or whatever instead of at bar close. How do I do that?

Thanks for any help,

- nittany1
This should do it. Remember that MT uses tick-based execution so per-second-accuracy is not possible (unless you loop everything in the Init() sub.).

if (CallIndicatorsCheck())
{
// your code here
}

bool CallIndicatorsCheck()
{
static datetime Oldtime;
int Secs = 90;
bool Flag;

if (CurrTime() >= Oldtime) {
Oldtime = CurrTime() + Secs;
Flag = true; }

return(Flag);
}
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
  #664 (permalink)  
Old 02-04-2008, 02:03 AM
wolfe's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 818
wolfe is on a distinguished road
Comment placement

Could someone show me the code to place a comment in the UPPER RIGHT corner of the screen, rather than the default upper left?

Thanks!
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
  #665 (permalink)  
Old 02-04-2008, 02:27 AM
Linuxser's Avatar
User Root
 
Join Date: May 2006
Location: Helliconia (Winter)
Posts: 4,410
Blog Entries: 56
Linuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond repute
Quote:
Originally Posted by wolfe View Post
Could someone show me the code to place a comment in the UPPER RIGHT corner of the screen, rather than the default upper left?

Thanks!
You can't. From MQL4 manual:

Quote:
void Comment( ...)The function outputs the comment defined by the user in the left top corner of the chart.

If you need by death you could could create objects.
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
  #666 (permalink)  
Old 02-04-2008, 03:24 AM
mog's Avatar
mog mog is offline
Junior Member
 
Join Date: Oct 2005
Posts: 11
mog is on a distinguished road
Quote:
Originally Posted by wolfe View Post
Could someone show me the code to place a comment in the UPPER RIGHT corner of the screen, rather than the default upper left?

Thanks!

LinusGuy is right; there's no direct way. The easy workaround is to pad your Comment with spaces --
Comment(" <lots of spaces> hello world!");
willl offset the text to the right.
You can also put in line feeds to drop down the page.

Comment("\n\n\n\n\nyour text");

or combine linefeeds and space to print at the lower right-hand corner of the screen.

mog
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
  #667 (permalink)  
Old 02-04-2008, 06:33 AM
wolfe's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 818
wolfe is on a distinguished road
Quote:
Originally Posted by mog View Post
LinusGuy is right; there's no direct way. The easy workaround is to pad your Comment with spaces --
Comment(" <lots of spaces> hello world!");
willl offset the text to the right.
You can also put in line feeds to drop down the page.

Comment("\n\n\n\n\nyour text");

or combine linefeeds and space to print at the lower right-hand corner of the screen.

mog
Thanks for the help. I'll try it!
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
  #668 (permalink)  
Old 02-04-2008, 08:30 AM
Junior Member
 
Join Date: Apr 2007
Posts: 3
mikerawson is on a distinguished road
no new trade for X bars after a losing trade

hi team - hoping someone can help please..

how do i stop a new trade from commencing for 10 bars if the last trade was a loss?

cheers
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
  #669 (permalink)  
Old 02-04-2008, 08:59 AM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 297
ralph.ronnquist is on a distinguished road
The function below will return true while the account history has a loss trade that closed at or after the opening of the 10:th past bar (current bar is 0),
and return false otherwise.

PHP Code:
bool postMortem()
{
    
datetime since Timebar+10 ];
    for ( 
int i OrdersHistoryTotal() - 1>= 0i-- ) {
        if ( ! 
OrderSelectiSELECT_BY_POSMODE_HISTORY )
            continue;
        if ( 
OrderProfit() < && OrderCloseTime() >= since )
            return( 
true );
    }
    return( 
false );

If you add that function to your EA, then include a statement like the following in the start() function, then Bob's your uncle.
PHP Code:
if ( postMortem() ) return( ); 
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
  #670 (permalink)  
Old 02-04-2008, 07:10 PM
Junior Member
 
Join Date: Apr 2007
Posts: 3
mikerawson is on a distinguished road
thx very much for that - i will try it
regards
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 04:31 PM.



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