Plz help in MA program

 

Hello everybody,


I have query for EA program related to Moving Average.


WHEN MA20 ( MOVING AVERAGE WITH PEROID 20 AND PERIODICITY 5 MNTS) CROSS THE PIVOT LINE THIS WILL SELL AN ORDERS.


I have idea of pivot line and sell order program.My problem is on the main section "CROSS".How will i find the MA20 is crossed the pivot line.



if( pivot line == MA20 value) // virtual code //

Ordersend( SELL ORDER);


// this will for equal //


if(Pivot Line > MA20 value || Pivot Line < MA20 value) // virtual code //

Ordersend(SELL ORDER);


// This may order infinite "sell orders" .Suppose MA20 never cross the pivot line this will be always higher or lower by pivot line.Then this logic may wrong. //


Right ?


If u are not clear then plz reply becz i am very new with mql.


Plz help.....


Thanx..

 
ajay009ajay wrote >>

Hello everybody,

I have query for EA program related to Moving Average.

WHEN MA20 ( MOVING AVERAGE WITH PEROID 20 AND PERIODICITY 5 MNTS) CROSS THE PIVOT LINE THIS WILL SELL AN ORDERS.

I have idea of pivot line and sell order program.My problem is on the main section "CROSS".How will i find the MA20 is crossed the pivot line.

if( pivot line == MA20 value) // virtual code //

Ordersend( SELL ORDER);

// this will for equal //

if(Pivot Line > MA20 value || Pivot Line < MA20 value) // virtual code //

Ordersend(SELL ORDER);

// This may order infinite "sell orders" .Suppose MA20 never cross the pivot line this will be always higher or lower by pivot line.Then this logic may wrong. //

Right ?

If u are not clear then plz reply becz i am very new with mql.


Plz help.....

Thanx..


The general solution of this type of problems is they will checking the values of last bar and current bar. For example, if ma20 last bar < pivot line and ma20 current bar > pivot line, means ma20 is cross up above pivot line, such and such. Thanks.

Reason: