You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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
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.
Hi,
look at this https://www.mql5.com/en/forum/173255
and https://www.mql5.com/en/forum/173255.
Igor
Igorad, thank you very much, the Volty Channel Stop was excactly what I was looking for
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[]:
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
Yessiree, any help at all.....
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
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...
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
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 lossI 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.