Created
February 7, 2017 17:43
-
-
Save junajan/b26667e02a8aaf9ef997dae908173c55 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//------------------------------------------------------ | |
// | |
// Formula Name: Donchian Channel trading System | |
// Author/Uploader: Trading Tuitions | |
// E-mail: support@tradingtuitions.com | |
// Website: www.tradingtuitions.com | |
//------------------------------------------------------ | |
_SECTION_BEGIN("Donchian Channel trading System"); | |
SetChartOptions(0,chartShowArrows|chartShowDates); | |
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C )); | |
//Initial Parameters | |
SetTradeDelays( 0,0,0, 0 ); | |
SetOption( "InitialEquity", 200000); | |
SetOption("FuturesMode" ,True); | |
SetOption("MinShares",1); | |
SetOption("CommissionMode",2); | |
SetOption("CommissionAmount",100); | |
SetOption("AccountMargin",10); | |
SetOption("RefreshWhenCompleted",True); | |
SetPositionSize(150,spsShares); | |
SetOption( "AllowPositionShrinking", True ); | |
Plot( Close, "Price", colorWhite, styleCandle ); | |
pds=Param("DonchianPeriods",5,5,100,5); | |
DonchianUpper =HHV(Ref(H,-1),pds); | |
DonchianLower = LLV(Ref(L,-1),pds); | |
DonchianMiddle = (DonchianUpper+DonchianLower)/2; | |
printf("\nDonchianUpper : " + DonchianUpper ); | |
printf("\nDonchianLower : " + DonchianLower ); | |
printf("\nDonchianMiddle : " + DonchianMiddle ); | |
Plot(DonchianUpper,"DU",colorBlue,styleLine); | |
Plot(DonchianMiddle,"DM",colorGreen,styleLine); | |
Plot(DonchianLower,"DL",colorRed,styleLine); | |
ATRMultiplier=Param("ATRMultiplier",5,1,5,1); | |
ATRPeriods=Param("ATRPeriods",25,5,25,1); | |
Buy=Cross(High,DonchianUpper); | |
Short=Cross(DonchianLower,Low); | |
Sell=Cross(DonchianMiddle,Low); | |
Cover=Cross(High,DonchianMiddle); | |
BuyPrice=DonchianUpper; | |
SellPrice=DonchianMiddle; | |
ShortPrice=DonchianLower; | |
CoverPrice=DonchianMiddle; | |
Buy = ExRem(Buy,Sell); | |
Sell = ExRem(Sell,Buy); | |
Short=ExRem(Short,Cover); | |
Cover=ExRem(Cover,Short); | |
ApplyStop(stopTypeTrailing, stopModePoint, ATRMultiplier*ATR(ATRPeriods), True, True ); | |
printf("\nBuy : " + Buy ); | |
printf("\nSell : " + Sell ); | |
printf("\nShort : " + Short ); | |
printf("\nCover : " + Cover ); | |
/* Plot Buy and Sell Signal Arrows */ | |
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-25); | |
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-35); | |
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-30); | |
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=25); | |
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=35); | |
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-30); | |
PlotShapes(IIf(Sell, shapeStar, shapeNone),colorGold, 0, L, Offset=-15); | |
PlotShapes(IIf(Cover, shapeStar, shapeNone),colorGold, 0,L, Offset=-15); | |
_SECTION_END(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment