Help Needed to Create AFL For Crossover Moving Average.

V.V.

Active Member
#1
Dear Experts,
I like to get AFL for Below Condition. Please Help Me.

Condition :
Buy Signal:-
i) I want create Buy Signal "When Moving average 50 Crossover the price & After the Price go above ten points"

[ Please Assume If Nifty Price is 3600. Movingaverage 50 is now crossover the price=3600, after then Nifty go up to 3610 now I want show Buy Signal in 3610. ]

I USE HERE ONLY ONE MOVING AVERAGE.

ii) I want create Sell Signal "When Moving average 50 Crossover the price & After the Price go Below ten points"

[ Please Assume If Nifty Price is 3600. Movingaverage 50 is now crossover the price=3600, after then Nifty go Down to 3590 now I want show Sell Signal in 3590. ]


I am waiting for yours reply.

Regards
V.V.
 

pasha

Active Member
#2
Since this seems to be for intraday and Nifty only, just put the 50 MA on the chart and wait for the crossover. If you want it for scanning multiple stocks then you need to scan with this
x = (C+10) > MA(C,50);
Buy = x;
 

V.V.

Active Member
#3
// Identify the price when the MA crosses above the price.
crossOverValue = ValueWhen( Cross( MA(C, 50), C), C, 1);

// Trigger the buy-signal when the price crosses above the crossOverValue + 10 points.
buySignal = Cross( C, crossOverValue + 10 );

// Trigger the Buy signal when the condition is met.
Buy = buySignal;

// Further code can be written to avoid whip-saws of the buy-signal.
Dear Sir,
Thankyou for your Help. I tried this formula. Please See the Attachment file. Here I used 10 MA . When this Movingaverage Crossover the price at the same time that price go to above 10 points then I like to show Buy signal at the same time after i got Buy signal When this MA Crossover the Price Below at the same time that price go to below 10 Points then here I want to show Cover Signal. Please Can help to create AFL For this Method .

Long :-
======
1) MA Crossover Above the Price (AND) After Price goto + 10 Points ===> Buy Signal
2) After I got Buy signal Price + 20 Points (Profit Booking) ===> cover Signal

Stoploss (Exit Long) :-
=================
1st condition true but second condition false then I should show Long Cover (Stoploss) Signal.
Condition : MA Crossover Below the Price -10 Points === Exit Long Signal

Short :-
======
1) MA Crossover Below the Price (AND) Price goto -10 Points ===> Sell Signal
2) After I got sell signal Price + 20 Points (profit Booking) ===> cover Signal

Stoploss (Exit Short) :-
=================
1st condition true but second condition false then I should show Short Cover (Stoploss) Signal.
Condition : MA Crossover Above the Price (AND) Price goto + 10 Points ===> Exit Short Signal

=========================================================
I Used This AFL :
_SECTION_BEGIN("Test");
Title = Name() + " " + Date() + " Open:" + O +"," + " High: " + H +"," + " Low: " + L+"," + EncodeColor( colorBlue ) + " Close: " + C+"," + EncodeColor( colorBlack ) + " Volume: " + V ;//+ EncodeColor( colorBlue )+ "\n" + EncodeColor(colorDarkGreen) + WriteVal (XR, format=1.2 ) + " Price Required for EMA Crossover";
Plot(EMA( Close,10), "", colorRed );
// Identify the price when the MA crosses above the price.
crossOverValue = ValueWhen( Cross( MA(C, 10), C), C, 1);
// Trigger the buy-signal when the price crosses above the crossOverValue + 10 points.
buySignal = Cross( C, crossOverValue + 10 );
// Trigger the Buy signal when the condition is met.
Buy = buySignal;
shape = Buy * shapeUpArrow ;
PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, Low, High ) );
// Further code can be written to avoid whip-saws of the buy-signal.
_SECTION_END();
==========================================================
Kindly help me.


Regards
V.V.
 

Attachments

Similar threads