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
  #1051 (permalink)  
Old 06-29-2008, 07:31 PM
IN10TION's Avatar
Senior Member
 
Join Date: Mar 2007
Posts: 651
Blog Entries: 1
IN10TION is on a distinguished road
:: the only way to close is NOT to use " == " in your code, instead everything have to close higher or lower then your price, use... higher " >= " price or lower " <= " price, yes price doesn't go like 1 2 3, it can jump from 1 to 5 in volatile market (like big news announcements), hope this helps a little
Quote:
Originally Posted by Ronald Raygun View Post
Hello everyone.

I'm trying to code in an effective and reliable invisible stoploss, trailing stop and takeprofit into my EAs. So far, my code just looks for the bid/ask to equal the stoploss or takeprofit value. If the price equals that value, then close the trade.

The problem I'm having is that sometimes the price seems to skip. There is no progressive movement of price. How do I then get around that problem? and make an invisible TP/SL which is guaranteed to close the trade where necessary?
__________________
NEW UPDate! 04 Nov. 09 IN10TION newsReader v09.98 Lite - the best forex news reader on your chart
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
  #1052 (permalink)  
Old 06-29-2008, 09:33 PM
Member
 
Join Date: Oct 2006
Posts: 80
Big Be is on a distinguished road
Can anyone code this 'simple' task?

luxinterior and ajk,
Thanks. I tried one of those methods before (I will have to find what I did) and it worked great for price but not for an indicator.
Have you successfully done it?
The indicator doesn't matter, if could be any of MT4's built-ins.


Big Be
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
  #1053 (permalink)  
Old 06-30-2008, 02:28 AM
Member
 
Join Date: Sep 2007
Posts: 69
Ronald Raygun is on a distinguished road
Quote:
Originally Posted by Big Be View Post
I want to grab the highest and lowest values of an indicator over an entire chart. A while ago I tried what I thought should have worked, from within an EA, but it didn't.
(Sorry I don't have that attempt now to show you.)

Any ideas?

Big Be
using the iHighest function:

int iHighest( string symbol, int timeframe, int type, int count=WHOLE_ARRAY, int start=0)

set the count to "Bars" so.

iHighest(NULL, 0, 3, Bars, 0);

At least that what I think would work. Just check in your chart settings how many bars you keep in history. Default I think is 52,000 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
  #1054 (permalink)  
Old 06-30-2008, 06:28 AM
Senior Member
 
Join Date: Nov 2006
Posts: 308
luxinterior is on a distinguished road
That works for price. He's wanting to find the highest and lowest of an idicator.

Lux
__________________
Build An Expert Advisor. FREE E-course As Seen On TV
ForexArea.com
Users of Gap Trader from 'Forex-Assistant' MUST Read This
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
  #1055 (permalink)  
Old 06-30-2008, 07:05 AM
Senior Member
 
Join Date: Dec 2005
Location: In front of my trading desk
Posts: 348
Devil2000 is on a distinguished road
Hello,

You can try this :

Code:
....

int highest=0, lowest=0, bar=WindowBarsPerChart();

for(int shift=0;shift<bar;shift++)
 {
    double indie=iCustom(.........,shift);

    if(highest<indie) highest=indie;

    if(lowest==0) lowest=indie;
    if(lowest>indie) lowest=indie;
 } 

.....
note: this code calculating the current open candle too, if you want to calculate the closed candle only, use shift=1.

Hope this helps,
Ardie
__________________
Need a professional MQL4 programmer? PM me
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
  #1056 (permalink)  
Old 06-30-2008, 10:31 AM
IN10TION's Avatar
Senior Member
 
Join Date: Mar 2007
Posts: 651
Blog Entries: 1
IN10TION is on a distinguished road
:: iBarShift will find for you the bar that start on that day/hour... or also the end bar for that day:hour... (depends what timeframe or chart you want to start to find your high/low).

int iBarShift( string symbol, int timeframe, datetime time, bool exact=false)

next...

:: use those bar positions to find the results of iHighest and iLowest

int iHighest( string symbol, int timeframe, int type, int count=WHOLE_ARRAY, int start=0)
int iLowest( string symbol, int timeframe, int type, int count=WHOLE_ARRAY, int start=0)


:: results & done , don't use any loops in this!
__________________
NEW UPDate! 04 Nov. 09 IN10TION newsReader v09.98 Lite - the best forex news reader on your chart
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
  #1057 (permalink)  
Old 06-30-2008, 02:35 PM
Senior Member
 
Join Date: Dec 2005
Location: In front of my trading desk
Posts: 348
Devil2000 is on a distinguished road
Programmaticaly refresh the repaint indicator

Hello,

I'm looking to find a way to refresh a repaint indicator for every x minutes.
The only way to refresh it currently, is to click in the indicator on the chart and then click "ok". Can we automate it with MQL4 code?
I found something on codersguru's site, Programmatically Refresh your charts | www.metatrader.info, but it seems not working for me. Or is there anybody has try it and get different result (working)?

Thank you
__________________
Need a professional MQL4 programmer? PM me

Last edited by Devil2000; 06-30-2008 at 02:40 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
  #1058 (permalink)  
Old 07-02-2008, 12:28 AM
Junior Member
 
Join Date: Jul 2008
Posts: 23
IngvarDagmar is on a distinguished road
Sorry for my Englsih.

I want count number times condition is true only once per bar. Computer add up many times per bar. What wrong I do?
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
  #1059 (permalink)  
Old 07-02-2008, 01:25 AM
Senior Member
 
Join Date: Nov 2006
Posts: 308
luxinterior is on a distinguished road
Quote:
Originally Posted by IngvarDagmar View Post
Sorry for my Englsih.

I want count number times condition is true only once per bar. Computer add up many times per bar. What wrong I do?
Use a function like this...

PHP Code:
bool NewBar() {

    static 
datetime LastTime 0;

    if (
Time[0] != LastTime) {
        
LastTime Time[0];        
        return (
true);
    } else
        return (
false);

Then put an if statement round your main code, like...

PHP Code:
if(NewBar() == true){
// do the main processing here

Hope that helps.

Lux
__________________
Build An Expert Advisor. FREE E-course As Seen On TV
ForexArea.com
Users of Gap Trader from 'Forex-Assistant' MUST Read This
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
  #1060 (permalink)  
Old 07-02-2008, 01:40 AM
TheRumpledOne's Avatar
Banned
 
Join Date: Nov 2006
Posts: 802
TheRumpledOne is an unknown quantity at this point
That was nice of you, Lux.

I found this:

Only process each bar once - MQL4 forum

Automated 2008.01.15 18:54 You could execute your code at the very first tick of a new bar ( i.e. right after the previous bar has closed ).
Here's a function that will return TRUE if a new bar has just formed:
// This function returns TRUE at the very first tick a bar i.e. after the previous bar has just closed
bool NewBar()
{
if(PreviousBarTime<Time[0])
{
PreviousBarTime = Time[0];
return(true);
}

return(false); // in case if - else statement is not executed
} you need to declare datetime PreviousBarTime at the beginning of your EA...
then in your code you could just use
if ( NewBar() )
{
...... code you need to be executed after a bar has closed here ....
} thank you
automatedfx@gmail.com


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

I noticed you used STATIC... I looked it up... what's the advantage of using STATIC vs a global variable?

Last edited by TheRumpledOne; 07-02-2008 at 01:55 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
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: 4 (2 members and 2 guests)
bobcat1_02, slingertje
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 12:41 AM.



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