CanOz
Home runs feel good, but base hits pay bills!
- Joined
- 11 July 2006
- Posts
- 11,543
- Reactions
- 519
/*
ASF Sample System Development 2 Inside days
*/
// Define system options - can modify these as required
SetChartOptions( 2, chartShowDates|chartShowArrows );
SetBarsRequired(10000,10000);
SetTradeDelays( 1, 1, 1, 1);
SetOption( "initialequity", 100000 );
SetOption( "MaxOpenPositions", 10 );
SetOption( "PriceBoundChecking", 1 );
SetOption( "CommissionMode", 1 );
SetOption( "CommissionAmount", 0.1 );
BuyPrice = SellPrice = Open;
ShortPrice = CoverPrice = Open;
PositionSize = -10; // always invest 10% of the current Equity
// Define and initialise variables
ATRMult = 3.5;
ATRPeriod = 14;
// Check if 2 Inside days occur
InsideDay1 = H < Ref(High,-1) AND Low > Ref(Low,-1);
InsideDay2 = Ref(High,-1)< Ref(High,-2) AND Ref(Low,-1)> Ref(Low,-2);
InsideDayCond = InsideDay1 == 1 AND InsideDay2 == 1;
/*
Notes:
To Do:
Add in a liquidity filter
Consider prerequisite conditions for trade entry
From Nick's post:
Consider an appropriate reference point.
Possibility of using n ATR:
if entry condition met then look for entry trigger;
if High is exceeded by n ATR then enter long;
if Low is exceeded by n ATR then enter Short;
*/
// Long side - buy and sell conditions
// Buy Condition
BuySig = InsideDayCond AND High > EMA(C,35);
// Sell Condition
// SellSig = condition.......
Buy = BuySig;
//Buy = ExRem(BuySig, SellSig);
//Sell = ExRem(SellSig, BuySig);
// Short side - short and cover conditions
// Short Condition
ShortSig = InsideDayCond AND Low < EMA(L,35);
// Cover Condition
// CoverSig = condition .......
Short = ShortSig;
//Short = ExRem(ShortSig, CoverSig);
//Cover = ExRem(CoverSig, ShortSig);
// Lists exploration results conforming to our buy/sell OR short/cover criteria
//Filter = Buy OR Sell OR Short OR Cover;
Filter = Buy OR Short;
AddColumn(Buy, "Buy", 1, colorDefault,IIf(Buy,colorGreen,colorDefault));
//AddColumn(Sell, "Sell", 1, colorDefault,IIf(Sell,colorRed,colorDefault));
AddColumn(Short, "Short", 1, colorDefault,IIf(Short,colorGreen,colorDefault));
//AddColumn(Cover, "Cover", 1, colorDefault,IIf(Cover,colorRed,colorDefault));
AddColumn(Open, "Open", 4.3);
AddColumn(Low, "Low", 4.3);
AddColumn(High, "High", 4.3);
AddColumn(Close, "Close", 4.3);
Tech was also going to work on some coding.
Mine will be metastock format.
I believe this has been discussed over at reefcap. Nick may be able to provide more info.Would it be worthwhile considering an approach similar to the ID/NR4Day system as described by Connors and Raschke?
This is doing my head in!!!!
I can't get it to buy on the next bar after the insidedaycond.
It keeps buying on inside bar 1.....
Enough for tonite...my GF and i have been trying to figure it out....she getting it (AFL) faster than me.
Cheers,
I believe this has been discussed over at reefcap. Nick may be able to provide more info.
/*
ASF Sample System Development
2 Inside days AND 6/100 Historical Volatility Ratio
*/
// Define system options can modify these as required
SetChartOptions( 2, chartShowDates|chartShowArrows );
SetBarsRequired(10000,10000);
SetTradeDelays( 1, 1, 1, 1);
SetOption( "initialequity", 100000 );
SetOption( "MaxOpenPositions", 10 );
SetOption( "PriceBoundChecking", 1 );
SetOption( "CommissionMode", 1 );
SetOption( "CommissionAmount", 0.1 );
BuyPrice = SellPrice = Open;
ShortPrice = CoverPrice = Open;
PositionSize = -10; // always invest 10% of the current Equity
// Setup Conditions
VolumeCond = EMA(V * C, 21) > 500000; // Ensure at least $500k of money flow for 21 periods
EMABuyCond = EMA(C, 35);
EMAShortCond = EMA(L, 35);
// BuyTrigCond = O > Ref(L,-1); not used in this version
// NR4DAY
// NR4Day = (H - L) < Ref(LLV(H-L,3),-1); // not used in this version
// 6/100 Historical Volatility
HVSixOneHundred = (StDev(log(C/Ref(C,-1)),6)*100*sqrt(256)) / (StDev(log(C/Ref(C,-1)),100)*100*sqrt(256));
HVRatioCond = HVSixOneHundred < 0.5;
// Check if 2 Inside days occur
InsideDay1 = H < Ref(High,-1) AND Low > Ref(Low,-1);
InsideDay2 = Ref(High,-1)< Ref(High,-2) AND Ref(Low,-1)> Ref(Low,-2);
InsideDayCond = InsideDay1 == 1 AND InsideDay2 == 1;
// Long side - buy and sell conditions
// Buy Condition
BuySig = InsideDayCond AND HVRatioCond AND VolumeCond AND C > EMABuyCond ;
// Sell Condition
// SellSig = condition.......
Buy = BuySig;
//Buy = ExRem(BuySig, SellSig);
//Sell = ExRem(SellSig, BuySig);
// Short side - short and cover conditions
// Short Condition
ShortSig = InsideDayCond AND HVRatioCond AND VolumeCond AND Low < EMAShortCond;
// Cover Condition
// CoverSig = condition .......
Short = ShortSig;
//Short = ExRem(ShortSig, CoverSig);
//Cover = ExRem(CoverSig, ShortSig);
// Define Stoploss Conditions
ApplyStop(stopTypeLoss, stopModePercent, amount = 10 );
// Lists exploration results conforming to our buy/sell OR short/cover criteria
//Filter = Buy OR Sell OR Short OR Cover;
Filter = Buy OR Short;
AddColumn(Buy, "Buy", 1, colorDefault,IIf(Buy,colorGreen,colorDefault));
//AddColumn(Sell, "Sell", 1, colorDefault,IIf(Sell,colorRed,colorDefault));
AddColumn(Short, "Short", 1, colorDefault,IIf(Short,colorGreen,colorDefault));
//AddColumn(Cover, "Cover", 1, colorDefault,IIf(Cover,colorRed,colorDefault));
AddColumn(Open, "Open", 4.3);
AddColumn(Low, "Low", 4.3); //
AddColumn(High, "High", 4.3); //
AddColumn(Close, "Close", 4.3); //
well done guys, I was losing hope on this thread for a while
.. as Kenny would say, "good on you" ... to those pushing this thread forward.
I still can't backtest this though...something to do with the buy/sell signals?
This is doing my head in!!!!
I can't get it to buy on the next bar after the insidedaycond.
It keeps buying on inside bar 1.....
There is no sell condition.
Add:
Sell = 0;
Edit: Even though Applystop is in the code, you still have to have a Sell. Adding Sell = 0; just makes the backtester happy, it doesn't do anything!
Hello and welcome to Aussie Stock Forums!
To gain full access you must register. Registration is free and takes only a few seconds to complete.
Already a member? Log in here.