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
  #1171 (permalink)  
Old 08-19-2008, 08:28 PM
Junior Member
 
Join Date: Aug 2008
Posts: 1
surisriram is on a distinguished road
Alerts that last longer

hi i am newbie trying to understand ins and outs of this and any help will be appreciated!!
my current indicator has the following code for generating alerts, but this alert lasts for only one beep, is there any way i can make it to beep for 30 or 60 sec or atleast bit longer than 1 beep

if (setalert == 1 && shift == 0) {
Alert(Symbol(), " ", period, " ", pattern);
setalert = 0;
}


Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1172 (permalink)  
Old 08-20-2008, 07:37 AM
raja_ar_radu's Avatar
Junior Member
 
Join Date: Jul 2006
Posts: 3
raja_ar_radu is on a distinguished road
Re Coding to metatrader (Klinger Volume Oscillator)

The Klinger Oscillator (KO) was developed by Stephen J. Klinger. Learning from prior research on volume by such well-known technicians as Joseph Granville, Larry Williams, and Marc Chaikin, Mr. Klinger set out to develop a volume-based indicator to help in both short- and long-term analysis.

The KO was developed with two seemingly opposite goals in mind: to be sensitive enough to signal short-term tops and bottoms, yet accurate enough to reflect the long-term flow of money into and out of a security.

The KO is based on the following tenets:

* Price range (i.e. High - Low) is a measure of movement and volume is the force behind the movement. The sum of High + Low + Close defines a trend. Accumulation occurs when today's sum is greater than the previous day's. Conversely, distribution occurs when today's sum is less than the previous day's. When the sums are equal, the existing trend is maintained.
* Volume produces continuous intra-day changes in price reflecting buying and selling pressure. The KO quantifies the difference between the number of shares being accumulated and distributed each day as "volume force". A strong, rising volume force should accompany an uptrend and then gradually contract over time during the latter stages of the uptrend and the early stages of the following downtrend. This should be followed by a rising volume force reflecting some accumulation before a bottom develops.
* By converting the volume force into an oscillator representing the difference between a 34-period and 55-period exponential moving average with a 13-period trigger, the force of volume into and out of a security can easily be tracked. Comparing this force to price action can help identify divergences at tops and bottoms.

Interpretation

Mr. Klinger recommends the following guidelines for using the KO:

1. The most reliable signals occur in the direction of the prevailing trend. Strict stop guidelines (i.e., failure to penetrate the zero line or a violation of the trigger line) should remain in force.
2. The most important signal occurs when the KO diverges with the underlying price action, especially on new highs or new lows in overbought/oversold territory. For example, when a stock makes a new high or low for a cycle and the KO fails to confirm this, the trend may be losing momentum and nearing completion.
3. If the price is in an uptrend (i.e., above an 89-day exponential moving average), buy when the KO drops to unusually low levels below zero, turns up, and crosses its trigger line. If the price is in a downtrend (i.e., below an 89-day exponential moving average), sell when the KO rises to unusually high levels above zero, turns down, and crosses its trigger line.

While the KO works well for timing trades in the direction of the trend, it is less effective against the trend. This can create problems for the trader trying to "scalp" a trade against the prevailing trend. However, when the KO is used in conjunction with other technical indicators, better results can be achieved. William's %R is recommended for confirming an overbought/oversold price condition and Gerald Appel's MACD is recommended for confirming the short-term direction of price.

Tip

Stephen Klinger suggests the following formula for viewing the cumulative flow of money into and out of a security:

cum(kvo())

Plot a 13-period moving average of the formula as a trigger line for entering buy and sell trades.

source codenya untuk trade station

Type: Function, Name: VForce

Vars: TSum(0), Trend(0), DM(0), CM(0);

TSum = High + Low + Close;
IF TSum > TSum[1] Then

Trend = 1
Else
Trend = -1;
IF Trend = Trend[1] Then
CM = CM + Range
Else
CM = Range + Range[1];
IF CM <> 0 Then
VForce = Volume * AbsValue(2 * (DM/CM) -1) * Trend * 100;





Type: Function, Name: KVO

Inputs:
FastX(Numeric),
SlowX(Numeric); Vars:
FXAvg(0),
SXAvg(0);

FXAvg = XAverage(VForce, FastX);
SXAvg = XAverage(VForce, SlowX);
KVO = FXAvg - SXAvg;


Type: Indicator, Name: Klinger Volume Oscillator

Inputs:
FastX(34),
SlowX(55),
TrigLen(13),
Smooth(1);

Vars:
Trigger(0);Trigger = XAverage(KVO(FastX, SlowX), TrigLen);IF Smooth <= 1 Then Begin
Plot1(KVO(FastX, SlowX), "KVO");
Plot2(Trigger, "KVO Trigger");
End Else BeginPlot1(Summation(KVO(FastX, SlowX), Smooth), "KVO");
Plot2(Summation(Trigger, Smooth), "KVO Trigger");
End;

Plot3(0, "Zero");
IF Plot1 Crosses Above Plot2 OR Plot1 Crosses Below Plot2 OR
Plot2 Crosses Above Plot3 OR Plot2 Crosses Below Plot3 Then
Alert = True;

someone would like to help me to convert this coding into Mql4?

thks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1173 (permalink)  
Old 08-20-2008, 03:29 PM
Member
 
Join Date: Jul 2007
Posts: 71
zmax is on a distinguished road
for CEHansen

Hi,

Inside that the for where you take the bars one by one you have to use i variable everywhere instead of Current. Current is uninitialised so it's 0.
The easyest way to see that is put inside the for at the begining this:
Current = i;
The arrows will appear. Also don't forget to use a bigger value for Sto_Lookback. Mabe 100,1000 or something like that.

P.S Use to make the for like this it is better from my point of view.

for (int i = Sto_Lookback; i >0; i--){
...
}

Because this is the normal way of "bars" comming 0 is the last one. It would save you of some other trubles later. (for example - repainting). Just a thought.

Thanks,
Victor
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1174 (permalink)  
Old 08-20-2008, 04:23 PM
Junior Member
 
Join Date: Nov 2007
Posts: 8
CEHansen is on a distinguished road
Thanks Victor!

I got the arrows to show by doing what you suggested. Turned out the indicator is not really doing what I intended it to do, LOL!

Hereīs what I want "i" to be:
take these lines as an example...

//short stochastics value at "i"
double sto_short = iStochastic(NULL, 0, 8, 3, 3, MODE_SMA, 0, MODE_MAIN, i);

//long stochastics value at "i"
double sto_long = iStochastic(NULL, 0, 36, 3, 3, MODE_SMA, 0, MODE_MAIN, i);

//if short stochastics move up... and both short and long stochastics
//have both been below 25 anywhere within the last "i" bars then stochup is true
if (sto_short_now > sto_short_pre && sto_short <= 25 && sto_long <= 25)
{stochup = true;}


My intend: if sto_short and sto_long have both been <= 25 at one of the last (sto_lookback) bars... then stochup is true...

thatīs what I wrote the "for" loop for... which I obviously screwed up big time, LOL...

I donīt really have a clue how to get this done...

Thanks again,

CEH
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1175 (permalink)  
Old 08-21-2008, 06:47 AM
Member
 
Join Date: Oct 2006
Posts: 71
Big Be is on a distinguished road
Klinger Volume Oscillator

I looked this up, looks like an interesting indicator.
However it relys in part on volume, which is not really available in Forex.

Big Be
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1176 (permalink)  
Old 08-21-2008, 09:34 PM
Member
 
Join Date: May 2008
Posts: 54
fireslayer26 is on a distinguished road
Order Modify Error 1

On my backtesting I keep getting the occasional "OrderModify error1". From what I can figure it means that there is no change, i.e. OrderModify() arguments are the same that corresponding parameters of the modified order.
This might be due to double comparison issue.

Question is how might I solve this issue?

Here's the area I believe is causing the problem:

if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen);
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy");
if (!EachTickMode) BarCount = Bars;
IsTrade = False;
continue;
}
//MoveOnce
if(MoveStopOnce && MoveStopWhenPrice > 0) {
if(Bid - OrderOpenPrice() >= Point * MoveStopWhenPrice) {
if(OrderStopLoss() < OrderOpenPrice() + Point * MoveStopTo) {
OrderModify(OrderTicket(),OrderOpenPrice(), OrderOpenPrice() + Point * MoveStopTo, OrderTakeProfit(), 0, Red);
if (!EachTickMode) BarCount = Bars;
continue;
}
}
}
//Trailing stop
if(UseTrailingStop && TrailingStop > 0) {
if(Bid - OrderOpenPrice() > Point * TrailingStop) {
if(OrderStopLoss() < Bid - Point * TrailingStop) {
OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * TrailingStop, OrderTakeProfit(), 0, MediumSeaGreen);
if (!EachTickMode) BarCount = Bars;
continue;
}
}
}
} else {
//Close

//+------------------------------------------------------------------+
//| Signal Begin(Exit Sell) |
//+------------------------------------------------------------------+


//+------------------------------------------------------------------+
//| Signal End(Exit Sell) |
//+------------------------------------------------------------------+

if (Order == SIGNAL_CLOSESELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, DarkOrange);
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Close Sell");
if (!EachTickMode) BarCount = Bars;
IsTrade = False;
continue;
}
//MoveOnce
if(MoveStopOnce && MoveStopWhenPrice > 0) {
if(OrderOpenPrice() - Ask >= Point * MoveStopWhenPrice) {
if(OrderStopLoss() > OrderOpenPrice() - Point * MoveStopTo) {
OrderModify(OrderTicket(),OrderOpenPrice(), OrderOpenPrice() - Point * MoveStopTo, OrderTakeProfit(), 0, Red);
if (!EachTickMode) BarCount = Bars;
continue;
}
}
}
//Trailing stop
if(UseTrailingStop && TrailingStop > 0) {
if((OrderOpenPrice() - Ask) > (Point * TrailingStop)) {
if((OrderStopLoss() > (Ask + Point * TrailingStop)) || (OrderStopLoss() == 0)) {
OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * TrailingStop, OrderTakeProfit(), 0, DarkOrange);
if (!EachTickMode) BarCount = Bars;
continue;
}
}
}
}
}
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1177 (permalink)  
Old 08-22-2008, 01:47 AM
matrixebiz's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 1,174
matrixebiz is on a distinguished road
Code Question

What does i++ or i-- mean in coding?
Eg: for (int i=5; i>0; i--)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1178 (permalink)  
Old 08-22-2008, 02:16 AM
Member
 
Join Date: Jan 2006
Posts: 56
hiachiever is on a distinguished road
Quote:
Originally Posted by matrixebiz View Post
What does i++ or i-- mean in coding?
Eg: for (int i=5; i>0; i--)
It is short hand in C based langauges for incrementing or decrementing a number based variable.

For example in Visual Basic you would have to write.
i = i + 1 to increment the i variable.
however, in C you can simply write i++.

Hope this helps.

Hiachiever
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1179 (permalink)  
Old 08-22-2008, 02:53 AM
matrixebiz's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 1,174
matrixebiz is on a distinguished road
Quote:
Originally Posted by hiachiever View Post
It is short hand in C based langauges for incrementing or decrementing a number based variable.

For example in Visual Basic you would have to write.
i = i + 1 to increment the i variable.
however, in C you can simply write i++.

Hope this helps.

Hiachiever
Thanks,
so if I put if (int i=6; i>0; i++)

it will 'loop' or keep checking value until 6 max? not sure if that is right. What if I use i--? Please clarify
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1180 (permalink)  
Old 08-22-2008, 03:00 AM
Member
 
Join Date: Jan 2006
Posts: 56
hiachiever is on a distinguished road
Quote:
Originally Posted by matrixebiz View Post
Thanks,
so if I put if (int i=6; i>0; i++)

it will 'loop' or keep checking value until 6 max? not sure if that is right. What if I use i--? Please clarify
Matrixebiz,

if you want to start at 6 and go back to 0 then use i--

(int i=6; i>0; i--)

This will start at 6, decrement by 1 on each loop for as long as I > 0.
If you want to include 0 then use i>=0.

Cheers,
Hiachiever
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 12:29 PM.



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