Quote:
Originally Posted by cja
Can you give me an example of what you are talking about, and i will see if i can apply it to my situation, thanks
|
cja,
If I understood your question correctly, this may work (otherwise my appologies).
1. define couple of variales before the start() function. Note that the crossPrice variable is created as static variable so that the value assigned to remains static until changed
static double crossPrice;
int crossDirection; //1=up, 2=down, 0=no direction
2. check the crossing of the MA's (I just used a period of 6 & 13). If the MA's crossed, assign the price (it could be ask, bid or (ask+bid/2).
crossDirection=0;
double ma_06_0=iMA(NULL,0,6,0,MODE_SMA,PRICE_CLOSE,0);
double ma_13_0=iMA(NULL,0,13,0,MODE_SMA,PRICE_CLOSE,0);
double ma_06_1=iMA(NULL,0,6,0,MODE_SMA,PRICE_CLOSE,1);
double ma_13_1=iMA(NULL,0,13,0,MODE_SMA,PRICE_CLOSE,1);
if (ma_06_0>ma_13_0 && ma_06_1<ma_13_1)
{
crossPrice=Ask; // or bid or (ask+bid)/2
crossDirection=1; // ie. direction is up
}
if (ma_13_0>ma_06_0 && ma_13_1<ma_06_1)
{
crossPrice=Bid; // or bid or (ask+bid)/2
crossDirection=2; // ie. direction is down
}
The Value in crossPrice remains unchanged until the next cross occurs. Please let me know if this is what you are looking for.