Forex



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
 
Thread Tools Display Modes
  #61 (permalink)  
Old 04-15-2006, 10:03 AM
Junior Member
 
Join Date: Apr 2006
Posts: 12
Capablanca is on a distinguished road
How to Code Alerts/Alarms for indicators?

Hello I'd like to learn more about how to code alerts.

I'm not a programmer but I have a head on my shoulders and am generally able to tinker with something, pick it apart, and put it back together again closer to the way I want it.

I've gone through some of the indicators with alerts and have copied the general alert functions I've seen to other indicators I've wanted to have alerts. I've had mixed results.

I notice that the main functions called for alerts are the Alert() function, the Comment() function, and the Playsound() function. So far I'm most familiar with the Alert() function. Is there a significant difference between Alert() and Playsound() for example?

The general problem I have is that I don't know how to code the alerts enough so that they are both noticeable on the one hand but not ridiculously distracting on the other. For example if using the Alert() function for some crosses and the indicator has not printed with finality on the current bar the alert might repeat over and over and over and I have trouble turning the alert off. Usually I have to change the time frame of the chart.

First of all is there a simple way to disable/deactivate the alert for the current bar only?

Second, is there a way to code an alert so that it isn't an unending annoying nuisance by introducing code that restricts the number of iterations or gives the alert a fixed duration? How would you code it?

One solution I see is to delay the alert until the next bar so that it isn't constantly changing but that does have the disadvantage of not being timely.

To avoid the hassle of berserk alarms on indicators, I've used the predetermined price alerts that one can set using the terminal window and it helps but it isn't ideal.

I'm also aware that Expert Advisors could be created to give alerts and that there is a button that can turn their alerts on and off easily. The problem I have with EAs, however, is that I notice that another important program I run concurrently with MetaTrader seems to experience interference when Expert Advisors are activated and runs sluggishly.

Are there any other solutions to this problem?

If there any indicators out there that have an alert code that avoids the pitfalls I have enumerated and can serve as a good example of how to code and alert could you please refer me to it and/or post it?

Thank you very much.

Last edited by Capablanca; 04-15-2006 at 10:10 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
  #62 (permalink)  
Old 04-15-2006, 04:09 PM
keris2112's Avatar
Senior Member
 
Join Date: Dec 2005
Location: California, US
Posts: 130
keris2112 is on a distinguished road
As I understand it, the best/easiest way to do it is going to be to look at the previous bar, as you have said. You may be late and you may not. Here's what I mean:

The Start() function processes every tick. MT4, by way of design, only processes time after a tick. That mean a new bar doesn't appear on your chart until the first tick of that new bar. So, as you near the end of a bar, if your alert goes off after every tick (the annoying way) you'll get an alert on the last tick of the bar. If you look to the previous bar for your alert (the non-annoying way), you'll get an alert on the first tick of the new bar.

So, during hours with a lot a market activity, the first tick of the new bar may take place immediately after the previous bar should be closing (based on time). During slow market hours, it could be 20-30 seconds before a new tick comes in, and MT 4 won't show you the new bar until you get that first tick.

I hope that's clear.

Keris
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
  #63 (permalink)  
Old 04-19-2006, 05:40 PM
multa's Avatar
Junior Member
 
Join Date: Feb 2006
Posts: 18
multa is on a distinguished road
Need help to code "The Volatility Stop Entry Technique"

The Volatility Stop calculates the volatility by using the average range of the price bar. It is calculated by multiplying the average range bya constant. The value is added to the lowest close when short, and subtracted from the highest high when long:
Range = (Range x (N - 1) + High - Low / N)
Short = Lowest Close + Range x C
Long = Highest Close - Range x C
It is best to use the Volatility Stop in strongly trending markets. It is an excellent entry technique and in most instances will be superior to valid trend line breaks, or channel breakouts. The reverse stop also acts to quantify risk as it relates to volatility. The constants should be kept between 2.5 and 4.0.


I have no personal experience with this indicator, but I have read about it in the book "Fibonacci Ratios with Pattern Recognition".
I would be verry happy if somone could code this indicator.
Attached Images
File Type: bmp v.s..bmp (961.7 KB, 662 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
  #64 (permalink)  
Old 04-19-2006, 06:27 PM
igorad's Avatar
Senior Member
 
Join Date: Oct 2005
Location: Ukraine
Posts: 956
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #65 (permalink)  
Old 04-19-2006, 08: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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #66 (permalink)  
Old 04-19-2006, 11:16 PM
Senior Member
 
Join Date: Mar 2006
Posts: 124
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #67 (permalink)  
Old 04-23-2006, 12:55 AM
Senior Member
 
Join Date: Mar 2006
Posts: 124
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #68 (permalink)  
Old 04-23-2006, 02:00 AM
lowphat's Avatar
Senior Member
 
Join Date: Sep 2005
Posts: 200
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 02: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
  #69 (permalink)  
Old 04-24-2006, 05: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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #70 (permalink)  
Old 04-24-2006, 05:22 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 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!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

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 06:23 PM.



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