PDA

View Full Version : Possible Crossover Alert


1800promote
02-19-2009, 07:38 PM
Hello,

I have a simple strategy based on 2 simple moving average crossover
Let say we are 1 bar before a possible crossover. Since the moving averages are based on the closing price..the closing price of this bar will be very important and will lead to a signal or not.
Therefor i want to plot an alert message on the chart..something like
"Crossover alert! If curent bar closing price will be greater/below value x.xx the moving average will cross and a position will be initiated at the openning price of the next bar."
Basically i want to know before the bar close if the curent price of the bar will be enough to generate a crossover when the bar will be closed.
Is this possible?
Thank you.

roonius
02-19-2009, 11:00 PM
Hello,

I have a simple strategy based on 2 simple moving average crossover
Let say we are 1 bar before a possible crossover. Since the moving averages are based on the closing price..the closing price of this bar will be very important and will lead to a signal or not.
Therefor i want to plot an alert message on the chart..something like
"Crossover alert! If curent bar closing price will be greater/below value x.xx the moving average will cross and a position will be initiated at the openning price of the next bar."
Basically i want to know before the bar close if the curent price of the bar will be enough to generate a crossover when the bar will be closed.
Is this possible?
Thank you.

It's possible with additional calculations in the script.

1800promote
02-19-2009, 11:42 PM
well...any guidance on how to do it?..or is too complicated to try to do it myself..

roonius
02-20-2009, 12:03 AM
well...any guidance on how to do it?..or is too complicated to try to do it myself..

OK. Let's use two SMA's SMA10 and SMA20.
The approach would be like this:

CalculateOnBarClose = false;

if(SMA(10)[0] < SMA(20)[0] && Rising(SMA(10)))
{
double x = Close[0];

while((SUM(Close, 9)[1] + x)/10 <= (SUM(Close, 19)[1] + x)/20)
{
x+=TickSize;
}

if (x - Close[0] <= 2*TickSize)
{
Print ("Hey, we are less than two ticks away from possible crossover");
Print (" Be Prepared to Enter Long Position");
}
}

Viceversa for oposite direction.

I just give you an idea. I did not compile this code, I am writing it directly to the forum out of my head.

If you want to use EMA or HMA or whatever MA you should use the appropriate calculation formulas.

Hope it helps.

roonius

1800promote
02-20-2009, 05:02 PM
thank you.will try it.