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
  #61 (permalink)  
Old 04-19-2006, 05:27 PM
igorad's Avatar
Senior Member
 
Join Date: Oct 2005
Location: Ukraine
Posts: 814
igorad is on a distinguished road
Hi,

look at this http://www.forex-tsd.com/4357-post6.html
and http://www.forex-tsd.com/6239-post9.html.

Igor
__________________
Let's improve trade skills together
http://finance.groups.yahoo.com/group/TrendLaboratory
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #62 (permalink)  
Old 04-19-2006, 07:39 PM
multa's Avatar
Junior Member
 
Join Date: Feb 2006
Posts: 18
multa is on a distinguished road
Igorad, thank you very much, the Volty Channel Stop was excactly what I was looking for
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #63 (permalink)  
Old 04-19-2006, 10:16 PM
Member
 
Join Date: Mar 2006
Posts: 91
ZTrader is on a distinguished road
Please help with this code...

I'm trying to learn about the mechanism of the LSMA_in_color indicator, which I found elsewhere on this forum. The following code sets the color of the indicator line segments based on the values in wt[]:
Code:
//========== COLOR CODING ===========================================               
        
       ExtMapBuffer3[shift] = wt[shift]; //yellow 
       ExtMapBuffer2[shift] = wt[shift]; //blue
       ExtMapBuffer1[shift] = wt[shift]; //red
             
        if (wt[shift+1] > wt[shift])
        {
        ExtMapBuffer2[shift] = EMPTY_VALUE; //turn blue off
        Print ("red ",wt[shift+1]," ",wt[shift]);
        }
        else if (wt[shift+1] < wt[shift]) 
        {
        ExtMapBuffer1[shift] = EMPTY_VALUE; //turn red off
        Print ("blue ",wt[shift+1]," ",wt[shift]);
        }
        else 
        {         
        ExtMapBuffer1[shift]=EMPTY_VALUE; //turn red off;
        ExtMapBuffer2[shift]=EMPTY_VALUE; //turn blue off;
        Print ("yellow ",wt[shift+1]," ",wt[shift]);
        }
I added Print() functions so I could see what the actual values are in the three color conditions - red, yellow and blue. It seems that the yellow condition only occurs when wt[shift] == wt[shift+1], but for some reason when I run this the log shows that it never enters the yellow condition. Every log entry written is either red or blue. On the chart, there are clearly yellow conditions occurring - every time it changes from red to blue or blue to red it goes to yellow in between... Why isn't it printing the yellow conditions to the log?

Also, in looking at the log I see instances where wt[shift] is identical to wt[shift+1], but it prints as a red condition. How can this occur when the red condition requires that wt[shift+1] > wt[shift] ?

Any help would be appreciated
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #64 (permalink)  
Old 04-22-2006, 11:55 PM
Member
 
Join Date: Mar 2006
Posts: 91
ZTrader is on a distinguished road
Yessiree, any help at all.....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #65 (permalink)  
Old 04-23-2006, 01:00 AM
lowphat's Avatar
Senior Member
 
Join Date: Sep 2005
Posts: 199
lowphat is on a distinguished road
im a real noob at code but looks like yellow is always on and either red or blue gets put on top of it or jsut replaces it unless its even in which case nothing gets drawn on top of yellow. as far as it still being red when they are even dunno

Last edited by lowphat; 04-23-2006 at 01:55 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #66 (permalink)  
Old 04-24-2006, 04:15 PM
Junior Member
 
Join Date: Apr 2006
Posts: 18
fxdk is on a distinguished road
code to check if last [closed] trade was a win or lose..

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...
__________________
fxdk
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #67 (permalink)  
Old 04-24-2006, 04:22 PM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 987
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
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...
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
__________________
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
  #68 (permalink)  
Old 04-25-2006, 10:32 AM
Senior Member
 
Join Date: Feb 2006
Posts: 525
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
  #69 (permalink)  
Old 04-25-2006, 01:10 PM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 987
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
  #70 (permalink)  
Old 04-25-2006, 06: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 06:41 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
CHinGsMAroonCLK, I_XO_A_H

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 06: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 04:22 PM


All times are GMT. The time now is 07:30 PM.



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