
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
study the 2010 charts
using your template to create something -- over the league of Stochastic
as we have use our stochastic charts in the early days -- does it still apply to 2010 charts -- those are real traders, bud and you could have his assignments -- I am into non-banding lebesgue integral maths programming -- remember the movie She's Out of My League --- good work means good pay -----
read the codes -- a bit less sophisticated than current investment style in 2010
I have tried just about every possible combo of the cursed freaking parenthesis fault that i am getting trying to compile. Been looking at it for many hours but no luck in fixing it. I have nailed it down to a section of code whats screwing the script up. Anyone advise me on whats wrong (aside from me being a moron).
void ScanForClosure ()
{
int cash = OrderProfit() + OrderSwap() + OrderCommission()
int MacdCurrent, MacdPrevious, SignalCurrent;
int SignalPrevious, MaCurrent, MaPrevious;
int total2 = OrdersTotal();
int numords2 = 0;
bool type = false;
int trd2 = 0;
MacdCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0);
MacdPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1);
SignalCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0);
SignalPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1);
MaCurrent=iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,0);
MaPrevious=iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,1);
ArrayResize(lastOrders,5);
ArrayInitialize(lastOrders,0);
//
for(int cnt=0; cnt<total2; cnt++)
{
OrderSelect(cnt, SELECT_BY_POS);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) ;
{
if ((OrderType()==OP_BUY)&&
(MacdCurrent>0)&&
(MacdCurrent<SignalCurrent)&&
(cash > 0)&&
(MacdPrevious>SignalPrevious) && MacdCurrent>(MACDCloseLevel*Point));
{
CloseOrder(1);
}
if ((OrderType()==OP_SELL)&&
(cash > 0)&& (MacdCurrent<0 ) &&
(MacdCurrent>SignalCurrent)&&
(MacdPrevious<SignalPrevious)&&
(MathAbs(MacdCurrent))>(MACDCloseLevel*Point));
{
CloseOrder(2);
}
}
}
}Hi Scotty,
I'm copying from macd sample
if(OrderType()==OP_BUY)
{
if(MacdCurrent>0 && cash > 0 && MacdCurrentSignalPrevious &&
MacdCurrent>(MACDCloseLevel*Point))
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet);
return(0);
}
else
{
if(MacdCurrent 0 && MacdCurrent>SignalCurrent &&
MacdPrevious(MACDCloseLevel*Point))
{
OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position
return(0);
}
Regards
tools
why is this code giving the wrong parameter count error:
for(int i = 0;i < 3;i++)
{
kline = iStochastic(NULL,TimeFrame1, Period(), 4, 3, 3, MODE_SMA, 1, MODE_MAIN, i);
dline = iStochastic(NULL,TimeFrame1, Period(), 4, 3, 3, MODE_SMA, 1, MODE_SIGNAL, i);
}Should be
int counted_bars = IndicatorCounted();
int limit,i;
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit = Bars - counted_bars;
for(int i=limit; i>=0; i--)
{
kline = iStochastic(NULL,TimeFrame1, 4, 3, 3, MODE_SMA, 1, MODE_MAIN, i);
dline = iStochastic(NULL,TimeFrame1, 4, 3, 3, MODE_SMA, 1, MODE_SIGNAL, i);
Regards
tools
Thanks Mr Tools maybey i was making it to complex but what was wrong with it? Will that posted example scan all the open tickets? I would think it would only scan 2 (a single buy one and a single sell ), Most likely the same one every time :/ I am very new to this mt4 programming but i am sure thats what would happen.
figured it out
its amazing you stare at the same problem for 10 hours straight and cant fix it. I had another look at it. When I woke up and fixed it in 5. Seems this MT4 code is very tight. You seem to need to code precisely what its looking for (whether or not you can do the exact same thing in 10 other languages and work)
I have created bots for World of Warcraft to make a character run around by itself in a game locating and killing things however when I try and make a simple buy sell routine in MT4 I struggle
Anyways lesson for me was to limit what you put on a line with an if. Hopefully I save a few others the pain I had.
OrderSelect(cnt, SELECT_BY_POS);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
{
if (OrderType()==OP_BUY)
if (profit>0)
if (MacdCurrent<SignalCurrent)
if (MacdCurrent>0)
if (MacdPrevious>SignalPrevious)
if (MacdCurrent>(MACDCloseLevel*Point))
{
CloseOrder(1);
}
if (OrderType()==OP_SELL)
if ((MacdCurrent<0 ) )
if (profit >0 )
if (MacdCurrent>SignalCurrent)
if (MacdPrevious<SignalPrevious)
if (MathAbs(MacdCurrent) >(MACDCloseLevel*Point))
Code Assistance - Fractals
Hi there,
I'm looking for some help on the code needed to do the following as part of a system I'm working on:
Valid Long if:
(numbered oldest to most recent 1-x)
-> Fractal Pointing Down 1 higher than Fractal Down 2
-> Fractal Up 1 is formed and creates the break-long possible condition, however
-> Fractal Down 3 is has to be higher than Fractal Down 2
-- This validates the change in trend. A price break up of the upper fractal would be a valid TRUE. If a new, lower Upper Fractal is formed, that is the new break point UNLESS there is a lower Fractal Down than the previous Fractal Down. The lower Fractals should be making higher highs.
Inverse true for short validation.
Cheers
Aaron
May try to explain a little better
So there is an up trend in price, an upper fractal is formed. Price retraces and a bottom fractal is formed. Price continues to retrace and another, lower, bottom fractal is formed.
Then price goes up to form a new, lower, upper fractal.
Price retraces and another bottom fractal is formed, but this is higher than the previous bottom fractal.
Price breaks the previous upper fractal, valid break long condition.
PS If a new, lower, upper fractal is formed, but the bottom fractals continue to be making higher highs, the new break point is the most recent upper fractal.
PPS If lower, bottom fractals start to form, the conditions are reset and we continue to look for the above conditions or the inverse conditions for short validation of a break.
Cheers
Aaron
And what exactly help with programming you need? Need to have whole system programmed?
Just that logic part.
Say a bool that is ValidBuy = FALSE;
if the condition logic as above occurs it sets it to TRUE.
I'm sure it is an array then comparing array values, but I'm not that great when it comes to coding the arrays.
Cheers
Aaron
You do not need to use any arrays. Just create function, which will find the level of given fractal, so you can call like this:
first parameter being number of fractal (0-last, 1-one before last, etc.) and second parameter telling if you want upper or lower fractal.
Then, you can code like this:
[CODE]double last_lower_fractal = FindFractal( 0, MODE_LOWER );
double previous_lower_fractal = FindFractal( 1, MODE_LOWER );
if( last_lower_fractal > previous_lower_fractal )
{
//we have found that most recent lower fractal is higher than its predecessor, do rest of your logic here.
}