Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.
From the list below, select the forum that you want to visit and register to post, as many times you want. Its absolutely free. Click here for registering on Forex-TSD.
Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
Elite Section
Get access to private discussions, specialized support, indicators and trading systems reported every week.
Advanced Elite Section
For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
How to start trading on the opening candle in D1 ??
is there anyone know the code to ask the EA start open trade when the new bar start in D1 time frame ??
here is the logic:
in D1 TF, when the new candle (it's mean a new day) is start then EA will open 2 position, BUY and SELL with TP=10 pips for each position.
When the candle closed then EA close all position and start opening position again for the new candle.
very simple rule, but still I cann't find the code for this simple rule....
I'm realy new in MQL4 coding and already search and read many source and forum to learn more about MQL4 coding, but cann't find what I'm need.
Last night I uploaded to my vps, but this morning I check it up but my sample EA doesn't open any trade, can someone here help me to fix my sample EA here ??
hereīs the code, thought it wouldnīt fit in here but when I pressed "preview post" it all looked neat.....
I canīt figure out why there arenīt any arrows showing up on the chart... probably just a simple mistake...
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Green
extern int Trend_Period = 100; //period of overall trend indicator
extern int Trend_Mode = 1; //0=sma, 1=ema, 2=smma, 3=lwma, 4=lsma
extern int Trend_Shift = 0; //shift of overall trend indicator
extern int Sto_Lookback = 3; //lookback period for stochastic indicator
double buyit[];
int Current = 0;
bool triggup, trendup, stochup, sloppystochup;
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int Current = 0;
int i = 0;
//this is intended to create a lookback period where the program finds out if
//there was a certain condition within "i" bars...
for (i = 1; i <= Sto_Lookback; i++)
{
//overall trend indicator... now and previous to calculate direction itīs going
double trend_ma_now = iMA(NULL, 0, Trend_Period, Trend_Shift, Trend_Mode, PRICE_CLOSE, Current + 1);
double trend_ma_pre = iMA(NULL, 0, Trend_Period, Trend_Shift, Trend_Mode, PRICE_CLOSE, Current + 2);
//triggerline... now and previous to calculate if it was crossed
double trigg_ma_now = iMA(NULL, 0, 5, 1, MODE_EMA, PRICE_CLOSE, Current + 1);
double trigg_ma_pre = iMA(NULL, 0, 5, 1, MODE_EMA, PRICE_CLOSE, Current + 2);
//short stochastics... now and previous to calculate which direction it is moving
double sto_short_now = iStochastic(NULL, 0, 8, 3, 3, MODE_SMA, 0, MODE_MAIN, Current + 1);
double sto_short_pre = iStochastic(NULL, 0, 8, 3, 3, MODE_SMA, 0, MODE_MAIN, Current + 2);
//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 last bar closed above overall trend and trendline moves up then trendup is true
if (Close[Current + 1] > trend_ma_now && trend_ma_now > trend_ma_pre)
{trendup = true;}
//if last bar closed above triggerline while closing below/at it the bar before (a cross up) then triggup is true
if (Close[Current +1] > trigg_ma_now && Close[Current +2] <= trigg_ma_pre)
{triggup = true;}
//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;}
//if short stochastics move up... and anywhere within "i" bars short stochastics have been
//at least 10 points lower than long stochastics... and long stochastics are still above 35..
//then sloppystochup is true
if (sto_short_now > sto_short_pre && sto_short + 10 <= sto_long && sto_long_now > 35)
{sloppystochup = true;}
//if triggup, trendup and stochup are all true.. OR... triggup, trendup and sloppystochup are all true...
if (triggup == true && trendup == true && stochup == true || triggup == true && trendup == true && sloppystochup == true)
//then draw an arrow below the low of the last closed candle...
{buyit[Current + 1] = Low[Current + 1];}
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
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;
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.
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...
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.