Need help last buy sell

sir,

i want to help in afl writing. this is sample code

MA1 = MA(C,15);
MA2 = MA(C,20);

Buy = Cross(MA1,MA2); and no position open ( no last buy sell signal open )
Short = Cross(MA2,MA1); and no position open ( no last buy sell signal open )

how to add above in buy short code. please help

As per the above condition check the AFL code below

_SECTION_BEGIN("Zerodha");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
Buy = Cross (EMA( Close, 15 ), EMA( Close, 20 )) ;
Sell = Cross (EMA( Close, 20 ), EMA( Close, 15 )) ;
Short = Sell;
Cover = Buy;

PlotShapes (Buy*shapeHollowStar,colorGreen);
PlotShapes (Sell*shapeHollowStar,colorRed);
Plot( EMA( Close, 15 ),"med ema", colorRed,styleThick); 
Plot( EMA( Close, 20 ),"long ema", colorBlue,styleThick); 

//SL
Start_Trading = ParamToggle("Start Trading", "No|Yes",1);
_SECTION_END();

sir,
u didnt get me.sir i am trying to write afl and i want to know my previous trade is open or not. how to write it in afl. means if trade is open then 1 or 0 like this. i know i can use exrem for this but i need this for different purpose.

You want to know ? or get response of previous trade open ? or completed? is this your query?

sir i want response of previous trade open ? or completed? sir please help i am stuck here.

have to connected to any terminal with the help of some plugin or something? like Pi bridge, to get response you have to use the getpositions functions asper it defined in that plugin dll.

sir,
i will explain what i need
condition1 –
suppose ema crossover gives short signal as per rule say on 1 pm. now there is no cover signal come as per cover rule till 2.00 pm .again ema crossover gives short signal as per rule on 2.00 pm ( no exrem used ) now i dont want this signal come. because last short signal is open.
condition2–
suppose ema crossover gives short signal as per rule say on 1 pm now on 1.30 pm cover signal come as per cover rule so short trade is close now. at 2pm again ema crossover gives short signal as per rule ( no exrem used ) now i want this signal because last short signal is not open.
so in short i want repeat signals like buy after buy or short after short on chart when buy short rules met. but only when last buy short positions are closed by cover signal. can u show me how to do this on simple ema crossover system. so that i can get a clue. i am stuck here.

problem solved. thank u for ur time.