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
  #411 (permalink)  
Old 10-12-2007, 01:40 AM
wolfe's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 818
wolfe is on a distinguished road
Quote:
Originally Posted by jimven View Post
Save the current bar's highest quoted value to a variable. Every time you get another quote, compare it with the value of the variable. If the new value is higher, save it to the variable. If the new value is lower, keep the variable the same.

if(variable < newquote)
variable = newquote;

Hope that helps!
Thank you for the help, I have one question though. What happens when the current bar is no longer the bar that the order opened in? What if the order opened in the bar 5 bars ago? Now I want the highest quoted value of 5 bars, the highest quoted price since the order opened. Will this still work?

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
  #412 (permalink)  
Old 10-12-2007, 01:43 AM
wolfe's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 818
wolfe is on a distinguished road
Quote:
Originally Posted by jimven View Post
Save the current bar's highest quoted value to a variable. Every time you get another quote, compare it with the value of the variable. If the new value is higher, save it to the variable. If the new value is lower, keep the variable the same.

if(variable < newquote)
variable = newquote;

Hope that helps!
Now that I think about it, your suggestion will probably work. Thank you! I'll try it out.
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
  #413 (permalink)  
Old 10-12-2007, 05:06 PM
jimven's Avatar
Senior Member
 
Join Date: Mar 2007
Location: Upstate New York
Posts: 140
jimven is on a distinguished road
Quote:
Originally Posted by wolfe View Post
Now that I think about it, your suggestion will probably work. Thank you! I'll try it out.
Good. When the trade position is closed, you want to set the variable to zero. When the next trade opens, you start the process again.

Of course my example was for a "BUY" position. For "SELL," you want to get the lowest value saved.
__________________
Success is more perspiration than inspiration . . .
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
  #414 (permalink)  
Old 10-12-2007, 06:25 PM
Member
 
Join Date: Sep 2006
Posts: 59
waaustin is on a distinguished road
Help with negative values ??

Could anyone share with what syntax and instructions I would use in mql to write some code in EA using the following:

(OrderProfit() < 0).

Except I really want to know when OrderProfit() is some specific value less than zero such as when the profit on an open trade is -1,250.00. For example:

if (OrderProfit() < -1,250.00).

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
  #415 (permalink)  
Old 10-13-2007, 01:49 AM
wolfe's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 818
wolfe is on a distinguished road
Quote:
Originally Posted by waaustin View Post
Could anyone share with what syntax and instructions I would use in mql to write some code in EA using the following:

(OrderProfit() < 0).

Except I really want to know when OrderProfit() is some specific value less than zero such as when the profit on an open trade is -1,250.00. For example:

if (OrderProfit() < -1,250.00).

Thanks
I think you have the right idea. However you would probably want to use if (OrderProfit() <= -1250.00) Your OrderProfit() may never = -1,250.00, especially if a position is held for more than a day and swaps are involved. I think you would be safer to use less than or equal (<=). You may want to set an external double variable so you can change the negative amount if you wish to. Such as external double Loss_Value = -1250.00; then you could use if (OrderProfit() <= Loss_Value).

Hope this helps
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
  #416 (permalink)  
Old 10-13-2007, 06:57 PM
Junior Member
 
Join Date: Oct 2007
Posts: 1
vonokpasah is on a distinguished road
Unhappy I Need Help

I am appealing to the experts out there to please come to my aid i need some to help me buld an EXPERT ADVISER META 4 TRADER for me i would be greatfull if my request is granted.
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
  #417 (permalink)  
Old 10-14-2007, 08:02 AM
Administrator
 
Join Date: Sep 2005
Posts: 20,058
Blog Entries: 241
newdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud of
Quote:
Originally Posted by vonokpasah View Post
I am appealing to the experts out there to please come to my aid i need some to help me buld an EXPERT ADVISER META 4 TRADER for me i would be greatfull if my request is granted.
Hi vonokpasah,

Just for information: we are having few very good threads with templates to create EAs and indicators. For example:

Templates to create EAs and Indicators:
- some good templates are here;
- templates with some new codes are here.
- Programming Modules with many programming functions are here.
- function of "mql4 code": thread with codes.

To use those templates and to create your own EA so you will need some very preliminary knowledge and it is basicly related to this thread http://www.forex-tsd.com/general-dis...der-forex.html

If you don't want to do some routine coding so you may automate this job: use this EA builder Expert Advisor Builder for MetaTrader 4 (it is free) and use this program Forex Trading with Gordago Forex Broker - Best Forex Software for Creating Forex Trading System! (I bought it for $9 long time ago - don't know about the price now). But to use those builders so you will need this thread first with Codersguru lessans http://www.forex-tsd.com/general-dis...der-forex.html
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
  #418 (permalink)  
Old 10-15-2007, 03:01 AM
jimven's Avatar
Senior Member
 
Join Date: Mar 2007
Location: Upstate New York
Posts: 140
jimven is on a distinguished road
Using variables in an EA

Remember that any time you store data to temporary variables in an EA, the data will be gone if you reinitialize or restart the EA (or reboot your computer). This could have unexpected consequences regarding your trades. One possibility is that open trades will close, for example.

You can store data to Global Variables (using GlobalVariableSet and GlobalVariableGet). They remain in the terminal for two weeks (I think), even if undisturbed by your EA. But of course such data could quickly become just as problematic as lost data if you have a computer equipment problem.

In any event, your EA should be written defensively to prepare for loss of connection and the possibility of reinitialization.
__________________
Success is more perspiration than inspiration . . .
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
  #419 (permalink)  
Old 10-15-2007, 04:41 PM
Senior Member
 
Join Date: Feb 2007
Posts: 175
Flytox is on a distinguished road
Good Day
i'am learning mql4 and have difficulties to understand some functions example:
Code:
 for( shift=limit; shift>=0; shift--)
   {
   double RSI = iRSI(NULL,0,RSILength,PRICE_CLOSE,shift);
   SmRSI[shift]= SmRSI[shift+1] + 2./(Smooth+1)*(RSI - SmRSI[shift+1]);  
   
      if(SmRSI[shift] > SmRSI[shift+1]) {double hRSI = SmRSI[shift]; double lRSI = SmRSI[shift+1];}
      else 
      if(SmRSI[shift] < SmRSI[shift+1]) {hRSI = SmRSI[shift+1]; lRSI = SmRSI[shift];}
      else
      {hRSI = SmRSI[shift]; lRSI = SmRSI[shift];}
   
   ATRRSI[shift] = hRSI - lRSI;
I don't see how it is possible to know SmRSI value with the following line, knowing that it has not been defined before and seems to me mathematically impossible.
Code:
SmRSI[shift]= SmRSI[shift+1] + 2./(Smooth+1)*(RSI - SmRSI[shift+1]);
Could anyone explain please.
PS: it's a pîece of code from Igorad trendstrength indi.
Thnaks
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
  #420 (permalink)  
Old 10-15-2007, 06:41 PM
Senior Member
 
Join Date: Feb 2007
Posts: 175
Flytox is on a distinguished road
May be i understood the code above:
We can affect a value to smRsi because it use the same index then the iRsi().
Can someone confirm 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
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:43 PM.



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