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
Hello!
Can anyone who knows how to correctly prescribe the following in the code:
There is an indicator MACD Histogramm WIS. The histogram is calculated in its code and colored bars, depending on the direction of the line and the filter macd in different colours.
int start()
{
int limit,i;
int counted_bars = IndicatorCounted();
if(counted_bars > 0) counted_bars--;
limit = iBars(NULL,0) - counted_bars;
BufferResize(Filter);
BufferResize(Histogram);
for(i = 0; i <= limit; i++)
MACD[i] = iMA(NULL, 0, FastMA, 0, MAMethod, MAAppliedPrice, i) - iMA(NULL, 0, SlowMA, 0, MAMethod, MAAppliedPrice, i);
for(i = 0; i <= limit; i++)
Signal[i] = iMAOnArray(MACD, iBars(NULL,0), SignalMA, 0, MAMethod, i);
for(i = 0; i <= limit; i++)
Histogram[i] = MACD[i] - Signal[i];
CalcFilter(Line, limit);
for(i = limit; i >= 0; i--)
{
if(Histogram[i] > Histogram[i+1] && Filter[i] > Filter[i+1])
{
HistogramWaitClose[i] = 0.0;
HistogramSell[i] = 0.0;
HistogramBuy[i] = Histogram[i];
}
if(Histogram[i] < Histogram[i+1] && Filter[i] < Filter[i+1])
{
HistogramWaitClose[i] = 0.0;
HistogramSell[i] = Histogram[i];
HistogramBuy[i] = 0.0;
}
if((Histogram[i] >= Histogram[i+1] && Filter[i] <= Filter[i+1]) || (Histogram[i] <= Histogram[i+1] && Filter[i] >= Filter[i+1])
{
HistogramWaitClose[i] = Histogram[i];
HistogramSell[i] = 0.0;
HistogramBuy[i] = 0.0;
}
}
return(0);
}
I'm trying to prescribe in the Expert Advisor, one of the conditions, the opening of positions upwards if:
if(Histogram[i] > Histogram[i+1] && Filter[i] > Filter[i+1])
{
HistogramWaitClose[i] = 0.0;
HistogramSell[i] = 0.0;
HistogramBuy[i] = Histogram[i];
but I need to compare only 2 closed bars, ie the first and second (zero do not touch), not all (i-bars), ie need to compare the first and second bar, and if the bar graph of the first bar greater than the second and complied with filters and other conditions of the EA, buy, to sell the opposite .... how to prescribe it correctly, please advise, tea-learned amateur)
Thank you
I will write an advisor of any complexity. The main thing is to have a good idea. How you will use it I do not care: will sell - I do not mind (I will not ask for money).
P. S. If you need an indicator, you have to tell me the strategy in which you want to use it.
I do not know anything about programming and I am a beginner.
Maybe this adviser already have, in general, so:
On the principle of "rollover" the crossing of two EMAs closes the previous one opens a new one, EMAs should be variable.
I think on H1, H4 is quite relevant.
Maybe such an EA already exists, here's how it works:
On the principle of "rollover" the crossing of two EMAs closes the previous one opens a new one, EMAs should be variable.
I think on H1, H4 is quite relevant.
Hello.
Please make a simple Expert Advisor that opens one order for a certain amount of points and if the price passed them and closed in the + side, the order closes and opens back in the plus side. If it is in a minus position, it reverses to the minus position.
Parameters to be set - Size of lot and number of points to be passed.
Many thanks in advance.
Regards Dimitriy.
I will write an advisor of any complexity. The main thing is to have a good idea. How you will use it I do not care: will sell - I do not mind (I will not ask for money).
P. S. If you need an indicator, you have to tell me about the strategy in which you want to use it.
Hello Dear developers. Please help me to create an indicator based on SSL_fast_sBar_mtf indicator.
I want it to draw two "rulers", one with value "Lb" bigger and another one with smaller value (or TIME FREAM bigger and smaller). If on the bar the colours
of both "rulers" are the same (and on the previous one they were different), then at the beginning of the next bar you should give the signal to open (place the arrow).
Arrows should be drawn using indicator buffers, not graphical objects. The data of both "rulers" are required in the window of external parameters
(for further selection of their parameters).
http://savepic.ru/1965498.gif
I don't know how to send a link to the indicator. It is in the MQL4.com library
Good afternoon!
Very much I ask to make an expert (well I am not a programmer) :((.
Technical parameters:
1) We work on a 4-hour candlestick chart by crossing two lines Moving Average: one(Red) period 18, method Exponential, toClose prices, respectively(Yellow) period 8, method also Exponential, to Close prices.
2) Trade size 1 lot
3) We work from crossover to crossover lines. As soon as theyellow line crosses the red line (Red) in the up direction (north), buy order, the second crossing of lines, yellow line crosses accordingly the red one from above downwards - fixing of the open order, with simultaneous opening of a new sell order, and so on.
4) A stop loss of 35 points is set for all trades.
4-hour chart allows you to avoid unnecessary movements, unlike the hour chart, working for sure.
If just look at currency pairs, the idea justifies itself (no loss-making trades, around zero at worst), of course, one should take into account the trend and use the Expert Advisor while looking back at it. As an example, for EUR/USD, if on September 1 we buy +139 points before crossing +115 points, then we buy again before crossing +1184 points on October 12. Take August the same picture +368 points sale, then buy sale at the same level without any losses and +181 points down on profit selling. Further, for example gold GOLD(the commission is 70 points, but the point is 2.5 dollars per lot) and so from August, 31st buy +1789 points, at once sell +547 points, +4557 points buy, sell nil, +4328 buy, sell nil and till this weekend again +3636 points.
Regards, Yuriy
Take the standard Moving Average supplied as a basis and experiment with it. You can replace the MA with the EMA.
Here's the full description:
//+------------------------------------------------------------------+
//| Moving Average.mq4 |//| Copyright © 2005, MetaQuotes Software Corp.
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#define MAGICMA 20050610
extern double Lots = 0.1;
extern double MaximumRisk = 0.02;
extern double DecreaseFactor = 3;
extern double MovingPeriod = 12;
extern double MovingShift = 6;
//+------------------------------------------------------------------+
//| Calculate open positions |
//+------------------------------------------------------------------+
int CalculateCurrentOrders(string symbol)
{
int buys=0,sells=0;
//----
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGICMA)
{
if(OrderType()==OP_BUY) buys++;
if(OrderType()==OP_SELL) sells++;
}
}
//---- return orders volume
if(buys>0) return(buys);
else return(-sells);
}
//+------------------------------------------------------------------+
//| Calculate optimal lot size |
//+------------------------------------------------------------------+
double LotsOptimized()
{
double lot=Lots;
int orders=HistoryTotal(); // history orders total
int losses=0; // number of losses orders without a break
//---- select lot size
lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,1);
//---- calcuulate number of losses orders without a break
if(DecreaseFactor>0)
{
for(int i=orders-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Error in history!"); break; }
if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL) continue;
//----
if(OrderProfit()>0) break;
if(OrderProfit()<0) losses++;
}
if(losses>1) lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,1);
}
//---- return lot size
if(lot<0.1) lot=0.1;
return(lot);
}
//+------------------------------------------------------------------+
//| Check for open order conditions |
//+------------------------------------------------------------------+
void CheckForOpen()
{
double ma;
int res;
//---- go trading only for first tiks of new bar
if(Volume[0]>1) return;
//---- get Moving Average
ma=iMA(NULL,0,MovingPeriod,MovingShift,MODE_SMA,PRICE_CLOSE,0);
//---- sell conditions
if(Open[1]>ma && Close[1]<ma)
{
res=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,0,0,",MAGICMA,0,Red);
return;
}
//---- buy conditions
if(Open[1]<ma && Close[1]>ma)
{
res=OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,0,0,",MAGICMA,0,Blue);
return;
}
//----
}
//+------------------------------------------------------------------+
//| Check for close order conditions |
//+------------------------------------------------------------------+
void CheckForClose()
{
double ma;
//---- go trading only for first tiks of new bar
if(Volume[0]>1) return;
//---- get Moving Average
ma=iMA(NULL,0,MovingPeriod,MovingShift,MODE_SMA,PRICE_CLOSE,0);
//----
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue;
//---- check order type
if(OrderType()==OP_BUY)
{
if(Open[1]>ma && Close[1]<ma) OrderClose(OrderTicket(),OrderLots(),Bid,3,White);
break;
}
if(OrderType()==OP_SELL)
{
if(Open[1]<ma && Close[1]>ma) OrderClose(OrderTicket(),OrderLots(),Ask,3,White);
break;
}
}
//----
}
//+------------------------------------------------------------------+
//| Start function |
//+------------------------------------------------------------------+
void start()
{
//---- check for history and trading
if(Bars<100 || IsTradeAllowed()==false) return;
//---- calculate open orders by current symbol
if(CalculateCurrentOrders(Symbol())==0) CheckForOpen();
else CheckForClose();
//----
}
//+------------------------------------------------------------------+
How do I change it here to make it work for me I don't understand! I just want 50EMA and 100EMA and a beep at each crossing!!!