Hi,
Please correct below afl, too. It is for Intraday Trading and I tried but no success.
*****************************************************
SetBarsRequired
(200, 0);
_SECTION_BEGIN
("TA signal ");
GraphXSpace
=
5;
SetChartOptions
(0, chartShowArrows|chartShowDates);
k =
Optimize("K", Param("A (Change To Optimise)", 1.75, 0.25, 5, 0.25), 0.25, 5, 0.25);
Per=
Optimize("ATR", Param("B (Change To Optimise)", 10, 3, 20, 1), 3, 20, 1);
CloseAtEnd =
ParamToggle("Close Positions EOD", "No|Yes");
ShowBands =
ParamToggle("Show Trending Bands", "No|Yes");
ShowPivots =
ParamToggle("Show Pivot High/Low", "No|Yes");
SetChartBkGradientFill
( ParamColor("BgTop", colorDarkOliveGreen), ParamColor("BgBottom", colorRose), ParamColor("titleblock", colorRose ));
//Param_Margin = Param("Margin required (used for backtesting only)", 15, 0.001, 100, 0.001);
//Param_LotSize = Param("Lot Size (used for backtesting only)", 50, 5, 5000, 5);
//Param_NoOfLots = Param("No of lots normally traded (used for backtesting only)", 2, 1, 10000, 1);
R=(H-L);
//RANGE;
FR=(H-L)/
3;//THIRD OF RANGE;
S1=H-FR;
//SEGMENT ONE;
S2=H-
2*FR;//SEGMENT TWO;
S3=L;
//SEGMENT THREE;
/*POSITION OF OPEN AND CLOSE RELATIVE TO BAR*/
P=
IIf(O>S1, 1, IIf(S1>O<S2, 2, IIf(S2>O<L, 3, 0)));// POSITION OF OPENING PRICE ;
CL=
IIf(C>S1, 1, IIf(S1>C<S2, 2, IIf(S2>C<L, 3, 0)));// POSITION OF CLOSING PRICE;
/*CONDITIONAL STATEMENTS */
�@
COND_C=((P==
2 OR P==3) AND CL==1) OR (P==3 AND (CL==1 OR CL==2)); //CLIMBERS(eq. 1)
COND_C=(P==
2/*OR P==3)*/ AND CL==1) OR (P==3 AND (CL==1 OR CL==2));//CLIMBERS (eq. 1a)
�@
COND_D=(P==
1 AND (CL==2 OR CL==3)) OR (P==2 AND (CL==2 OR CL==3));//DRIFTERS
COND_N=((P==CL) AND ( P==
1 OR P==2 OR P==3)); //NEUTRAL BARS
DYNAMIC_COLOR=
IIf(COND_C, colorDarkGreen, IIf(COND_D, colorRed, IIf(COND_N, colorBlue, colorTeal)));
PlotOHLC
( Open, High, Low, Close, "Price chart ", DYNAMIC_COLOR, styleCandle, styleThick);
HACLOSE=(O+H+L+C)/
4;
HaOpen =
AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh =
Max( H, Max( HaClose, HaOpen ) );
HaLow =
Min( L, Min( HaClose, HaOpen ) );
j=Haclose;
//================================================== ================================================== ===================
//=========================Indicator================ ================================================== ============================
f=
ATR(14);
rfsctor =
WMA(H-L, Per);
revers = k * rfsctor;
Trend =
1;
NW[
0] = 0;
�@
for
(i = 1; i < BarCount; i++)
{
if
(Trend[i-1] == 1)
{
if
(j < NW[i-1])
{
Trend = -
1;
NW = j + Revers;
}
else
{
Trend =
1;
if
((j - Revers) > NW[i-1])
{
NW = j - Revers;
}
else
{
NW = NW[i-
1];
}
}
}
if
(Trend[i-1] == -1)
{
if
(j > NW[i-1])
{
Trend =
1;
NW = j - Revers;
}
else
{
Trend = -
1;
if
((j + Revers) < NW[i-1])
{
NW = j + Revers;
}
else
{
NW = NW[i-
1];
}
}
}
}
activezone=
ADX(14) >20 AND V> MA(V, 60);
calmzone=
ADX(14) < 20 AND V < MA(V, 60);
�@
Plot
( 2,
/* defines the height of the ribbon in percent of pane width
*/
"ribbon",
IIf
( activezone, colorBlue, IIf( calmzone, colorYellow, 0 )),
/* choose color */
styleOwnScale
|styleArea|styleNoLabel, -0.5, 100 );
//===============system================
ForceCloseTradesAfter =
153000;
NextBarOutsideRTH = (
Ref(TimeNum(), 1) > ForceCloseTradesAfter);
NextBarNotToday = (
Ref(DateNum(), 1) > DateNum());
Buy
=
Cross(j, nw);
Short
=
Cross(nw, j);
Sell
=
IIf(CloseAtEnd==False, Short, Short OR NextBarOutsideRTH OR NextBarNotToday);
Cover
=
IIf(CloseAtEnd==False, Buy, Buy OR NextBarOutsideRTH OR NextBarNotToday);
SellPrice
=
ValueWhen(Short, C, 1);
BuyPrice
=
ValueWhen(Buy, C, 1);
Long=
Flip(Buy, Sell);
Shrt=
Flip(Short, Cover);
OBSetting=
Param("Setting", 45, 1, 500, 1);
Bline =
StochD(OBSetting);
Oversold=Bline<=
5;
Overbought=Bline>=
95;
�@
PlotShapes
(IIf(Oversold, shapeSmallCircle, shapeNone), colorBrightGreen, layer = 0, yposition = HaLow, offset = -8 );
PlotShapes
(IIf(Overbought, shapeSmallCircle, shapeNone), colorOrange, layer = 0, yposition = HaHigh, offset = 7 );
//=================TITLE============================ ================================================== ==================
if
( Status("action") == actionIndicator)
(
Title
=
EncodeColor(colorBlue)+ "StockManiacs Intraday Trading System V2.0 - www.stockmaniacs.net" + " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorBlue) +
" - "
+ Date() +" - "+"n" +EncodeColor(colorLightBlue) +"Open-"+O+" "+"High-"+H+" "+"Low-"+L+" "+
"Close-"
+C+" "+ "Volume= "+ WriteVal(V)+"n"+
EncodeColor
(colorBlue)+
WriteIf
(Buy, " GO LONG ABOVE "+H+" AND IF TRIGGERS ADD MORE LONG NEAR "+C+" - KEEP SL BELOW"+NW+" ", "")+
WriteIf
(Short, " GO SHORT BELOW "+L+" AND IF TRIGGERS ADD MORE SHORT NEAR "+C+" - KEEP SL ABOVE"+NW+" ", "")+"n"+EncodeColor(colorDarkGreen)+
WriteIf
(Short AND CloseAtEnd==False, "Total Profit/Loss For The Last Trade: Points - "+(C-BuyPrice)+"", "")+
WriteIf
(Buy AND CloseAtEnd==False, "Total Profit/Loss For The Last Trade: Points - "+(SellPrice-C)+"", "")+
WriteIf
(Long AND NOT Buy, "Current Trade : Long - Entry Price Near "+(BuyPrice), "")+
WriteIf
(shrt AND NOT Sell, "Current Trade : Short - Entry Price Near "+(SellPrice), "")+"n"+
WriteIf
(Long AND NOT Buy, "Current Profit/Loss "+(C-BuyPrice)+" Points - Current Trailing Stop Loss @ " + NW + "", "")+
WriteIf
(shrt AND NOT Sell, "Current Profit/Loss "+(SellPrice-C)+" Points - Current Trailing Stop Loss @ " + NW + "", ""))+
WriteIf
(NOT Long AND NOT Buy AND NOT shrt AND NOT Sell, "Currently Not In A Trade ", "");
PlotShapes
(IIf(Buy, shapeUpArrow, shapeNone), colorGreen, 0, Low, -15);
PlotShapes
(IIf(Short, shapeHollowDownArrow, shapeNone), colorPink, 0, High, -15);
PlotShapes
(IIf(Buy, shapeHollowUpArrow, shapeNone), colorLime, 0, Low, -25);
PlotShapes
(IIf(Short, shapeDownArrow, shapeNone), colorDarkRed, 0, High, -25);
PlotShapes
(IIf(CloseAtEnd==True AND (NextBarOutsideRTH OR NextBarNotToday), shapeStar, shapeNone), colorGold, 0, L, Offset=-10);
//Settings for Backtester
SetOption
("AllowSameBarExit", False);
SetOption
("AllowPositionShrinking", False);
SetOption
("FuturesMode", True);
SetOption
("InterestRate", 0);
SetOption
("MaxOpenPositions", 1);
//RoundLotSize = Param_LotSize;
SetOption
("MinShares", RoundLotSize);
SetOption
("PriceBoundChecking", False);
//SetOption("CommissionMode", 3);
//SetOption("CommissionAmount", 12.5/RoundLotSize);
//SetOption("AccountMargin", Param_Margin);
SetOption
("ReverseSignalForcesExit", True);
SetOption
("UsePrevBarEquityForPosSizing", True);
SetOption
("GenerateReport", 1);
SetOption
("MaxOpenLong", 1);
SetOption
("MaxOpenShort", 1);
SetOption
("RefreshWhenCompleted", True);
//PositionSize = C*RoundLotSize*Param_NoOfLots;
SetTradeDelays
(0, 0, 0, 0);
BuyPrice
= Close;
SellPrice
= Close;
ShortPrice
= Close;
CoverPrice
= Close;
//End of Settings for Backtester
Please correct below afl, too. It is for Intraday Trading and I tried but no success.
*****************************************************
SetBarsRequired
(200, 0);
_SECTION_BEGIN
("TA signal ");
GraphXSpace
=
5;
SetChartOptions
(0, chartShowArrows|chartShowDates);
k =
Optimize("K", Param("A (Change To Optimise)", 1.75, 0.25, 5, 0.25), 0.25, 5, 0.25);
Per=
Optimize("ATR", Param("B (Change To Optimise)", 10, 3, 20, 1), 3, 20, 1);
CloseAtEnd =
ParamToggle("Close Positions EOD", "No|Yes");
ShowBands =
ParamToggle("Show Trending Bands", "No|Yes");
ShowPivots =
ParamToggle("Show Pivot High/Low", "No|Yes");
SetChartBkGradientFill
( ParamColor("BgTop", colorDarkOliveGreen), ParamColor("BgBottom", colorRose), ParamColor("titleblock", colorRose ));
//Param_Margin = Param("Margin required (used for backtesting only)", 15, 0.001, 100, 0.001);
//Param_LotSize = Param("Lot Size (used for backtesting only)", 50, 5, 5000, 5);
//Param_NoOfLots = Param("No of lots normally traded (used for backtesting only)", 2, 1, 10000, 1);
R=(H-L);
//RANGE;
FR=(H-L)/
3;//THIRD OF RANGE;
S1=H-FR;
//SEGMENT ONE;
S2=H-
2*FR;//SEGMENT TWO;
S3=L;
//SEGMENT THREE;
/*POSITION OF OPEN AND CLOSE RELATIVE TO BAR*/
P=
IIf(O>S1, 1, IIf(S1>O<S2, 2, IIf(S2>O<L, 3, 0)));// POSITION OF OPENING PRICE ;
CL=
IIf(C>S1, 1, IIf(S1>C<S2, 2, IIf(S2>C<L, 3, 0)));// POSITION OF CLOSING PRICE;
/*CONDITIONAL STATEMENTS */
�@
COND_C=((P==
2 OR P==3) AND CL==1) OR (P==3 AND (CL==1 OR CL==2)); //CLIMBERS(eq. 1)
COND_C=(P==
2/*OR P==3)*/ AND CL==1) OR (P==3 AND (CL==1 OR CL==2));//CLIMBERS (eq. 1a)
�@
COND_D=(P==
1 AND (CL==2 OR CL==3)) OR (P==2 AND (CL==2 OR CL==3));//DRIFTERS
COND_N=((P==CL) AND ( P==
1 OR P==2 OR P==3)); //NEUTRAL BARS
DYNAMIC_COLOR=
IIf(COND_C, colorDarkGreen, IIf(COND_D, colorRed, IIf(COND_N, colorBlue, colorTeal)));
PlotOHLC
( Open, High, Low, Close, "Price chart ", DYNAMIC_COLOR, styleCandle, styleThick);
HACLOSE=(O+H+L+C)/
4;
HaOpen =
AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh =
Max( H, Max( HaClose, HaOpen ) );
HaLow =
Min( L, Min( HaClose, HaOpen ) );
j=Haclose;
//================================================== ================================================== ===================
//=========================Indicator================ ================================================== ============================
f=
ATR(14);
rfsctor =
WMA(H-L, Per);
revers = k * rfsctor;
Trend =
1;
NW[
0] = 0;
�@
for
(i = 1; i < BarCount; i++)
{
if
(Trend[i-1] == 1)
{
if
(j < NW[i-1])
{
Trend = -
1;
NW = j + Revers;
}
else
{
Trend =
1;
if
((j - Revers) > NW[i-1])
{
NW = j - Revers;
}
else
{
NW = NW[i-
1];
}
}
}
if
(Trend[i-1] == -1)
{
if
(j > NW[i-1])
{
Trend =
1;
NW = j - Revers;
}
else
{
Trend = -
1;
if
((j + Revers) < NW[i-1])
{
NW = j + Revers;
}
else
{
NW = NW[i-
1];
}
}
}
}
activezone=
ADX(14) >20 AND V> MA(V, 60);
calmzone=
ADX(14) < 20 AND V < MA(V, 60);
�@
Plot
( 2,
/* defines the height of the ribbon in percent of pane width
*/
"ribbon",
IIf
( activezone, colorBlue, IIf( calmzone, colorYellow, 0 )),
/* choose color */
styleOwnScale
|styleArea|styleNoLabel, -0.5, 100 );
//===============system================
ForceCloseTradesAfter =
153000;
NextBarOutsideRTH = (
Ref(TimeNum(), 1) > ForceCloseTradesAfter);
NextBarNotToday = (
Ref(DateNum(), 1) > DateNum());
Buy
=
Cross(j, nw);
Short
=
Cross(nw, j);
Sell
=
IIf(CloseAtEnd==False, Short, Short OR NextBarOutsideRTH OR NextBarNotToday);
Cover
=
IIf(CloseAtEnd==False, Buy, Buy OR NextBarOutsideRTH OR NextBarNotToday);
SellPrice
=
ValueWhen(Short, C, 1);
BuyPrice
=
ValueWhen(Buy, C, 1);
Long=
Flip(Buy, Sell);
Shrt=
Flip(Short, Cover);
OBSetting=
Param("Setting", 45, 1, 500, 1);
Bline =
StochD(OBSetting);
Oversold=Bline<=
5;
Overbought=Bline>=
95;
�@
PlotShapes
(IIf(Oversold, shapeSmallCircle, shapeNone), colorBrightGreen, layer = 0, yposition = HaLow, offset = -8 );
PlotShapes
(IIf(Overbought, shapeSmallCircle, shapeNone), colorOrange, layer = 0, yposition = HaHigh, offset = 7 );
//=================TITLE============================ ================================================== ==================
if
( Status("action") == actionIndicator)
(
Title
=
EncodeColor(colorBlue)+ "StockManiacs Intraday Trading System V2.0 - www.stockmaniacs.net" + " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorBlue) +
" - "
+ Date() +" - "+"n" +EncodeColor(colorLightBlue) +"Open-"+O+" "+"High-"+H+" "+"Low-"+L+" "+
"Close-"
+C+" "+ "Volume= "+ WriteVal(V)+"n"+
EncodeColor
(colorBlue)+
WriteIf
(Buy, " GO LONG ABOVE "+H+" AND IF TRIGGERS ADD MORE LONG NEAR "+C+" - KEEP SL BELOW"+NW+" ", "")+
WriteIf
(Short, " GO SHORT BELOW "+L+" AND IF TRIGGERS ADD MORE SHORT NEAR "+C+" - KEEP SL ABOVE"+NW+" ", "")+"n"+EncodeColor(colorDarkGreen)+
WriteIf
(Short AND CloseAtEnd==False, "Total Profit/Loss For The Last Trade: Points - "+(C-BuyPrice)+"", "")+
WriteIf
(Buy AND CloseAtEnd==False, "Total Profit/Loss For The Last Trade: Points - "+(SellPrice-C)+"", "")+
WriteIf
(Long AND NOT Buy, "Current Trade : Long - Entry Price Near "+(BuyPrice), "")+
WriteIf
(shrt AND NOT Sell, "Current Trade : Short - Entry Price Near "+(SellPrice), "")+"n"+
WriteIf
(Long AND NOT Buy, "Current Profit/Loss "+(C-BuyPrice)+" Points - Current Trailing Stop Loss @ " + NW + "", "")+
WriteIf
(shrt AND NOT Sell, "Current Profit/Loss "+(SellPrice-C)+" Points - Current Trailing Stop Loss @ " + NW + "", ""))+
WriteIf
(NOT Long AND NOT Buy AND NOT shrt AND NOT Sell, "Currently Not In A Trade ", "");
PlotShapes
(IIf(Buy, shapeUpArrow, shapeNone), colorGreen, 0, Low, -15);
PlotShapes
(IIf(Short, shapeHollowDownArrow, shapeNone), colorPink, 0, High, -15);
PlotShapes
(IIf(Buy, shapeHollowUpArrow, shapeNone), colorLime, 0, Low, -25);
PlotShapes
(IIf(Short, shapeDownArrow, shapeNone), colorDarkRed, 0, High, -25);
PlotShapes
(IIf(CloseAtEnd==True AND (NextBarOutsideRTH OR NextBarNotToday), shapeStar, shapeNone), colorGold, 0, L, Offset=-10);
//Settings for Backtester
SetOption
("AllowSameBarExit", False);
SetOption
("AllowPositionShrinking", False);
SetOption
("FuturesMode", True);
SetOption
("InterestRate", 0);
SetOption
("MaxOpenPositions", 1);
//RoundLotSize = Param_LotSize;
SetOption
("MinShares", RoundLotSize);
SetOption
("PriceBoundChecking", False);
//SetOption("CommissionMode", 3);
//SetOption("CommissionAmount", 12.5/RoundLotSize);
//SetOption("AccountMargin", Param_Margin);
SetOption
("ReverseSignalForcesExit", True);
SetOption
("UsePrevBarEquityForPosSizing", True);
SetOption
("GenerateReport", 1);
SetOption
("MaxOpenLong", 1);
SetOption
("MaxOpenShort", 1);
SetOption
("RefreshWhenCompleted", True);
//PositionSize = C*RoundLotSize*Param_NoOfLots;
SetTradeDelays
(0, 0, 0, 0);
BuyPrice
= Close;
SellPrice
= Close;
ShortPrice
= Close;
CoverPrice
= Close;
//End of Settings for Backtester