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
  #71 (permalink)  
Old 04-25-2006, 11:32 AM
Senior Member
 
Join Date: Feb 2006
Posts: 587
Michel is on a distinguished road
Quote:
Originally Posted by codersguru
fxdk,

to check the profit of the last closed order use this code:

int total = HistoryTotal();
OrderSelect(total-1,SELECT_BY_POS,MODE_HISTORY);
Alert(OrderProfit()); //This is the last closed order profit or loss
I think this may be not always true. I had a discussion with Slawa about, and it seems that HISTORY, like TRADE, are not always sorted by date, and depends of the sort colonn you are using on the terminal tab. So it's more secure to scan all (!) History and compare closing dates; then remember the last one so the next time you don't need to scan the whole array.
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
  #72 (permalink)  
Old 04-25-2006, 02:10 PM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 994
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Quote:
Originally Posted by Michel
I think this may be not always true. I had a discussion with Slawa about, and it seems that HISTORY, like TRADE, are not always sorted by date, and depends of the sort colonn you are using on the terminal tab. So it's more secure to scan all (!) History and compare closing dates; then remember the last one so the next time you don't need to scan the whole array.
very good idea!
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
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
  #73 (permalink)  
Old 04-25-2006, 07:38 PM
Senior Member
 
Join Date: Sep 2005
Location: St Louis, MO, USA
Posts: 176
cardio is an unknown quantity at this point
Last order profit

Hi

This is what I use - works well.

[CODE/]///////////
int i,orders;
//Determine if the last trade was a winner or losser
orders = HistoryTotal();
//Print("PP0: orders : ", orders);
for(i=orders-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==fals e)
{
Print("Error in history!");
break;
}

// if((OrderSymbol()!=Symbol()) || (OrderType()>OP_SELL) || (OrderMagicNumber() != MagicNum1)) continue;
//Print("PP11 Profit : ", OrderProfit());
if(OrderProfit()>0)
{
wl = -1;
break;
}
if(OrderProfit()<0)
{
wl = 1;
break;
}
}
[\code]

Last edited by cardio; 04-25-2006 at 07:41 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
  #74 (permalink)  
Old 04-26-2006, 12:30 AM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 994
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Lightbulb History script!

Please check my history script and you'll find the answer I hope so:

http://www.metatrader.info/node/111
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
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
  #75 (permalink)  
Old 04-26-2006, 02:25 PM
FX-Hedger's Avatar
Senior Member
 
Join Date: Dec 2005
Posts: 186
FX-Hedger is on a distinguished road
Cconverting MetaStock code to MT4?

Hello!

Can anyone convert MetaStock code to MT4?

I have "Wolfe Wave" code and needs conversion.

Please find code and documents in attachment.

Thank you.
Attached Files
File Type: txt Wolfe Wave Metastock code .txt (555 Bytes, 74 views)
File Type: doc Wolfe Wave - Street smarts.doc (297.5 KB, 82 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
  #76 (permalink)  
Old 04-26-2006, 02:54 PM
Administrator
 
Join Date: Sep 2005
Posts: 20,059
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
There is good thread about it here.
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
  #77 (permalink)  
Old 04-26-2006, 03:20 PM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 994
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Lightbulb GetLastProfit()

Quote:
Originally Posted by fxdk
Is there a method in mql4 for checking whether the last trade resulted in profit or loss, after it's closed?

I'm trying OrderSelect() and OrderProfit() with the HistoryTotal() using an array.. but the OrderProfit seems to be referring to the 'open order' , so it's not giving me the results im wanting.

On average, my system has 5 consecutive wins, to 1 lose. What im wanting to do is, after a losing trade, i want to increase the number of lots used as the chances are the next trade after it will be a win.

I therefore need to check what the last closed trade resulted in, before modifying the number of lots.

Any help would be appreciated...
For the History script go to:

http://www.metatrader.info/node/111

This is the code you want:

PHP Code:
Alert("LastProfit/Loss : " GetLastProfit());

.............................

double GetLastProfit()
{
   
int total HistoryTotal();
   
   
datetime cur_order 0;
   
datetime last_order=0;
   
double profit=0;
      
   for(
int cnt cnt total cnt++)
   {
      
OrderSelect(cnt,SELECT_BY_POS,MODE_HISTORY);
      
cur_order OrderCloseTime();
      if(
cur_order>last_order)
      {
         
last_order cur_order;
         
profit OrderProfit();
      }
   }
   return (
profit);

__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
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
  #78 (permalink)  
Old 04-26-2006, 05:16 PM
Senior Member
 
Join Date: Oct 2005
Location: Porto/Portugal
Posts: 333
hellkas is on a distinguished road
Quote:
Originally Posted by FX-Hedger
Hello!

Can anyone convert MetaStock code to MT4?

I have "Wolfe Wave" code and needs conversion.

Please find code and documents in attachment.

Thank you.
hi Hedger

I dont know how to convert Meta to Mt4, but i've this indicator...

Hope u like it...
Attached Files
File Type: mq4 Wolf.mq4 (8.6 KB, 125 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
  #79 (permalink)  
Old 04-26-2006, 09:22 PM
FX-Hedger's Avatar
Senior Member
 
Join Date: Dec 2005
Posts: 186
FX-Hedger is on a distinguished road
Quote:
Originally Posted by hellkas
hi Hedger

I dont know how to convert Meta to Mt4, but i've this indicator...

Hope u like it...
Thanks for the Indicator hellka!

This Indicator does not catch the Wolfe Wave acuratly every time.

May be someone can improve it a little?
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
  #80 (permalink)  
Old 05-02-2006, 04:29 PM
Junior Member
 
Join Date: Apr 2006
Posts: 18
fxdk is on a distinguished road
Profit in Pips

Hey,
Can anyone think of a way to calculate the profits as pips, as opposed to profit in $?

ie. a script to return the total number of pips profit so far. Or, the total number of pips profit between month x and month y.

Thanks.
__________________
fxdk
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 05:39 PM.



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