Hello, I am relatively new to amibroker. I have just recently make an attempt to code both trading system and testing platform. I would greatly appreciate any help from experience coder who has already familiar with amibroker and obviously I would welcome any positive and supportive comments and effort .
Kind Regards,
Tom
//A reversal trading system concept based modified 2 days Connor's RSI coupled with pattern candle limit entry and exits
//The codes belong to @link https://forum.amibroker.com
//EOD System but can be tailored to any timeframe. Please do your own research and adjust it to your comfort risk level
//An example system only and I dont hold responsible for anything
//First attempt code by Thomas Ng
_SECTION_BEGIN("Xtreme");
//Trading System Settings
leverage = 2;
SetTradeDelays( 1, 1, 1, 1 );
SetOption( "InitialEquity", 10000);
SetOption("MinShares",1);
SetOption("CommissionMode",2);
SetOption("CommissionAmount",50);
SetOption("AccountMargin",100/leverage);
SetOption("FuturesMode", False);
SetOption("UseCurBarEquityForPosSizing", True);
SetOption( "AllowPositionShrinking", True);
SetOption("UseCustomBacktestProc", True );
SetOption( HoldMinDays, 4 )
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, 300 ))));
LEPrice=Min(CLOSE,LE Condition);
LXPrice=Close;
SEPrice=Max(CLOSE,SE Condition);
SXPrice=Close;
// Indicator Functions
OBOS=RSI(C,2);
// Buy AND Sell Rules
LE Rules= Sum(C<Ref(C,-1),4)==4 AND OBOS<5
LE Signal= Ref(LE Rules,-1);
LE Limit Price= Value When(LE Signal,L)-1.5*ATR(14);
LE Condition= Hold(LE,3) AND L<LE Limit Price;
LX Signal= Ref(H,-3);
ApplyStop( stopTypeNBar, stopModeBars, 3);
SE Rules= Sum(C>Ref(C,-1),4)==4 AND OBOS>90
SE Signal = Ref(SE Rules,-1);
SE Limit Price= Value When(SE Signal,H)+0.35*ATR(5);
SE Condition= Hold(SE,3) AND H>SE Limit Price;
SX Signal= Ref(L,-2);
ApplyStop( stopTypeNBar, stopModeBars, 2);
LE = ExRem( LE Price, LX);
LX = ExRem( LX, LE Price);
SE = ExRem( SE Price, SX);
SX = ExRem( SX, SE Price);
//Define stoploss and targets
Initial stop LX Price= LEPrice-3.2*ATR(10);
ApplyStop( stopTypeTrailing, stopModePoint, amount, 1);
Initial stop SX Price= SEPrice+3.2*ATR(10);
ApplyStop( stopTypeTrailing, stopModePercent, amount, 1);
//Debug
printf("\nLE Rules: " + LE Rules);
printf("\nSE Rules: " + SE Rules);
printf("\nSX Rules: " + SX Rules);
printf("\nLX Rules: " + LX Rules);
printf("\nLEPrice : " + LEPrice );
printf("\nSEPrice : " + SEPrice );
printf("\nLXPrice : " + LXPrice );
printf("\nSXPrice : " + SXPrice );
printf("\nLE Condition : "+ LE Condition);
printf("\nSE Condition : "+ SE Condition);
printf("\nInitial stop LE Price : "+Initial stop LE Price);
printf("\nInitial stop SE Price : "+Initial stop SE Price);
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
/* Plot Buy and Sell Signal Arrows */
PlotShapes(IIf(LE, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(LE, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(LE, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(SX, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(SX, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(SX, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(LX, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(LX, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(LX, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
PlotShapes(IIf(SE, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(SE, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(SE, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
_SECTION_END(); type or paste code here
Testing platform
//A reversal trading system concept based modified 2 days Connor's RSI coupled with pattern candle limit entry and exits
//The codes belong to @link https://forum.amibroker.com
//EOD System but can be tailored to any timeframe. Please do your own research and adjust it to your comfort risk level
//An example system only and I dont hold responsible for anything
//First attempt code by Thomas Ng
_SECTION_BEGIN("Xtreme");
//Trading System Settings
leverage = 2;
SetTradeDelays( 1, 1, 1, 1 );
SetOption( "InitialEquity", 10000);
SetOption("MinShares",1);
SetOption("CommissionMode",2);
SetOption("CommissionAmount",50);
SetOption("AccountMargin",100/leverage);
SetOption("FuturesMode", False);
SetOption("UseCurBarEquityForPosSizing", True);
SetOption( "AllowPositionShrinking", True);
SetOption("UseCustomBacktestProc", True );
SetOption( HoldMinDays, 4 )
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, 300 ))));
LEPrice=Min(CLOSE,LE Condition);
LXPrice=Close;
SEPrice=Max(CLOSE,SE Condition);
SXPrice=Close;
// Indicator Functions
OBOS=RSI(C,2);
// Buy AND Sell Rules
LE Rules= Sum(C<Ref(C,-1),4)==4 AND OBOS<5
LE Signal= Ref(LE Rules,-1);
LE Limit Price= Value When(LE Signal,L)-1.5*ATR(14);
LE Condition= Hold(LE,3) AND L<LE Limit Price;
LX Signal= Ref(H,-3);
ApplyStop( stopTypeNBar, stopModeBars, 3);
SE Rules= Sum(C>Ref(C,-1),4)==4 AND OBOS>90
SE Signal = Ref(SE Rules,-1);
SE Limit Price= Value When(SE Signal,H)+0.35*ATR(5);
SE Condition= Hold(SE,3) AND H>SE Limit Price;
SX Signal= Ref(L,-2);
ApplyStop( stopTypeNBar, stopModeBars, 2);
LE = ExRem( LE Price, LX);
LX = ExRem( LX, LE Price);
SE = ExRem( SE Price, SX);
SX = ExRem( SX, SE Price);
//Define stoploss and targets
Initial stop LX Price= LEPrice-3.2*ATR(10);
ApplyStop( stopTypeTrailing, stopModePoint, amount, 1);
Initial stop SX Price= SEPrice+3.2*ATR(10);
ApplyStop( stopTypeTrailing, stopModePercent, amount, 1);
// Position Sizing
RiskPerShare = 3.2 * ATR( 10 );
ApplyStop( stopTypeLoss, stopModePoint, RiskPerShare, True );
// risk 3% of entire equity on single trade
PositionRisk = 3;
// position size calculation
PctSize = PositionRisk * BuyPrice / RiskPerShare;
SetPositionSize( PctSize, spsPercentOfEquity )
//Debug
printf("\nLE Rules: " + LE Rules);
printf("\nSE Rules: " + SE Rules);
printf("\nSX Rules: " + SX Rules);
printf("\nLX Rules: " + LX Rules);
printf("\nLEPrice : " + LEPrice );
printf("\nSEPrice : " + SEPrice );
printf("\nLXPrice : " + LXPrice );
printf("\nSXPrice : " + SXPrice );
printf("\nLE Condition : "+ LE Condition);
printf("\nSE Condition : "+ SE Condition);
printf("\nInitial stop LE Price : "+Initial stop LE Price);
printf("\nInitial stop SE Price : "+Initial stop SE Price);
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
/* Plot Buy and Sell Signal Arrows */
PlotShapes(IIf(LE, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(LE, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(LE, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(SX, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(SX, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(SX, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(LX, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(LX, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(LX, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
PlotShapes(IIf(SE, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(SE, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(SE, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
_SECTION_END();