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.
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".
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?
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.).
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.
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.
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 = Time[ bar+10 ];
for ( int i = OrdersHistoryTotal() - 1; i >= 0; i-- ) {
if ( ! OrderSelect( i, SELECT_BY_POS, MODE_HISTORY )
continue;
if ( OrderProfit() < 0 && 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.