Amibroker scan clubbing stocks together

pannet1

Well-Known Member
#23
i wanted to add buy sell signals to the exploration AFL, so that i can backtest if the strategy has an edge. Here is an attempt. While the code look crude the results are not .. its trading every bar. Sorry cannot get away from MQL influence i had ...

Code:
for( i = 0; i < BarCount; i++ )
{

weightedMA = WMA(Avg, 65);

// Buy AND Short signal
IIf((High[1]>weightedMA AND Open[1]<weightedMA) AND (Open[1]<Close[1]),Buy=1,0);
IIf((Low[1]<weightedMA AND Open[1]>weightedMA)  AND (Open[1]>Close[1]),Short=1,0);

// Sell AND Cover signal
IIf((High[1]>weightedMA AND Open[1]<weightedMA) AND (Open[1]<Close[1]),BuyStop=Low[1],0);
IIf((Low[1]<weightedMA AND Open[1]>weightedMA)  AND (Open[1]>Close[1]),SellStop=High[1],0);
}

// TODO
// buy and sell stop order handling

// of stop is not hit till 15 Hrs, then exit
Cover = TimeNum() == 150000;
Sell = TimeNum() == 150000;
 
#24
i wanted to add buy sell signals to the exploration AFL, so that i can backtest if the strategy has an edge. Here is an attempt. While the code look crude the results are not .. its trading every bar. Sorry cannot get away from MQL influence i had ...

Code:
for( i = 0; i < BarCount; i++ )
{

weightedMA = WMA(Avg, 65);

// Buy AND Short signal
IIf((High[1]>weightedMA AND Open[1]<weightedMA) AND (Open[1]<Close[1]),Buy=1,0);
IIf((Low[1]<weightedMA AND Open[1]>weightedMA)  AND (Open[1]>Close[1]),Short=1,0);

// Sell AND Cover signal
IIf((High[1]>weightedMA AND Open[1]<weightedMA) AND (Open[1]<Close[1]),BuyStop=Low[1],0);
IIf((Low[1]<weightedMA AND Open[1]>weightedMA)  AND (Open[1]>Close[1]),SellStop=High[1],0);
}

// TODO
// buy and sell stop order handling

// of stop is not hit till 15 Hrs, then exit
Cover = TimeNum() == 150000;
Sell = TimeNum() == 150000;
Your backtest code attached.
 

Attachments