Forex
Google
New signals service!

Go Back   Forex Trading > Programming > Metatrader Programming


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack (1) Thread Tools Display Modes
  #71 (permalink)  
Old 04-25-2006, 11:32 AM
Senior Member
 
Join Date: Feb 2006
Posts: 559
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!
Reply With Quote
  #72 (permalink)  
Old 04-25-2006, 02:10 PM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 986
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!
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!
Reply With Quote
  #74 (permalink)  
Old 04-26-2006, 12:30 AM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 986
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!
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, 62 views)
File Type: doc Wolfe Wave - Street smarts.doc (297.5 KB, 70 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #76 (permalink)  
Old 04-26-2006, 02:54 PM
Administrator
 
Join Date: Sep 2005
Posts: 16,816
Blog Entries: 145
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!
Reply With Quote
  #77 (permalink)  
Old 04-26-2006, 03:20 PM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 986
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!
Reply With Quote
  #78 (permalink)  
Old 04-26-2006, 05:16 PM
Senior Member
 
Join Date: Oct 2005
Location: Porto/Portugal
Posts: 284
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, 99 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl 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!
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!
Reply With Quote
Reply

Bookmarks

Tags
candle time, CHinGsMAroonCLK, coders guru, expert advisor, forex, how to code, I_XO_A_H, mechanical trading, trading

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

LinkBacks (?)
LinkBack to this Thread: http://www.forex-tsd.com/metatrader-programming/554-how-code.html
Posted By For Type Date
Need an experienced programmer? - Page 2 Post #0 Refback 09-24-2008 07:24 AM

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 08:46 AM.



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