Do you mean a 2 bar reversal. What time frame are you thinking of using
Do you use some timefilter for the EA to work or this EA will work 24hrs? What's the timeframe?
Like this??
if(Volume[0]<1) {
if(Close[1]>Open[1] && Close[2]<Open[2]) OrderSend(...,OP_BUY,...);
if(Close[1]Open[2]) OrderSend(...,OP_SELL,...);
}
Thanks for the replies everyone. I wanted a statement that would work for any time frame.
I came up with this and it seems to work.
// get the open and close for last two bars
OpenLastBar = iOpen(NULL,0,1);
OpenPreviousBar = iOpen(NULL,0,2);
CloseLastBar = iClose(NULL,0,1);
ClosePreviousBar = iClose(NULL,0,2);
// check if conditions are met
if(OpenLastBar=ClosePreviousBar) siCurrentDirection = 1; //up
if(OpenLastBar>CloseLastBar && OpenPreviousBar<=ClosePreviousBar) siCurrentDirection = 2; //down
This is just the beginning of what I want to accomplish but, it is a start.
Thanks for the help, all
Shorter yet
I have learned that this will work as well;
if(iOpen(NULL,0,1)=iClose(NULL,0,2)) siCurrentDirection = 1; //up
if(iOpen(NULL,0,1)>iOpen(NULL,0,2) && iOpen(NULL,0,2)<=iClose(NULL,0,2)) siCurrentDirection = 2; //down
A little shorter than the first I made.
I believe I can use the "TimeFrame" standard constant inside these to get
data from other time frames. But, this will work for now.
Have a great day Everyone!!
One more try
Forget everything past, this is what I meant;
if(iOpen(NULL,0,1)=iClose(NULL,0,2)) siCurrentDirection = 1; //up
if(iOpen(NULL,0,1)>iClose(NULL,0,1) && iOpen(NULL,0,2)<=iClose(NULL,0,2)) siCurrentDirection = 2; //down
That's what I get for being in a hurry.
It is a good thing my head is attached.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello All,
I have been searching around for an EA with no luck and have been unable to create one that does exactly what I want it to do.
What I am looking for is an EA that will place a buy or sell order based on the opening and closing of the last two bars in the current chart.
Specifically, if the close of bar[1] is greater than the open of bar[1] and the close of bar[2] was less than the open of bar[2] (a price reversal), a buy order is placed on the open of bar[0]. A sell would be the opposite.
The EA doesn't need to be fancy or anything like that. Actually, what I could probably work with is just the formula that is needed to satisfy these conditions.
Any help that is offered will be greatly appreciated. In the mean time, I will continue to try to create the proper formula.
Thank you for your attention,
Ron