Register for free to join our community of investors and share your ideas. You will also get access to streaming quotes, interactive charts, trades, portfolio, live options flow and more tools.
Funny you should ask that, I've been thinking about that while at work tonight. I was going to ask you the same thing just now. I thought of a couple of solutions (which may or may not work lol).
First, since the only difference between a trendline and a horizontal line is the slope, if you had the beginning and end points of the line and knew how many bars were between, you could programmatically calculate the value of a concurrent trendline touch. Sort of like if you had a very small 5 bar sample and you drew a line from the top of the first bar to the top of the third bar. Based on that you could calculate where the top of any concurrent bar would be if they followed the trend line.
Second, I thought about using the arctangent or other function and programmatically figuring the trendline touch that way with the angle of the line. Knowing the slope of an upward trendline for example, theoretically you should be able to count over a certain number of bars (x) and calculate how high or low the (y) coordinate should be and make the trade there. After typing this all out, I have not put as much thought into this as the others so it's still sort of murky. Programming wise, it might be easier since you could (theoretically at least) take the slope of the line times the beginning point and calculate all the way up the line or down the line as the case may be.
Third, since you can move objects around based on coordinates you could use the beginning and end of the trendline and calculate the coordinates of the trendline. I think it would be pretty processor intensive since you'd have to create and delete an object say the size of at least a pixel every tick and when that object hit the calculated coordinates of the trendline then make the trade.
There may be some other ways, I just haven't thought of them yet.
Trading either would be pretty cool, short or long based on the bid+spread if shorting it or the ask-spread if going long. If it broke the trendline, then go with the breakout. Should be able to do it with a very minimal manually calculated stop as well like 3 pips or so.
Me again...have you found anything to mimic the Cross function from VTTrader? It sure is a lot more convoluted to code in MT4....(this type of thing anyway)
I have been trying to reference the objects in that SDC indie, and when I pull the PRICE1 and PRICE2 on each of the two channels, I get the same value regardless of whether it is the standard channel or the regression. Just sending it to the screen in an alert for now, but the numbers don't match what I see on the chart...have you done anything with it yet?
yep a lot better view
Or yes, you can do it that way too! I am more comfortable seeing it that way too, it gives me room for hope that it will go my direction lol.
Yes, right click on the chart and select properties, then check the box marked "Chart Shift".
sherri i found a button it has alittle red cross on it--i like to be able to see my charts this way--they seem crammed up against the wall the other way --also i can extend my trend line better
lol-tks anyway-so if you did it accidently-there must be a way to do it-i'll hunt
I've done it before, usually accidentally....though I cannot tell you how you are supposed to do it. Sorry!
sherri or git-is there a way on mt4 to move the chart to the right more in the future --oanda charts have that ability
Nicely done! I am still trying to get SG's long ported and compiling....LOL...LOTS of code
Hey Sherri, check out this indie I made. Not finished yet, but it shows the 1 hour support and 1 hour resistance regardless of the timeframe of the chart you're looking at with the red horizontal lines plus it adds the e64, the e144, and the e169. It's my first attempt at using Objects instead of buffers and I'm pretty tickled. Gonna add the 4 hour for sure later and play around with the colors and line widths.
Kind of even been thinking about showing it as a histogram of the difference between the current price and the support or resistance levels.
Here's the code so far.
//+------------------------------------------------------------------+
//| GitsTunnelResistance.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""
#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 PowderBlue //Recent 1 Hour resistance
#property indicator_color2 Khaki//Recent 1 Hour support
#property indicator_color3 Chartreuse//Recent 4 Hour resistance
#property indicator_color4 Red//Recent 4 Hour support
#property indicator_color5 Red//Current62ema
#property indicator_color6 Yellow//Current144ema
#property indicator_color7 Chartreuse//Current169ema
//---- buffers
double H1R,H1S,H4R,H4S;
double E62[];
double E144[];
double E169[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(7);
//---- drawing settings
SetIndexStyle(0,DRAW_LINE,STYLE_DASHDOT,3);//1 Hour Resistance
SetIndexStyle(1,DRAW_LINE,STYLE_DASHDOT,3);//1 Hour Support
SetIndexStyle(2,DRAW_LINE,2);//4 Hr Resistance
SetIndexStyle(3,DRAW_LINE,2);//4 Hr Support
SetIndexStyle(4,DRAW_LINE);//E62
SetIndexStyle(5,DRAW_LINE);//E144
SetIndexStyle(6,DRAW_LINE);//E169
//---- indicator mapping
SetIndexBuffer(0,H1R);
SetIndexBuffer(1,H1S);
SetIndexBuffer(2,H4R);
SetIndexBuffer(3,H4S);
SetIndexBuffer(4,E62);
SetIndexBuffer(5,E144);
SetIndexBuffer(6,E169);
//---- indicator labeling
IndicatorShortName("Gits Tunnel Resistance");
SetIndexLabel(0,"1 Hour Resistance");
SetIndexLabel(1,"1 Hour Support");
SetIndexLabel(2,"4 Hour Resistance");
SetIndexLabel(3,"4 Hour Support");
SetIndexLabel(4,"Current E62");
SetIndexLabel(5,"Current E144");
SetIndexLabel(6,"Current E169");
return(0);
}
int deinit()
{
//----
ObjectsDeleteAll();
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- Current EMAs
for(int i=0; i<limit; i++)
E62=iMA(NULL,0,62,0,MODE_EMA,PRICE_CLOSE,i);
for(i=0; i<limit; i++)
E144=iMA(NULL,0,144,0,MODE_EMA,PRICE_CLOSE,i);
for(i=0; i<limit; i++)
E169=iMA(NULL,0,169,0,MODE_EMA,PRICE_CLOSE,i);
// 1 Hour resistance
for(i=1; i<limit; i++)
{
if(iHigh(NULL,60,i+1) > iHigh(NULL,60,i)) H1R=iHigh(NULL,60,i+1); else H1R=iHigh(NULL,60,i);
ObjectCreate("H1Resistance",OBJ_HLINE,0,0,H1R);
break;
}
// 1 Hour support
for(i=0; i<limit; i++)
{
if(iLow(NULL,60,i+1) < iLow(NULL,60,i)) H1S=iLow(NULL,60,i+1); else H1S=iLow(NULL,60,i);
ObjectCreate("H1Support",OBJ_HLINE,0,0,H1S);
break;
}
// 4 Hour resistance
for(i=0; i<limit; i++)
{
if(iHigh(NULL,240,i+1) < iHigh(NULL,240,i)) H4R=High; break;
}
// 4 Hour support
for(i=0; i<limit; i++)
{
if(iLow(NULL,240,i+1) > iLow(NULL,240,i)) H4S=Low; break;
}
Comment("H1R = ",H1R, " || H1S = ",H1S," || H4R = ",H4R," || H4S = ",H4S);
//---- done
return(0);
}
//+------------------------------------------------------------------+
LOL! Found a really simple HA indie that works nicely...
Yeah, originally I had instead of the [t] and it kept making everything italic lol.
Ahhhh - makes sense....formatting is a b|tch sometimes
I figured it out, not through with it yet though. It is indented, but when I copied and pasted, the formatting didn't transfer.
Eventually, I put break where the return was, since I want it to stop looking when it found the instance to be true and save the H1R and H1S values. Just got home, when I get it working like it should I'll send it to you. Thanks!
It looks like you have two statements to be executed if the if portion is true....parentheses are required for more than one statement. FWIW, it would be good to get in the habit of using indentation - makes it easier to spot syntax issues (and easier for other people to read )
Code should be basically like this:
// 1 Hour resistance
for(t=0; t<limit; t++)
if(iHigh(NULL,60,t+1)!>iHigh(NULL,60,t))
(
H1R==High[t];
return(0);
)
// 1 Hour support
for(t=0; t<limit; t++)
if(iLow(NULL,60,t+1)!<iLow(NULL,60,t))
(
H1S==Low[t];
return(0);
)
One thing I am curious about is why you have the return in each of those statements? If you don't need it, you could also leave the code like this:
// 1 Hour resistance
for(t=0; t<limit; t++)
if(iHigh(NULL,60,t+1)!>iHigh(NULL,60,t))
H1R==High[t];
// 1 Hour support
for(t=0; t<limit; t++)
if(iLow(NULL,60,t+1)!<iLow(NULL,60,t))
H1S==Low[t];
Sherri, what am I doing wrong here?
I want to go back through the candles and if the high of the previous candle is not higher than the current candle then set the H1R or H1S value to the high of the current candle and determine support/resistance. It gives me an unbalanced parenthesis error.
// 1 Hour resistance
for(t=0; t<limit; t++)
if(iHigh(NULL,60,t+1)!>iHigh(NULL,60,t)) H1R==High[t]; return(0);
// 1 Hour support
for(t=0; t<limit; t++)
if(iLow(NULL,60,t+1)!<iLow(NULL,60,t)) H1S==Low[t]; return(0);
The 1 min was way too short, but as I posted on the other board, the 5 min ran overnight and netted 29 pips on 2 trades with no losses. (The first trade being one I manually closed for like 5 pips).
Still needs more tweaking. Little revelation came to light there with the PRICE_CLOSE vs PRICE_OPEN emas after making about 10 changes and still getting trades being entered when (I thought) they shouldn't. It's evidently more logical than I am, which is a good thing, just have to be very specific. At work the next 3 or 4 days so my posting will be limited at best.
How did your 1 min test go?
You've been busy! How did it work for you?
Crossing of the CLOSE and OPEN EMAs are crucial. If the PRICE_CLOSE is above the PRICE_OPEN and the 64 is under the 169 then it's going to blow past the 64 to the 169 and vice versa. Similarly if the PRICE_CLOSE is below the PRICE_OPEN while the 64 is above the 169, then it's going to blow past the 64 headed down to the 169 or below.
Mainly wanted to leave this note to myself so I don't loose my train of thought after I come back from work in a few days.
//+------------------------------------------------------------------+
//| TunnelPips64.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""
extern double SL=40;//Stop Loss
extern double TP=200;//Take Profit
extern double lots=0.10;
extern int slippage=3;
extern int magicnumber=913;
double scalp=0.40;
double entry;
int time;
bool up=False;
bool down=False;
bool tunn64=False;
bool tunn169=False;
bool Ltrigger=False;
bool Strigger=False;
bool TT=False;
double C64,C169;
//IFT Parameters
extern double IHi=0.65;//IFT Hi Line (passed to custom)
extern double ILo=-0.65;//IFT Lo Line (passed to custom)
extern int IRsi=5;// IFT first parameter
extern int IWma=9;// IFT second parameter
//******************* TIME TO TRADE ******************
extern int _sHour=1; // Start hour
extern int _eHour=23; // End hour
int init()
{
time=TimeCurrent();
return(0);
}
//***************** START **********************
int start()
{
//Start/End Time
if(Hour()>=_sHour && Hour()<=_eHour) TT=True; else TT=False;
int D=(Digits);//# of digits after decimal of current pair in the window
double SNSL=NormalizeDouble(Bid+SL*Point,D);//Short position stop loss
double SNTP=NormalizeDouble(Bid-TP*Point,D);//Short position take profit
double LNSL=NormalizeDouble(Ask-SL*Point,D);//Long position stop loss
double LNTP=NormalizeDouble(Ask+TP*Point,D);//Long position take profit
int OT=OrdersTotal();
//EMAs
double C169=iMA(NULL,0,169,0,MODE_EMA,PRICE_CLOSE,0);
double O169=iMA(NULL,0,169,0,MODE_EMA,PRICE_OPEN,0);
double O64=iMA(NULL,0,64,0,MODE_EMA,PRICE_OPEN,0);
double C64=iMA(NULL,0,64,0,MODE_EMA,PRICE_CLOSE,0);
double HTrend=iMA(NULL,0,169,0,MODE_EMA,PRICE_CLOSE,1)-iMA(NULL,0,169,0,MODE_EMA,PRICE_CLOSE,12);
//64 direction - Looking for uptrend with CLOSE EMA crossing above OPEN EMA
double CTrend1=iMA(NULL,0,64,0,MODE_EMA,PRICE_CLOSE,1)-iMA(NULL,0,64,0,MODE_EMA,PRICE_CLOSE,5);
double CTrend2=iMA(NULL,0,64,0,MODE_EMA,PRICE_CLOSE,1)-iMA(NULL,0,64,0,MODE_EMA,PRICE_OPEN,10);
//64 direction - Looking for downtrend with OPEN EMA crossing below CLOSE EMA
double CTrend3=iMA(NULL,0,64,0,MODE_EMA,PRICE_OPEN,1)-iMA(NULL,0,64,0,MODE_EMA,PRICE_CLOSE,5);
double CTrend4=iMA(NULL,0,64,0,MODE_EMA,PRICE_OPEN,1)-iMA(NULL,0,64,0,MODE_EMA,PRICE_OPEN,10);
//IFT Function
double ITrig=iCustom(NULL,5,"IFT",IHi,ILo,IRsi,IWma,1,1);//current IFT
double PITrig=iCustom(NULL,5,"IFT",IHi,ILo,IRsi,IWma,1,2);//previous IFT
if(C64>C169)
{
if(High[0]>=O64 && Low[0]<=O64) tunn64=True; else tunn64=False;
if(High[0]>=O169 && Low[0]<=O169) tunn169=True; else tunn169=False;
}
if(C64<C169)
{
if(High[0]>=C64 && Low[0]<=C64) tunn64=True; else tunn64=False;
if(High[0]>=C169 && Low[0]<=C169) tunn169=True; else tunn169=False;
}
//This part is very important when the 64 is close to the 169. Determine the switch between
//the open and close EMAs - Do not change
if(ITrig<ILo && C64>C169 && CTrend1>CTrend2) Ltrigger=True; else Ltrigger=False;
if(ITrig>IHi && C64<C169 && CTrend3<CTrend4) Strigger=True; else Strigger=False;
if((tunn64==True && Ltrigger==True) || (tunn169==True && Ltrigger==True)) up=True; else up=False;
if((tunn64==True && Strigger==True) || (tunn169==True && Strigger==True)) down=True; else down=False;
if(OT<1 && TT==True) //Are any orders open already?
{
//SHORT ENTRY
if(down==True && IsTradeAllowed()==True && TimeCurrent()>time+900)
{
int shortticket=OrderSend(Symbol(),OP_SELL,lots,Bid,slippage,SNSL,SNTP,"Short Order Being Placed ",magicnumber,0,Red);
if(shortticket<0)
{
Print("Short Order Send failed - error #",GetLastError());
}
if(shortticket>0)
{
if(OrderSelect(shortticket,SELECT_BY_TICKET,MODE_TRADES))
entry=OrderOpenPrice();
time=TimeCurrent();
Print("SELL order opened : ",OrderOpenPrice(),"|| Target Price : ",entry-scalp);
}
return(0);
}
//LONG ENTRY
if(up==True && IsTradeAllowed()==True && TimeCurrent()>time+900)
{
int longticket=OrderSend(Symbol(),OP_BUY,lots,Ask,slippage,LNSL,LNTP,"Long Order Being Placed ",magicnumber,0,Green);
if(longticket<0)
{
Print("Long Order Send failed - error #",GetLastError());
}
if(longticket>0)
{
if(OrderSelect(longticket,SELECT_BY_TICKET,MODE_TRADES))
entry=OrderOpenPrice();
time=TimeCurrent();
Print("BUY order opened : ",OrderOpenPrice(),"|| Target Price : ",entry+scalp);
}
return(0);
}
return(0);
}
//************** Close Orders ***********************
for(int cnt=0;cnt<OT;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderMagicNumber()==magicnumber)
{
if(OrderType()==OP_BUY && TimeCurrent()>time+300) // long position is open
{
if(ITrig>IHi && ITrig<PITrig)
{
OrderClose(OrderTicket(),OrderLots(),Bid,slippage,Blue);
return(0);
}
}
if(OrderType()==OP_SELL && TimeCurrent()>time+300) // short position is open
{
if(ITrig<ILo && ITrig>PITrig)
{
OrderClose(OrderTicket(),OrderLots(),Ask,slippage,Blue);
return(0);
}
}
}
}
return(0);
}
//+------------------------------------------------------------------+
Tonight's version. Thank goodness for copy and paste.
//+------------------------------------------------------------------+
//| TunnelPips64.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""
extern double SL=40;//Stop Loss
extern double TP=200;//Take Profit
extern double lots=0.10;
extern int slippage=3;
extern int magicnumber=913;
double scalp=0.40;
double entry;
int time;
bool up=False;
bool down=False;
bool tunn64=False;
bool tunn169=False;
bool Ltrigger=False;
bool Strigger=False;
bool TT=False;
double C64,C169;
//IFT Parameters
extern double IHi=0.65;//IFT Hi Line (passed to custom)
extern double ILo=-0.65;//IFT Lo Line (passed to custom)
extern int IRsi=5;// IFT first parameter
extern int IWma=9;// IFT second parameter
//******************* TIME TO TRADE ******************
extern int _sHour=1; // Start hour
extern int _eHour=23; // End hour
int init()
{
time=TimeCurrent();
return(0);
}
//***************** START **********************
int start()
{
//Start/End Time
if(Hour()>=_sHour && Hour()<=_eHour) TT=True; else TT=False;
int D=(Digits);//# of digits after decimal of current pair in the window
double SNSL=NormalizeDouble(Bid+SL*Point,D);//Short position stop loss
double SNTP=NormalizeDouble(Bid-TP*Point,D);//Short position take profit
double LNSL=NormalizeDouble(Ask-SL*Point,D);//Long position stop loss
double LNTP=NormalizeDouble(Ask+TP*Point,D);//Long position take profit
int OT=OrdersTotal();
//EMAs
double C169=iMA(NULL,0,169,0,MODE_EMA,PRICE_CLOSE,0);
double O169=iMA(NULL,0,169,0,MODE_EMA,PRICE_OPEN,0);
double O64=iMA(NULL,0,64,0,MODE_EMA,PRICE_OPEN,0);
double C64=iMA(NULL,0,64,0,MODE_EMA,PRICE_CLOSE,0);
double HTrend=iMA(NULL,0,169,0,MODE_EMA,PRICE_CLOSE,1)-iMA(NULL,0,169,0,MODE_EMA,PRICE_CLOSE,12);
//64 direction - Close EMAS
double CTrend1=iMA(NULL,0,64,0,MODE_EMA,PRICE_CLOSE,1)-iMA(NULL,0,64,0,MODE_EMA,PRICE_CLOSE,5);
double CTrend2=iMA(NULL,0,64,0,MODE_EMA,PRICE_CLOSE,5)-iMA(NULL,0,64,0,MODE_EMA,PRICE_CLOSE,10);
//64 direction - Open EMAS
double CTrend3=iMA(NULL,0,64,0,MODE_EMA,PRICE_OPEN,1)-iMA(NULL,0,64,0,MODE_EMA,PRICE_OPEN,5);
double CTrend4=iMA(NULL,0,64,0,MODE_EMA,PRICE_OPEN,5)-iMA(NULL,0,64,0,MODE_EMA,PRICE_OPEN,10);
//IFT Function
double ITrig=iCustom(NULL,5,"IFT",IHi,ILo,IRsi,IWma,1,1);//current IFT
double PITrig=iCustom(NULL,5,"IFT",IHi,ILo,IRsi,IWma,1,2);//previous IFT
if(C64>C169)
{
if(High[0]>=O64 && Low[0]<=O64) tunn64=True; else tunn64=False;
if(High[0]>=O169 && Low[0]<=O169) tunn169=True; else tunn169=False;
}
if(C64<C169)
{
if(High[0]>=C64 && Low[0]<=C64) tunn64=True; else tunn64=False;
if(High[0]>=C169 && Low[0]<=C169) tunn169=True; else tunn169=False;
}
if(ITrig<ILo && C64>C169) Ltrigger=True; else Ltrigger=False;
if(ITrig>IHi && C64<C169) Strigger=True; else Strigger=False;
if((tunn64==True && Ltrigger==True) || (tunn169==True && Ltrigger==True)) up=True; else up=False;
if((tunn64==True && Strigger==True) || (tunn169==True && Strigger==True)) down=True; else down=False;
if(OT<1 && TT==True) //Are any orders open already?
{
//SHORT ENTRY
if(down==True && IsTradeAllowed()==True && TimeCurrent()>time+900)
{
int shortticket=OrderSend(Symbol(),OP_SELL,lots,Bid,slippage,SNSL,SNTP,"Short Order Being Placed ",magicnumber,0,Red);
if(shortticket<0)
{
Print("Short Order Send failed - error #",GetLastError());
}
if(shortticket>0)
{
if(OrderSelect(shortticket,SELECT_BY_TICKET,MODE_TRADES))
entry=OrderOpenPrice();
time=TimeCurrent();
Print("SELL order opened : ",OrderOpenPrice(),"|| Target Price : ",entry-scalp);
}
return(0);
}
//LONG ENTRY
if(up==True && IsTradeAllowed()==True && TimeCurrent()>time+900)
{
int longticket=OrderSend(Symbol(),OP_BUY,lots,Ask,slippage,LNSL,LNTP,"Long Order Being Placed ",magicnumber,0,Green);
if(longticket<0)
{
Print("Long Order Send failed - error #",GetLastError());
}
if(longticket>0)
{
if(OrderSelect(longticket,SELECT_BY_TICKET,MODE_TRADES))
entry=OrderOpenPrice();
time=TimeCurrent();
Print("BUY order opened : ",OrderOpenPrice(),"|| Target Price : ",entry+scalp);
}
return(0);
}
return(0);
}
//************** Close Orders ***********************
for(int cnt=0;cnt<OT;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderMagicNumber()==magicnumber)
{
if(OrderType()==OP_BUY && TimeCurrent()>time+300) // long position is open
{
if(ITrig>IHi && ITrig<PITrig)
{
OrderClose(OrderTicket(),OrderLots(),Bid,slippage,Blue);
return(0);
}
}
if(OrderType()==OP_SELL && TimeCurrent()>time+300) // short position is open
{
if(ITrig<ILo && ITrig>PITrig)
{
OrderClose(OrderTicket(),OrderLots(),Ask,slippage,Blue);
return(0);
}
}
}
}
return(0);
}
//+------------------------------------------------------------------+
I gotcha. This is what I have figured out after yesterday....and I will send you the EA in all its "commented out" glory. Those percentages you are trying to bring up? It is all about your exit criteria. I changed to enter on a simple EMA cross - nothing else - with a 50 pip TP and no stop losses. Using the strat tester (which I still don't trust, especially after I look at the chart it produces because it misses a lot), only 1 trade out of 15 was bad, yet my drawdown was never more than 11% in any case I tested. BUT, that leaves you exposed in a way that I would not do on an EA....
So....what that tells me is we are concentrating on the wrong thing. We need to find the criteria that makes us exit at the right time and we will be home free.
I am going to try a couple of things today and really really study a chart for where I would manually exit. Will let you know what I see....
This is where I'm at right now. Once I can get these circled numbers up there around 85 percent I'll be a lot happier. Not too worried about the dollar profit yet, I just want it to trade right and right on time. This is from a 3 day stretch on 10k units. It's hard teaching a computer to figure out the beast! Gonna post my EA code now in case I screw it up tonight lol and need to get back to where I once belonged lmao.
//+------------------------------------------------------------------+
//| TunnelPips64.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""
extern double SL=50;//Stop Loss
extern double TP=100;//Take Profit
extern double lots=0.10;
extern int slippage=3;
extern int magicnumber=913;
double scalp=0.40;
double entry;
int time;
bool up=False;
bool down=False;
bool tunn64=False;
bool tunn169=False;
bool TT=False;
double C64,C144,C169;
//******************* TIME TO TRADE ******************
extern int _sHour=1; // Start hour
extern int _eHour=23; // End hour
int init()
{
time=TimeCurrent();
return(0);
}
//***************** START **********************
int start()
{
//Start/End Time
if(Hour()>=_sHour && Hour()<=_eHour) TT=True; else TT=False;
int D=(Digits);//# of digits after decimal of current pair in the window
double SNSL=NormalizeDouble(Bid+SL*Point,D);//Short position stop loss
double SNTP=NormalizeDouble(Bid-TP*Point,D);//Short position take profit
double LNSL=NormalizeDouble(Ask-SL*Point,D);//Long position stop loss
double LNTP=NormalizeDouble(Ask+TP*Point,D);//Long position take profit
int OT=OrdersTotal();
//EMAs
double C169=iMA(NULL,0,169,0,MODE_EMA,PRICE_CLOSE,0);
double C144=iMA(NULL,0,144,0,MODE_EMA,PRICE_CLOSE,0);
double C64=iMA(NULL,0,64,0,MODE_EMA,PRICE_CLOSE,0);
//1 Hour tunnel direction
double Trend1=iMA(NULL,60,64,0,MODE_EMA,PRICE_CLOSE,1)-iMA(NULL,60,64,0,MODE_EMA,PRICE_CLOSE,4);
double Trend2=iMA(NULL,60,144,0,MODE_EMA,PRICE_CLOSE,1)-iMA(NULL,60,144,0,MODE_EMA,PRICE_CLOSE,10);
//Current Chart tunnel direction
double CTrend1=iMA(NULL,0,64,0,MODE_EMA,PRICE_CLOSE,1)-iMA(NULL,0,64,0,MODE_EMA,PRICE_CLOSE,4);
double CTrend2=iMA(NULL,0,144,0,MODE_EMA,PRICE_CLOSE,1)-iMA(NULL,0,144,0,MODE_EMA,PRICE_CLOSE,10);
if(High[0]>C64 && Low[0]<C64) tunn64=True; else tunn64=False;
if(High[0]>C169 && Low[0]<C169) tunn169=True; else tunn169=False;
if((tunn64==True && CTrend1>CTrend2) || (tunn169==True && Trend2>0)) up=True; else up=False;
if((tunn64==True && CTrend1<CTrend2) || (tunn169==True && Trend2<0)) down=True; else down=False;
if(OT<1 && TT==True) //Are any orders open already?
{
//SHORT ENTRY
if(down==True && IsTradeAllowed()==True && TimeCurrent()>time+900)
{
int shortticket=OrderSend(Symbol(),OP_SELL,lots,Bid,slippage,SNSL,SNTP,"Short Order Being Placed ",magicnumber,0,Red);
if(shortticket<0)
{
Print("Short Order Send failed - error #",GetLastError());
}
if(shortticket>0)
{
if(OrderSelect(shortticket,SELECT_BY_TICKET,MODE_TRADES))
entry=OrderOpenPrice();
time=TimeCurrent();
Print("SELL order opened : ",OrderOpenPrice(),"|| Target Price : ",entry-scalp," Trend1 : ",Trend1," Trend2 : ",Trend2);
}
return(0);
}
//LONG ENTRY
if(up==True && IsTradeAllowed()==True && TimeCurrent()>time+900)
{
int longticket=OrderSend(Symbol(),OP_BUY,lots,Ask,slippage,LNSL,LNTP,"Long Order Being Placed ",magicnumber,0,Green);
if(longticket<0)
{
Print("Long Order Send failed - error #",GetLastError());
}
if(longticket>0)
{
if(OrderSelect(longticket,SELECT_BY_TICKET,MODE_TRADES))
entry=OrderOpenPrice();
time=TimeCurrent();
Print("BUY order opened : ",OrderOpenPrice(),"|| Target Price : ",entry+scalp," Trend1 : ",Trend1," Trend2 : ",Trend2);
}
return(0);
}
return(0);
}
//************** Close Orders ***********************
for(int cnt=0;cnt<OT;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderMagicNumber()==magicnumber)
{
if(OrderType()==OP_BUY) // long position is open
{
if(Bid>=entry+scalp)
{
OrderClose(OrderTicket(),OrderLots(),Bid,slippage,Blue);
return(0);
}
}
if(OrderType()==OP_SELL) // short position is open
{
if(Ask<=entry-scalp)
{
OrderClose(OrderTicket(),OrderLots(),Ask,slippage,Blue);
return(0);
}
}
}
}
return(0);
}
//+------------------------------------------------------------------+
Hiya Sherri, just been piddling with my EAs most of the day. Funny how my brain thinks about 12 steps ahead of my coding skills and my, my the tangents I've been on. Been working on a tunnel EA today mostly, with surprisingly decent results. I've modified it about 10 times and it hasn't gotten much better lol.
Where ya been Git??? I told ST I got the SAR added today, and right now, I am finishing up with an MA cross also, so between the three, I think my entries should be refined. Then, the next step is to do some tests on when the indies start reversing so I can take profits before they change too much....
This is just way too much fun!
I'm still just a baby in MT4 terms, the only time stuff I have messed with is the indicators on multiple charts and using the global variables to share info....
BUT, since custom indicators are based upon ticks, I'll bet the time functions would not be that difficult to use.
Sherri have you ever done anything with the Time functions in MT4? For example, on an Heiken Ashi chart lets say you were 4:40 into the current 5 min bar and the price was so far away from the ends of the candle that you could more or less predict what the candle was going to look like before it actually printed. Just a wild thought.
I know....I am still trying to kick this bronchitis...haven't felt like doing much of anything.
OK gang, I have coded probably 5 EAs since starting with MT4 and I keep thinking about HA candles, specifically HA candles with no tails since on an HA chart these signify a strong trend. My idea is to find a candle with no tail and a long body. Here is my code so far, but it doesn't work like I expected it would, some timeframes work great, some pairs work great, but not all. In theory, it should be a perfect trend follower, trading the HA trend similar to a Renko chart...here is the code so far.
I think there is definitely merit to this, but gotta step through the logic first...
//+------------------------------------------------------------------+
//| HA_EA.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""
extern double SL=40;//Stop Loss
extern double TP=200;//Take Profit
extern double lots=0.10;
extern int slippage=3;
extern int magicnumber=913;
double scalp=0.75;
double entry;
bool up=False;
bool down=False;
//***************** START **********************
int start()
{
int D=(Digits);//# of digits after decimal of current pair in the window
double SNSL=NormalizeDouble(Bid+SL*Point,D);//Short position stop loss
double SNTP=NormalizeDouble(Bid-TP*Point,D);//Short position take profit
double LNSL=NormalizeDouble(Ask-SL*Point,D);//Long position stop loss
double LNTP=NormalizeDouble(Ask+TP*Point,D);//Long position take profit
int OT=OrdersTotal();
//first determine previous HA candle
double haC=(Open[1]+High[1]+Low[1]+Close[1])/4;
double haO=(Open[1]+Close[1])/2;
double haH=MathMax(High[1],MathMax(haO,haC));
double haL=MathMin(Low[1],MathMin(haO,haC));
//find a candle where there is no upper/lower tail and a body longer than 30
//percent of the candle
if(haL>=haO && MathAbs(haC-haO)>(0.3*MathAbs(haH-haL))) up=True; else up=False;
if(haH<=haO && MathAbs(haC-haO)>(0.3*MathAbs(haH-haL))) down=True; else down=False;
//if(OT==1) Print("CSum = ",CSum, " | PCSum = ",PCSum," || Orders Open = ",OT," Entry Price - ",entry, " Target Price - ",entry+scalp);
if(OT<1) //Are any orders open already?
{
//SHORT ENTRY
if(down==True && IsTradeAllowed()==True)
{
int shortticket=OrderSend(Symbol(),OP_SELL,lots,Bid,slippage,SNSL,SNTP,"Short Order Being Placed ",magicnumber,0,Red);
if(shortticket<0)
{
Print("Short Order Send failed - error #",GetLastError());
}
if(shortticket>0)
{
if(OrderSelect(shortticket,SELECT_BY_TICKET,MODE_TRADES))
entry=OrderOpenPrice();
Print("SELL order opened : ",OrderOpenPrice(),"|| Target Price : ",entry-scalp);
}
return(0);
}
//LONG ENTRY
if(up==True && IsTradeAllowed()==True)
{
int longticket=OrderSend(Symbol(),OP_BUY,lots,Ask,slippage,LNSL,LNTP,"Long Order Being Placed ",magicnumber,0,Green);
if(longticket<0)
{
Print("Long Order Send failed - error #",GetLastError());
}
if(longticket>0)
{
if(OrderSelect(longticket,SELECT_BY_TICKET,MODE_TRADES))
entry=OrderOpenPrice();
Print("BUY order opened : ",OrderOpenPrice(),"|| Target Price : ",entry+scalp);
}
return(0);
}
return(0);
}
//************** Close Orders ***********************
for(int cnt=0;cnt<OT;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderMagicNumber()==magicnumber)
{
if(OrderType()==OP_BUY) // long position is open
{
if(haL<haO)
{
OrderClose(OrderTicket(),OrderLots(),Bid,slippage,Blue);
return(0);
}
}
if(OrderType()==OP_SELL) // short position is open
{
if(haH>haO)
{
OrderClose(OrderTicket(),OrderLots(),Ask,slippage,Blue);
return(0);
}
}
}
}
return(0);
}
//+-----------------------------------------
LOL Sherri, time to get busy with all the ideas that need to come to fruition.
Here's a cool split ECO indie. This is only going to be one part of a larger picture, but it's just too sweet to ignore.
Here's the screenshot:
Here's the code:
//+------------------------------------------------------------------+
//| ECO_SplitTest.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""
#property indicator_separate_window
#property indicator_buffers 7
#property indicator_color1 IndianRed//Hi-Lo
#property indicator_color2 Red
#property indicator_color3 Gold//Open-Close
#property indicator_color4 Red
#property indicator_color5 MediumSeaGreen//Lo-Hi
#property indicator_color6 Red
//---- input parameters
extern int M1=9;
extern int M2=14;
//---- buffers
double HLTSignalBuffer[];
double COSignalBuffer[];
double HLBSignalBuffer[];
double ECBuffHLT[];
double ECBuffCO[];
double ECBuffHLB[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(6);
//---- drawing settings
SetIndexStyle(0,DRAW_LINE);//HLTSignalBuffer
SetIndexStyle(1,DRAW_NONE);//ECBuffHLT
SetIndexStyle(2,DRAW_LINE);//COSignalBuffer
SetIndexStyle(3,DRAW_NONE);//ECBuffCO
SetIndexStyle(4,DRAW_LINE);//HLBSignalBuffer
SetIndexStyle(5,DRAW_NONE);//ECBuffHLB
SetIndexDrawBegin(0,M1);
SetIndexDrawBegin(1,M1);
SetIndexDrawBegin(2,M1);
SetIndexDrawBegin(3,M1);
SetIndexDrawBegin(4,M1);
SetIndexDrawBegin(5,M1);
//---- indicator mapping
SetIndexBuffer(0,HLTSignalBuffer);
SetIndexBuffer(1,ECBuffHLT);
SetIndexBuffer(2,COSignalBuffer);
SetIndexBuffer(3,ECBuffCO);
SetIndexBuffer(4,HLBSignalBuffer);
SetIndexBuffer(5,ECBuffHLB);
//---- indicator labeling
IndicatorShortName("ECO Split- ( "+M1+","+M2+" )");
// SetIndexLabel(0,"High-Low");
// SetIndexLabel(2,"Close-Open");
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
// if(counted_bars>0) counted_bars--;
// limit=Bars-counted_bars;
//---- H-L array
// for(int i=0; i<limit; i++)
// ECBuffHLT=(High-Low[i+1])*100;
//---- H-L signal line
// for(i=0; i<limit; i++)
// HLTSignalBuffer=iEnvelopesOnArray(ECBuffCO,Bars,M2,0,MODE_EMA,5,MODE_UPPER,i);
int counted_bars1=IndicatorCounted();
if(counted_bars1>0) counted_bars1--;
limit=Bars-counted_bars1;
//---- C-O array
for(int k=0; k<limit; k++)
ECBuffCO[k]=(Close[k]-Open[k+1]);
//---- C-O signal line
for(k=0; k<limit; k++)
COSignalBuffer[k]=iMAOnArray(ECBuffCO,Bars,M1,0,MODE_EMA,k)*100;
for(k=0; k<limit; k++)
HLBSignalBuffer[k]=iEnvelopesOnArray(COSignalBuffer,Bars,M2,0,MODE_EMA,500,MODE_LOWER,k);
for(k=0; k<limit; k++)
HLTSignalBuffer[k]=iEnvelopesOnArray(COSignalBuffer,Bars,M2,0,MODE_EMA,500,MODE_UPPER,k);
// if(counted_bars>0) counted_bars--;
// limit=Bars-counted_bars;
//---- H-L array
// for(i=0; i<limit; i++)
// ECBuffHLB=(Low-High[i+1])*100;
//---- H-L signal line
// for(i=0; i<limit; i++)
// HLBSignalBuffer=iEnvelopesOnArray(ECBuffCO,Bars,M2,0,MODE_EMA,5,MODE_LOWER,i);
//---- done
return(0);
}
// EC1:= MOV((MOV(C-O,MT,MAT)),MT2,MAT);
// EC2:= MOV((MOV(H-L,MT,MAT)),MT2,MAT);
//+------------------------------------------------------------------+
iMAOnArray
From what I can tell iMAOnArray only works with MT4s other outputs like iCCI etc. I have yet to get it to work with an array created within the code itself. Here is my code I was working on to create an ECO indicator with the two parts of the ECO broken out. It plots the H-L and the C-O components great, but stumbles when you try to use the iMAOnArray function. I've coded the sumbeech backwards and forwards about 12 times in every way I can think of and even used the ArraySetAsSeries function to no avail. Only solution is to manually calculated the EMA of the array I think.
-------------------------------
#property copyright ""
#property link ""
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 MediumSeaGreen
#property indicator_color2 Red
//---- input parameters
extern int M1=9;
extern int MA1=MODE_EMA;
extern int M2=26;
//---- buffers
double ECBuffHL[];
double ECBuffCO[];
double ECBuff1[];
double ECBuff2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(2);
//---- drawing settings
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexDrawBegin(0,M1);
SetIndexDrawBegin(1,M1);
//---- indicator mapping
SetIndexBuffer(0,ECBuffHL);
SetIndexBuffer(1,ECBuffCO);
//---- indicator labeling
IndicatorShortName("ECO - ("+MA1+","+M1+","+M2+")");
SetIndexLabel(0,"Close-Open");
SetIndexLabel(1,"High-Low");
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
double ECBuff1[];
double ECBuff2[];
int counted_bars=IndicatorCounted();
int i=Bars-M1;
// if(counted_bars>M1) i=Bars-counted_bars-1;
if(counted_bars>0) counted_bars--;
int P=Bars-counted_bars;
i=Bars-counted_bars-1;
while (i>=0)
{
double high=High;
double low=Low;
double close=Close;
double open=Open;
ECBuffHL=high-low;
ECBuffCO=close-open;
i--;
}
i=Bars-counted_bars-1;
for(i=0; i<P; i++)
ECBuff1=iMAOnArray(ECBuffHL,0,M1,0,MODE_EMA,i);
for(i=0; i<P; i++)
ECBuff2=iMAOnArray(ECBuffCO,0,M1,0,MODE_EMA,i);
Comment("I Value- ",i," Bars- ",Bars," P Value- ",P," Counted Bars- ",counted_bars);
return(0);
}
//+------------------------------------------------------------------+
I've been wrestling with this same issue with my code and I thought I would share this with all. It appears to be simply impossible to close a trade after a certain number of pips has been attained due to limitations with the VT Trader setup. From what I read, the only time a trade will auto-close after a set take profit has been reached is if the next candle closes above it. I have re-written my code at least 50 times and spent at least 10 hours trying to make this happen when it seems that it cannot happen due to VT system limitations.
This has some fairly major implications in that you must be right on at least the 2 candle trend in any system you build. I have some ideas for a work-around for this issue and will post them if they prove to be substantial.
-----------------------------------
QUOTE
Hi, im new to this forum and i apologize if my question has allready been answerd, but i just dont find the answer... I'm having problem with my code, and i cant figure it out... i want to set my closeposition after 10pips are reached:
OpenBuy:= LongSignal AND (EventCount('OpenBuy') = EventCount('CloseBuy'));
CloseBuy:= ShortSignal AND (EventCount('OpenBuy') > EventCount('CloseBuy'));
What do i have to add to CloseBuy part so it would close my positions after 10 pips are reached?
If someone could just explain it to me i'd be veary happy. And excuse me again if there allready is an answer in forum.
--------------------------------------------------------
I recommend that you read through the following FAQ:
http://forum.vtsystems.com/index.php?showtopic=3742
It won't answer your question directly, but it's good information for you to know. In short, it's not possible to have your "close position" request a trade exit at exactly a 10 pip profit. Trading systems are not capable of requesting, managing, or removing stoploss and/or limit profit orders for its open positions. Additionally, trading systems can only request automated order requests at the close of a bar, not intrabar. This means once your condition is true, the position will not be exited until the close of bar assuming your condition is still true when the bar closes. Also, the trading systems don't have any 'real' knowledge of the positions opened/closed by itself; in other words, the trading systems cannot know the actual entry price of the trade it requested (or even if that trade actually got accepted and placed successfully by the broker for that matter) and as such, it cannot be determined with 100% accuracy at exactly what price the system must exit to achieve a 10 pips or greater profit.
The best that can be done (usually) is to include take profit logic into the trading system. This logic works like any other exit logic and the requests to close the trade will still happen at the close of the bar assuming price has crossed over/under your "simulated" take profit level. If you'd like to see this type of logic in a system, please review the "template system" topic in the New Trading Systems Postings forum and then download and try out the "template #15'.
----------------------------------------
yeah I understand
a lot of promise with these things
Well, actually I started with the stock VT system code from one of their systems and modified it with the macd pinch and adx parameters. The one you link to is very well written but I do not want to copy someone elses code. It takes me a little longer to write it, but by understanding it totally, it's better in the longrun and easier to make changes. Plus there are so many things that could be done with this that I want to understand the flow of logic very well first. Code could be written that looks for almost anything you ever manipulated an indicator to produce and even combine multiple instances. Been a 13 hour day for me today and probably the next two so probably Sunday before I can get any dedicated time on tweaking it.
so is this what you are working on right now, the fisher system
http://forum.vtsystems.com/index.php?showtopic=9635&st=0
yeah can't argue there. right now I am working on a better cci setup and to get a RMI system. They have never created one before.
I'm gittin there. Having a little trouble getting the trade exit to work after a set number of pips but it's a matter of time. There are all sorts of things someone could do with this...pretty much limited only by your imagination I think.
That's pretty sweet, so I take it you know how to code these things.
OK gang, here is the code right now. I used the linear regression of the macd histogram for the last 5 bars vs the linear regression slope of the last 9 bars in conjunction with the MinusDI above a user inputted number to generate the buy signals. Still working on the take TP, SL, and trailing stop part of it but as you will see, it generated some awesome signals today if you were looking to scalp for 10 pips or even more. It is exponentially easier to work with this now after I've spent a few hours becoming familiar with it.
-----------------------------------------------------------
{Control Error}
{Git Me A Pincer}
Error_DmiPeriods:= Error(Pr=0,'Input Error: "DMI & ADX Periods" cannot equal zero!');
{Determine the MACD parameters}
{s1=short ma price (default-close)}
{s2=short ma period (default-12)}
{s3=short ma type (default-exponential)}
{l1=long ma price (default-close)}
{l2=long ma period (default-26)}
{l3=long ma type (default-exponential)}
{sig1=signal period (default-9)}
{sig2=signal type (default-exponential)}
{hist1=histogram}
FL:= Mov(s1,s2,s3)- Mov(l1,l2,l3);
SL:= Mov(FL,sig1,sig2);
Hist1:=FL-SL;
{Determine the MACD Hook by examining the linear regression slope
of the macd histogram}
TRHist:=linregslope(Hist1,5)<linregslope(Hist1,9);
{Directional Movement System}
TH:= If(Ref(C,-1)>H,Ref(C,-1),H);
TL:= If(Ref(C,-1)<L,Ref(C,-1),L);
TR:= TH-TL;
PlusDM:= If(H>Ref(H,-1) AND L>=Ref(L,-1),
H-Ref(H,-1),
If(H>Ref(H,-1) AND L<Ref(L,-1) AND H-Ref(H,-1)>Ref(L,-1)-L,
H-Ref(H,-1),
0));
PlusDI:= 100*Wilders(PlusDM,Pr)/Wilders(Tr,Pr);
MinusDM:= If(L<Ref(L,-1) AND H<=Ref(H,-1),
Ref(L,-1)-L,
If(H>Ref(H,-1) AND L<Ref(L,-1) AND H-Ref(H,-1)<Ref(L,-1)-L,
Ref(L,-1)-L,
0));
MinusDI:= 100*Wilders(MinusDM,Pr)/Wilders(Tr,Pr);
{Long/Short Entry/Exit Display Signals}
{MACDT = macd negative fast line parameter}
{MinusDIT = minusDI positive parameter}
{Enter long when the last 3 histogram bars are getting shorter and
the minusDI and the MACD fast line are below user input variables}
Long:= TRHist=1 AND MinusDI >= MinusDIT AND FL <= MACDT;
{Trend Direction}
UpTrend:= TRHist=1 and PlusDI>MinusDI and FL <= MACDT;
{Auto-Trading Functionality; Used in Auto-Trade Mode Only}
OpenBuy:= Long AND (EventCount('OpenBuy') = EventCount('CloseBuy'));
CloseBuy:= C=TP AND (EventCount('OpenBuy') > EventCount('CloseBuy'));
{OpenSell:= Short AND (EventCount('OpenSell') = EventCount('CloseSell'));
CloseSell:= Long AND (EventCount('OpenSell') > EventCount('CloseSell'));}
if you have any issues you can either send them a request or they can help you out on their forum
Definitely! I'm working on determining the macd hook. Not used to their syntax so it takes a bit of reading through the code to see which variables they are passing.
also add T/P, S/L and T/S
here are some of their parameters
{Create Auto-Trading Functionality}
OpenBuy:= LongEntrySignal and (eventCount('OpenBuy')=eventCount('CloseBuy'));
CloseBuy:= LongExitSignal and (eventCount('OpenBuy')>eventCount('CloseBuy'));
OpenSell:= ShortEntrySignal and (eventCount('OpenSell')=eventCount('CloseSell'));
CloseSell:= ShortExitSignal and (eventCount('OpenSell')>eventCount('CloseSell'));
{***********************************************}
{Calculate Simulated Individual Trade Profit In Pips}
_TradeProfitInPips:= If(LongExitSignal=1,LongExitPrice - (LongEntryPrice + _Spread) - _Spread,
If(ShortExitSignal=1,ShortEntryPrice - (ShortExitPrice + _Spread) - _Spread,
0));
TradeProfitInPips:= if(SymbolDigits()=4, _TradeProfitInPips * 10000, _TradeProfitInPips * 100);
{Calculate Simulated Total Profit In Pips}
TotalProfitInPips:= cum(TradeProfitInPips);
{Calculate Number of Trades}
{LongTrades:= cum(LongExitSignal);
ShortTrades:= cum(ShortExitSignal);}
This is what I'm starting with - the stock VT Trader ADX platform and going to build from here out toward a pincer setup.
-------------------------
{Control Error}
Error_DmiPeriods:= Error(Pr=0,'Input Error: "DMI & ADX Periods" cannot equal zero!');
{Directional Movement System}
TH:= If(Ref(C,-1)>H,Ref(C,-1),H);
TL:= If(Ref(C,-1)<L,Ref(C,-1),L);
TR:= TH-TL;
PlusDM:= If(H>Ref(H,-1) AND L>=Ref(L,-1),
H-Ref(H,-1),
If(H>Ref(H,-1) AND L<Ref(L,-1) AND H-Ref(H,-1)>Ref(L,-1)-L,
H-Ref(H,-1),
0));
PlusDI:= 100*Wilders(PlusDM,Pr)/Wilders(Tr,Pr);
MinusDM:= If(L<Ref(L,-1) AND H<=Ref(H,-1),
Ref(L,-1)-L,
If(H>Ref(H,-1) AND L<Ref(L,-1) AND H-Ref(H,-1)<Ref(L,-1)-L,
Ref(L,-1)-L,
0));
MinusDI:= 100*Wilders(MinusDM,Pr)/Wilders(Tr,Pr);
DIDif:= Abs(PlusDI-MinusDI);
DISum:= PlusDI + MinusDI;
ADXFinal:= 100 * Wilders(DIDif/DISum,Pr);
ADXRCustom:= (ADXFinal+Ref(ADXFinal,1-Pr)) / 2;
_ADX := If(cT=0,ADXFinal,ADXRCustom);
{Long/Short Entry/Exit Display Signals}
Long:= Cross(PlusDI,MinusDI);
Short:= Cross(MinusDI,PlusDI);
{Trend Direction}
UpTrend:=PlusDI>MinusDI;
DownTrend:=MinusDI>PlusDI;
{Auto-Trading Functionality; Used in Auto-Trade Mode Only}
OpenBuy:= Long AND (EventCount('OpenBuy') = EventCount('CloseBuy'));
CloseBuy:= Short AND (EventCount('OpenBuy') > EventCount('CloseBuy'));
OpenSell:= Short AND (EventCount('OpenSell') = EventCount('CloseSell'));
CloseSell:= Long AND (EventCount('OpenSell') > EventCount('CloseSell'));
From the scan in the Ibox, the stocks returned on 5-14-08 were as follows:
AERG 2.09
COT 2.69
CRIS 1.27
IMOS 2.95
KOSN 1.7
NGLPF 1.08
NNPP 1.16
PLUG 3.13
QPCI 0.72
SCMR 3.32
VITA 2.18
We shall see how they do in the next 7 days and then time for modifications if necessary.
Here's another one I like:
[type = stock] and [daily sma(20,daily volume) > 100000] and [close > SMA(11,close)] and [SMA(10,close) > .95 * SMA(20,close)] and [2 days ago SMA(10,close) > .90 * SMA(20,close)] and [SMA(10,close) < SMA(50,close)] and [SMA(10,close) < SMA(20,close)] and [daily ppo line(12,26,9) < daily ppo signal(12,26,9)] and [close > .02] and [close < 15] and [country is US]
This one found MERX at 2.06 if I remember right. .55 gain from 2.10 or 26 percent. The 10 crossed the 50 though so I think I'll hang onto it for a while longer and see if it can't break that 100.
Followers
|
5
|
Posters
|
|
Posts (Today)
|
0
|
Posts (Total)
|
102
|
Created
|
01/10/08
|
Type
|
Free
|
Moderator gitonwithit | |||
Assistants |
Welcome to the WD Gann board!
I've been studying WD Gann and his methods for a couple of years now and I will tell you that I have a rudimentary understanding of Gann methods at best. I have traded different things over the years and Gann's methods always struck me as being simple and to the point. The reason for this board is to bring people together who are interested in contributing or learning from each other about how to apply his methods. This is not a place to pump stocks nor is it a place to promote other things so if you do so or violate IHub TOS then your posts will be deleted. There are no stupid questions and this board is open to everyone from beginners to advanced.
Subjects of interest would be SQ9, Gann angles, squaring price and time, examining time and astrological cycles, ratios, mathmatics, etc. Charts are welcome and appreciated!
My free software of choice is Gannalyst Pro 5.0. It may not have all the bells and whistles but Bill did a great job with it and for a free package it works great for me. I think Gann is about simplicity and the software has all the tools that I have felt like I needed.
http://www.gannalyst.com
If you're new to Gann, the best thing you can do is read about his methods and here are some links that I find helpful.
http://gann.su/book/eng/Jacobs%20-%20Gann%20Tutorial.pdf
http://www.educatedanalyst.com/ganns-greatest-fan
http://www.ibfx.com/Education/Gann-Theory
I usually keep a spreadsheet open in the background for making calculations on the fly and converting between calendar and trading, or between weeks, months, years, etc. One of my favorite spreadsheets looks like the one below and has various ratios and square roots and things. During my Gann studies I have become convinced that ratios and reciprocals fit right in with Gann's methods.
Volume | |
Day Range: | |
Bid Price | |
Ask Price | |
Last Trade Time: |