Hi,
First time posting query here, I'm not sure how to search for similar issue here,
I have a simple buy and sell strategy, just that when sell signal generated, if it's a flat day, i.e, High == Low
then don't sell, check the next day.
Attached the afl and data,
As per the data, say Buy signal generated on Jan 04 2018, then the Sell signal to be triggered on Jan 5th 2018, Jan 5th was a flat day, so i want the position to be open and goto next day, Jan 8th, was not a flat day, then Sell signal to be triggered.
SetFormulaName("Sample System v0.1");
SetOption( "MinShares", 1 );
SetOption( "UsePrevBarEquityForPosSizing", True );
SetOption( "MaxOpenpositions", 10);
SetOption( "AllowSameBarExit", false );
SetPositionSize(10,spsPercentOfEquity);
Short = Cover = 0;
MinPrice = 5;
ROCTrend = ROC(C, 10);
NotFlat = !(Ref(H, -1) == Ref(L, -1) OR Ref(H, -2) == Ref(L, -2) OR Ref(H, -3) == Ref(L, -3));
TodayNotFlat = !(H == L);
Buy = O > MinPrice AND NotFlat;
Buy = Buy AND TodayNotFlat;
BuyPrice = O;
SellPrice = O;
InTrade = False;
//Loop through all the bars
for(i=0; i< BarCount; i++){
if(Buy[i] == 1) {
InTrade = True;
continue;
}
else if(InTrade && H[i] != L[i])
{
Sell[i] = 1;
InTrade = False;
}
}
PositionScore = 100 - ROCTrend;
Data:
Ticker,Date/Time,Open,High,Low,Close,Volume
534748,04-01-2018,46.25,50.65,46.25,46.25,116414
534748,05-01-2018,43.95,43.95,43.95,43.95,17095
534748,08-01-2018,41.80,44.15,41.80,42.15,205410
534748,09-01-2018,40.80,43.20,40.05,41.80,340953
534748,10-01-2018,41.80,42.50,41.40,41.70,120428
When I back test this afl with the attached data, the result aren't consistent,
Not sure whats wrong, I did test this with the 6.28 beta and 6.20.1, the results are same!
Any help would be really appreciated
thanks