TRADERS’ TIPS

October 2017

Tips Article Thumbnail

For this month’s Traders’ Tips, the focus is Jerry D’Ambrosio and Barbara Star’s article in this issue, “A Candlestick Strategy With Soldiers And Crows.” Here, we present the October 2017 Traders’ Tips code with possible implementations in various software.

The Traders’ Tips section is provided to help the reader implement a selected technique from an article in this issue or another recent issue. The entries here are contributed by software developers or programmers for software that is capable of customization.


logo

TRADESTATION: OCTOBER 2017

In their article “A Candlestick Strategy With Soldiers And Crows” in this issue, authors Jerry D’Ambrosio and Barbara Star introduce a novel modification to the classic candle patterns: three white soldiers and three black crows. The modified patterns require fewer candles and as a result occur more frequently. The authors describe these as useful for highlighting reversals.

Sample Chart

FIGURE 1: TRADESTATION. This shows TradeStation Scanner results screen and chart of CLGX with the PaintBar study applied.

Below we have provided the EasyLanguage code for an indicator intended to be used in the TradeStation Scanner. The indicator can be used to find instances of the pattern in history and show the resulting price change as well as the number of bars since the pattern occurred. We have also provided a PaintBar study to assist in highlighting the pattern in your charts. Finally, we have included functions to help identify the patterns that can be used in your own Easy­Language code.

Function: __C_Crow
// _C_Crow Function
// TASC OCT 2017
// A Candlestick Strategy
// With Soldiers and Crows
// D'Ambrosio and Star

_C_Crow = Close[1] > Close[2] and
		Close[1] > Open[1] and 
		Open < Close[1] and
		Close < Open[1] and 
		Open > Open[1] and
		Close[1] > Close[2] and 
		Close[2] > Close[3] ;


Function: _C_Soldier
// _C_Soldier Function
// TASC OCT 2017
// A Candlestick Strategy
// With Soldiers and Crows
// D'Ambrosio and Star

_C_Soldier = Close[1] < Close[2] and
			Close[1] < Open[1] and 
			Open > Close[1] and
			Close > Open[1] and 
			Open < Open[1] and
			Close[1] < Close[2] and 
			Close[2] < Close[3] ;


Indicator: SoldierAndCrowScan
// Soldier and Crow Scan Indicator
// TASC OCT 2017
// A Candlestick Strategy
// With Soldiers and Crows
// D'Ambrosio and Star

inputs:
	ScanForSoldier( true ),
	ScanForCrow( true ),
	MinSoldierPrice( 1 ),
	MinCrowPrice( 10 ),
	MinAvgVolume( 100000 ),
	VolAvgLength( 50 ) ;
	
variables:
	SoldierFound( false ),
	CrowFound( false ),
	SetupFound( false ),
	AvgVolume( 0 ),
	SetupFoundPrice( 0 ),
	SetupFoundBar( 0 ),
	LastPattern( " " ) ;

constants:
	Soldier( "Soldier" ),
	Crow( "Crow" ) ;

AvgVolume = Average( Volume, VolAvgLength ) ;

SoldierFound = 	_C_Soldier ;
CrowFound = _C_Crow ;

if SoldierFound and
 	ScanForSoldier and
	AvgVolume >= MinAvgVolume and
	Close >= MinSoldierPrice then
		begin
		SetupFoundPrice = Close ;
		SetupFoundBar = CurrentBar ;
		LastPattern = Soldier ;
		end 
else if CrowFound and
	ScanForCrow and
	AvgVolume >= MinAvgVolume and
	Close >= MinCrowPrice then		
		begin
		SetupFoundPrice = Close ;
		SetupFoundBar = CurrentBar ;
		LastPattern = Crow ;
		end ;		
	
if LastBarOnChartEx  then
	if LastPattern = Crow then
		begin
		Plot1( 100 *( SetupFoundPrice - Close ) 
			/ SetupFoundPrice, "Pct Chg" ) ;
		Plot2( CurrentBar - SetupFoundBar, 
			"NumBars" ) ;
		Plot3( LastPattern, "Pattern" ) ;
		
		end
	else if LastPattern = Soldier then
		begin
		Plot1(100 * ( Close - SetupFoundPrice ) 
			/ SetupFoundPrice, "Pct Chg" ) ;
		Plot2( CurrentBar - SetupFoundBar, 
			"NumBars" ) ;
		Plot3( LastPattern, "Pattern" ) ;
		end ;	

	

PaintBar: SoldierAndCrowPB
// Soldier and Crow Paintbar
// TASC OCT 2017
// A Candlestick Strategy
// With Soldiers and Crows
// D'Ambrosio and Star
inputs:
	SoldierColor( Cyan ),
	CrowColor( Magenta ) ;

variables:
	SoldierFound( false ),
	CrowFound( false ),
	PlotColor( Cyan ) ;

SoldierFound = 	_C_Soldier ;
CrowFound = _C_Crow ;

if SoldierFound then
	PlotPaintBar( High, Low, Open, Close, 
		"Pattern", SoldierColor )
else if CrowFound then
	PlotPaintBar( High, Low, Open, Close, 
		"Pattern", CrowColor )
else
	begin
	NoPlot( 1 ) ;
	NoPlot( 2 ) ;
	NoPlot( 3 ) ;
	NoPlot( 4 ) ;
	end ;	

To download the EasyLanguage code please visit our TradeStation and EasyLanguage Support Forum. The files for this article can be found here: https://community.tradestation.com/Discussions/Topic.aspx?Topic_ID=142776. The filename is “TASC_OCT2017.ZIP.”

For more information about EasyLanguage in general please see: https://www.tradestation.com/EL-FAQ.

This article is for informational purposes. No type of trading or investment recommendation, advice or strategy is being made, given or in any manner provided by Trade­Station Securities or its affiliates.

—Doug McCrary
TradeStation Securities, Inc.
www.TradeStation.com

BACK TO LIST

logo

METASTOCK: OCTOBER 2017

Jerry D’Ambrosio and Barbara Star’s article in this issue, “A Candlestick Strategy With Soldiers And Crows,” presents criteria for two different reversal pattern scans. The formulas are listed below. They are designed to be put in the filter of explorations.

One Black Crow:

minPrice:= 10;    {minimum price}
minVol:= 100000; {minimum volume}
trend:= Sum( C > Ref(C, -1), 3) = 3; 
Ref(C > O, -1) AND O < Ref(C, -1) AND
C < Ref(O, -1) AND O > Ref(O, -1) AND
Ref(trend, -1) AND C > minPrice AND
Mov(V, 50, S) > minVol

One White Soldier:

minPrice:= 1;    {minimum price}
minVol:= 100000; {minimum volume}
trend:= Sum( C < Ref(C, -1), 3) = 3; 
Ref(C < O, -1) AND O > Ref(C, -1) AND
C > Ref(O, -1) AND O < Ref(O, -1) AND
Ref(trend, -1) AND C > minPrice AND
Mov(V, 50, S) > minVol

—William Golson
MetaStock Technical Support
www.metastock.com

BACK TO LIST

logo

eSIGNAL: OCTOBER 2017

For this month’s Traders’ Tip, we’ve provided One_White_Soldier.efs and One_Black_Crow.efs studies based on the candlestick patterns described in Jerry D’Ambrosio and Barbara Star’s article in this issue, “A Candlestick Strategy With Soldiers And Crows.” The authors present a strategy based on buy/sell signals based on these patterns.

The study contains formula parameters which may be configured through the edit chart window (right-click on the chart and select “edit chart”). A sample chart is shown in Figure 2.

Sample Chart

FIGURE 2: eSIGNAL. Here is an example of the studies plotted on a daily chart of ALK.

To discuss this study or download a complete copy of the formula code, please visit the EFS Library Discussion Board forum under the forums link from the support menu at www.esignal.com or visit our EFS KnowledgeBase at https://www.esignal.com/support/kb/efs/. The eSignal formula scripts (EFS) are shown below.

One White Soldier

/*********************************
Provided By:  
eSignal (Copyright c eSignal), a division of Interactive Data 
Corporation. 2016. All rights reserved. This sample eSignal 
Formula Script (EFS) is for educational purposes only and may be 
modified and saved under a new file name.  eSignal is not responsible
for the functionality once modified.  eSignal reserves the right 
to modify and overwrite this EFS file with each new release.

Description:        
    A Candlestick Strategy With Soldiers and Crows by Jerry D'Ambrosio and Barbara Star, PhD

Version:            1.00  08/09/2017

Formula Parameters:                     Default:
Minimum Eq Price                        1
Minimum Avg Volume                      100000



Notes:
The related article is copyrighted material. If you are not a subscriber
of Stocks & Commodities, please visit www.traders.com.

**********************************/

var fpArray = new Array();

function preMain(){
    setPriceStudy(true);
    setDefaultBarFgColor(Color.black,0);
    
    var x = 0;
    fpArray[x] = new FunctionParameter("MinPrice", FunctionParameter.NUMBER);
	with(fpArray[x++]){
        setLowerLimit(0);
        setDefault(1);
        setName("Minimum Eq Price");
    }

    fpArray[x] = new FunctionParameter("MinVol", FunctionParameter.NUMBER);
	with(fpArray[x++]){
        setLowerLimit(0);
        setDefault(100000);
        setName("Minimum Avg Volume");
    }
}

var bInit = false;
var bVersion = null;

var xHigh = null;
var xClose = null;
var xOpen = null;
var xVolume = null;
var avgVol = null;

var bPotential = false;
var nCounter = 0;
var returnString = null;

function main(MinPrice, MinVol){
    if (bVersion == null) bVersion = verify();
    if (bVersion == false) return;
    
    if (getCurrentBarCount() < 50) return;
    
    if (!bInit){
        xHigh = high();
        xClose = close();
        xOpen = open();
        
        xVolume = volume();
        avgVol = sma(50, xVolume);

        bInit = true
    }

    if (getBarState() == BARSTATE_ALLBARS){
        bInit = false;
    }


    if (xHigh.getValue(0) < MinPrice || avgVol.getValue(0) < MinVol) return;
    
    if (getBarState() == BARSTATE_NEWBAR && nCounter > 1){
        returnString == " ";
        bPotential = false;
    }
    
    if (getBarState() == BARSTATE_NEWBAR && bPotential){
        nCounter++;
    }

    if (xClose.getValue(-1) < xOpen.getValue(-1) &&
        xClose.getValue(-1) < xClose.getValue(-2) &&
        xClose.getValue(-2) < xClose.getValue(-3) &&
        xClose.getValue(-3) < xClose.getValue(-4) &&
        xOpen.getValue(0)   > xClose.getValue(-1) &&
        xClose.getValue(0)  > xOpen.getValue(-1) &&
        xOpen.getValue(0)   < xOpen.getValue(-1)
        ){
            returnString = "Potential pattern found";
            drawTextRelative(0, BelowBar1, "\u00E9", Color.RGB(171,255,171), null, Text.PRESET|Text.CENTER, "Wingdings", 12, "OWS"+rawtime(0));
            bPotential = true;
            nCounter = 0;
            
        }
    else {
        removeText("OWS"+rawtime(0));
        if (nCounter == 0){ 
            bPotential = false;
        }
        returnString = " ";
    }
    
    if (bPotential && nCounter == 1){
        if (xHigh.getValue(0) > xClose.getValue(-1)) {
            drawTextRelative(-1, BelowBar1, "\u00E9", Color.green, null, Text.PRESET|Text.CENTER, "Wingdings", 10, "OWS"+rawtime(-1));
            returnString = "Confirmed pattern";
            bPotential = false;
        }
    }
    
    if (isWatchList()) {
        if (returnString == "Potential pattern found"){
            setBarBgColor(Color.RGB(171,255,171),0);
        }
        else if (returnString == "Confirmed pattern"){
            setBarBgColor(Color.green,0);
        }
        return returnString;
    }

}

function verify(){
    var b = false;
    if (getBuildNumber() < 779){
        
        drawTextAbsolute(5, 35, "This study requires version 10.6 or later.", 
            Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
            null, 13, "error");
        drawTextAbsolute(5, 20, "Click HERE to upgrade.@URL=https://www.esignal.com/download/default.asp", 
            Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
            null, 13, "upgrade");
        return b;
    } 
    else
        b = true;
    
    return b;
}

One Black Crow

/*********************************
Provided By:  
eSignal (Copyright c eSignal), a division of Interactive Data 
Corporation. 2016. All rights reserved. This sample eSignal 
Formula Script (EFS) is for educational purposes only and may be 
modified and saved under a new file name.  eSignal is not responsible
for the functionality once modified.  eSignal reserves the right 
to modify and overwrite this EFS file with each new release.

Description:        
    A Candlestick Strategy With Soldiers and Crows by Jerry D'Ambrosio and Barbara Star, PhD

Version:            1.00  08/09/2017

Formula Parameters:                     Default:
Minimum Eq Price                        10
Minimum Avg Volume                      100000



Notes:
The related article is copyrighted material. If you are not a subscriber
of Stocks & Commodities, please visit www.traders.com.

**********************************/

var fpArray = new Array();

function preMain(){
    setPriceStudy(true);
    setDefaultBarFgColor(Color.black,0);
    
    var x = 0;
    fpArray[x] = new FunctionParameter("MinPrice", FunctionParameter.NUMBER);
	with(fpArray[x++]){
        setLowerLimit(0);
        setDefault(10);
        setName("Minimum Eq Price");
    }

    fpArray[x] = new FunctionParameter("MinVol", FunctionParameter.NUMBER);
	with(fpArray[x++]){
        setLowerLimit(0);
        setDefault(100000);
        setName("Minimum Avg Volume");
    }
}

var bInit = false;
var bVersion = null;

var xHigh = null;
var xLow = null;
var xClose = null;
var xOpen = null;
var xVolume = null;
var avgVol = null;

var bPotential = false;
var nCounter = 0;
var returnString = null;

function main(MinPrice, MinVol){
    if (bVersion == null) bVersion = verify();
    if (bVersion == false) return;
    
    if (getCurrentBarCount() < 50) return;
    
    if (!bInit){
        xHigh = high();
        xLow = low();
        xClose = close();
        xOpen = open();

        xVolume = volume();
        avgVol = sma(50, xVolume);

        bInit = true
    }

    if (getBarState() == BARSTATE_ALLBARS){
        bInit = false;
    }


    if (xHigh.getValue(0) < MinPrice || avgVol.getValue(0) < MinVol) return;
    
    if (getBarState() == BARSTATE_NEWBAR && nCounter > 1){
        returnString == " ";
        bPotential = false;
    }
    
    if (getBarState() == BARSTATE_NEWBAR && bPotential){
        nCounter++;
    }

    if (xClose.getValue(-1) > xClose.getValue(-2) &&
        xClose.getValue(-2) > xClose.getValue(-3) &&
        xClose.getValue(-3) > xClose.getValue(-4) &&
        xClose.getValue(-1) > xOpen.getValue(-1)  &&
        xOpen.getValue(0)   < xClose.getValue(-1) &&
        xClose.getValue(0)  < xOpen.getValue(-1)  &&
        xOpen.getValue(0)   > xOpen.getValue(-1)
        ){
            returnString = "Potential pattern found";
            drawTextRelative(0, AboveBar1, "\u00EA", Color.RGB(245,175,165), null, Text.PRESET|Text.CENTER, "Wingdings", 10, "OBC"+rawtime(0));
            bPotential = true;
            nCounter = 0;
            
        }
    else {
        removeText("OBC"+rawtime(0));
        if (nCounter == 0) bPotential = false;
        returnString = " ";
    }

    if (bPotential && nCounter == 1){
        if (xLow.getValue(0) < xClose.getValue(-1)) {
            drawTextRelative(-1, AboveBar1, "\u00EA", Color.red, null, Text.PRESET|Text.CENTER, "Wingdings", 10, "OBC"+rawtime(-1));
            returnString = "Confirmed pattern";
            bPotential = false;
        }
    }
    
    if (isWatchList()) {
        if (returnString == "Potential pattern found"){
            setBarBgColor(Color.RGB(245,175,165),0);
        }
        else if (returnString == "Confirmed pattern"){
            setBarBgColor(Color.red,0);
        }
        return returnString;
    }
}

function verify(){
    var b = false;
    if (getBuildNumber() < 779){
        
        drawTextAbsolute(5, 35, "This study requires version 10.6 or later.", 
            Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
            null, 13, "error");
        drawTextAbsolute(5, 20, "Click HERE to upgrade.@URL=https://www.esignal.com/download/default.asp", 
            Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
            null, 13, "upgrade");
        return b;
    } 
    else
        b = true;
    
    return b;
}

—Eric Lippert
eSignal, an Interactive Data company
800 779-6555, www.eSignal.com

BACK TO LIST

logo

WEALTH-LAB: OCTOBER 2017

The bullish one white soldier and bearish one black crow patterns highlighted by Jerry D’Ambrosio and Barbara Star in their article in this issue, “A Candlestick Strategy with Soldiers and Crows,” have been added to our Community Components library for easy reference in users’ strategies. Here’s the complete list of strategy rules:

Enter long next bar at open if following conditions are met:

Sell short next bar at open if following conditions are met:

Exit long position if any condition is triggered:

  1. Exit at market on two lower lows
  2. Exit at market if either the 14-period stochastic is at or above than 80 or the 14-period RSI is at or above 70
  3. Exit at a 3% stop-loss (if enabled)
  4. Exit at a 5% take-profit (if enabled)

Cover short position if any condition is triggered:

  1. Exit at market on two higher highs
  2. Exit at market if either the 14-period stochastic is at or below 20 or the 14-period RSI is at or below 30
  3. Exit at a 3% stop-loss (if enabled)
  4. Exit at a 5% take-profit (if enabled)
Sample Chart

FIGURE 3: WEALTH-LAB. Application of the strategy to AIG (American International Group).

Get the companion strategy’s C# code by downloading it right from Wealth-Lab’s open strategy dialog (strategy requires the Community Components library installed and/or upgraded to v2017.09 or later). The code is shown below.

Wealth-Lab strategy code (C#):

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;

//Requires Community Components!

namespace WealthLab.Strategies
{
	public class TASC201710 : WealthScript
	{
		private StrategyParameter paramSL;
		private StrategyParameter paramTP;
		private StrategyParameter paramStops;
      
		public TASC201710()
		{
			paramStops = CreateParameter("Activate SL/PT",1,0,1,1);
			paramSL = CreateParameter("Stop %",3,1,10,1);
			paramTP = CreateParameter("Profit %",5,1,20,1);
		}
		
		protected override void Execute()
		{
			var sto = StochK.Series( Bars, 14 );
			var rsi = RSI.Series( Close, 14 );
			bool enableStopAndProfit = paramStops.ValueInt == 1 ? true : false;
		
			for(int bar = GetTradingLoopStartBar( 50 ); bar < Bars.Count; bar++)
			{				
				if (IsLastPositionActive)
				{
					Position p = LastPosition;
					if( p.PositionType == PositionType.Long )
					{
						var twoLowerLows = CumDown.Series( Low, 1)[bar - 1] >= 2;
						var overbot = (sto[bar] >= 80) || (rsi[bar] >= 70);
						double Stop = p.EntryPrice * (1 - paramSL.Value / 100d);
						double Profit = p.EntryPrice * (1 + paramTP.Value / 100.0d);
						
						if( twoLowerLows )
							SellAtMarket( bar+1, p, "2 lows" );
						else
							if( overbot )
								SellAtMarket( bar+1, p, "Overbought" );
						else if(enableStopAndProfit)
						{
							if(!SellAtStop( bar + 1, p, Stop, "Stop") )
								SellAtLimit( bar + 1, p, Profit, "Profit" );
						}
					}
					else
					{
						var twoHigherHighs = CumUp.Series( High ,1)[bar - 1] >= 2;
						var oversold = (sto[bar] <= 20) || (rsi[bar] <= 30);
						double Stop = p.EntryPrice * (1 + paramSL.Value / 100d);
						double Profit = p.EntryPrice * (1 - paramTP.Value / 100.0d);
						
						if( twoHigherHighs )
							SellAtMarket( bar+1, p, "2 highs" );
						else
							if( oversold )
							SellAtMarket( bar+1, p, "Oversold" );
						else if (enableStopAndProfit)
						{
							if(!CoverAtStop( bar + 1, p, Stop, "Stop") )
								CoverAtLimit( bar + 1, p, Profit, "Profit" );
						}
					}
				}
				else
				{
					//trend definition (define your own one)
					var trendBearish = CumDown.Series( Close, 1 )[bar - 1] >= 3;
					var trendBullish = CumUp.Series( Close, 1 )[bar - 1] >= 3;

					//50-day average volume is greater than 100,000
					var volume = SMA.Series( Volume, 50 )[bar] > 100000;

					//Bullish one white soldier scan
					var soldier = this.isBullishOneWhiteSoldier(bar);
					var price1 = Close[bar] > 1.0;
					
					//Bearish one black crow scan
					var crow = this.isBearishOneBlackCrow(bar);
					var price10 = Close[bar] > 10.0;
					
					//Scans
					var BullishScan = trendBearish && volume && soldier && price1;
					var BearishScan = trendBullish && volume && crow && price10;
					
					double[] rectangle = { bar-4, Highest.Series(High, 3)[bar-1], bar-4, Lowest.Series(Low, 3)[bar-1], 
						bar, Lowest.Series(Low, 3)[bar-1], bar, Highest.Series(High, 3)[bar-1] };
					
					if( BullishScan )
					{						
						DrawPolygon( PricePane, Color.Transparent, Color.FromArgb(30, Color.Green), LineStyle.Solid, 2, true, rectangle );
						BuyAtMarket(bar+1, "Bullish one white soldier");
					}
					else
						if( BearishScan )
					{
						DrawPolygon( PricePane, Color.Transparent, Color.FromArgb(30, Color.Red), LineStyle.Solid, 2, true, rectangle );
						ShortAtMarket(bar+1, "Bearish one black crow");
					}
				}
			}
		}
	}
}

—Eugene (Gene Geren), Wealth-Lab team
MS123, LLC
www.wealth-lab.com

BACK TO LIST

logo

NEUROSHELL TRADER: OCTOBER 2017

The bullish one white soldier and bearish one black crow trading systems and scanning can be easily implemented in NeuroShell Trader. Select new trading strategy from the insert menu and enter the following in the appropriate locations of the trading strategy wizard:

Bullish One White Soldier Trading System

BUY LONG CONDITIONS: [All of which must be true]
     A>B(Close,1)
     A>B(Avg(Volume,50),100000)
     A=B(Lag(NumNegMom(Close,3,1),1),3)
     A<B(Lag(Close,1),Lag(Open,1))
     A<B<C(Lag(Close,1),Open,Lag(Open,1))
     A>B(Close,Lag(Open,1))
   STOP PRICE: Close

LONG TRAILING STOP PRICES:
     ValueEntryAct(Trading Strategy,Low,1)

SELL LONG CONDITIONS: [1 of which must be true]
     A=B(NumNegMom(Low,2,1),2)
     A>=B(Stoch%K(High,Low,Close,14),80)
     A>=B(RSI(Close,14),70)

Bearish One Black Crow Trading System

BUY LONG CONDITIONS: [All of which must be true]
     A>B(Close,10)
     A>B(Avg(Volume,50),100000)
     A=B(Lag(NumPosMom(Close,3,1),1),3)
     A>B(Lag(Close,1),Lag(Open,1))
     A>B>C(Lag(Close,1),Open,Lag(Open,1))
     A<B(Close,Lag(Open,1))
   STOP PRICE: Close

LONG TRAILING STOP PRICES:
     ValueEntryAct(Trading Strategy #2,High,1)

SELL LONG CONDITIONS: [1 of which must be true]
     A=B(NumPosMom(High,2,1),2)
     A<=B(Stoch%K(High,Low,Close,14),20)
     A<=B(RSI(Close,14),30)

If you have the NeuroShell Trader Professional, you can also choose whether or not the parameters should be optimized. After backtesting the trading strategy, use the detailed analysis button to view the backtest and trade-by-trade statistics for the strategy.

To scan a large number of ticker symbols for potential candlestick signals, select scan ticker symbols from the file menu and enter the entry conditions from either of the trading systems above as the scan criteria. Once the scan is finished, it can be saved for future use by simply pressing the save as template button.

Sample Chart

FIGURE 4: NEUROSHELL TRADER. This NeuroShell Trader chart shows the bullish one white soldier and bearish one black crow trading systems.

Users of NeuroShell Trader can go to the Stocks & Commodities section of the NeuroShell Trader free technical support website to download a copy of this or any previous Traders’ Tips.

—Marge Sherald, Ward Systems Group, Inc.
301 662-7950, sales@wardsystems.com
www.neuroshell.com

BACK TO LIST

logo

AIQ: OCTOBER 2017

The AIQ code for Jerry D’Ambrosio and Barbara Star’s article, “A Candlestick Strategy With Soldiers And Crows,” can be found at www.TradersEdgeSystems.com/traderstips.htm, and is also shown below.

!A CANDLESTICK STRATEGY WITH SOLDIERS AND CROWS
!Author: Jerry D'Ambrosio & Barbara Star, TASC Oct 2017
!Coded by: Richard Denning 8/05/2017
!www.TradersEdgeSystems.com

!CODING ABBREVIATIONS:
O is [open].
O1 is valresult(O,1).
C is [close].
C1 is valresult(C,1).
C2 is valresult(C,2).
H is [high].
L is [low].
V is [volume].

!INPUTS:
minPriceBull is 1.
minPriceBear is 10.
minVolume is 1000. !in hundreds
volAvgLen is 50.
dayCount is 5.
longExitBars is 7.
shortExitBars is 1.

okToBuy if simpleavg(C,50) > simpleavg(C,200) or C<simpleavg(C,200)*0.7.
okToBuyMkt if TickerRule("SPX",okToBuy).
PVfilterBull if C>minPriceBull and simpleavg(V,volAvgLen)>minVolume.
BullWS if C1<C2 and C1<O1
     and O>C1 and C>O1 and O<O1 
     and countof(C1<C2,dayCount)=dayCount
     and PVfilterBull and okToBuyMkt.
ExitLong if {position days} >= longExitBars.

okToSell if simpleavg(C,50) < simpleavg(C,200) or C>simpleavg(C,200)*1.1.
okToSellMkt if TickerRule("SPX",okToSell).
PVfilterBear if C>minPriceBear and simpleavg(V,volAvgLen).
BearBC if C1>C2 and C1>O1 
     and O<C1 and C<O1 and O>O1 
     and countof(C1>C2,dayCount)=dayCount
     and PVfilterBear and okToSellMkt.
ExitShort if {position days} >= shortExitBars.

I ran several backtests using the NASDAQ 100 list of stocks over the period from 8/04/2000 to 8/04/2017. I varied the following inputs to find the optimum set of parameters for the candlestick patterns. For longs, the “dayCount” = 5 with an “longExitBars” = 7 produced the best results, which is shown in Figure 5. For shorts, the “dayCount” = 5 with a “shortExitBars” = 1 produced the best results, which is shown in Figure 6. Neither commission nor slippage were subtracted from the results.

Sample Chart

FIGURE 5: AIQ. EDS summary report for longs only.

Sample Chart

FIGURE 6: AIQ. EDS summary report for shorts only.

—Richard Denning
info@TradersEdgeSystems.com
for AIQ Systems

BACK TO LIST

logo

TRADERSSTUDIO: OCTOBER 2017

The TradersStudio code based on Jerry D’Ambrosio and Barbara Star’s article, “A Candlestick Strategy With Soldiers And Crows,” can be found at www.TradersEdgeSystems.com/traderstips.htm, and is also available below.

The following files are included in the download:

'A CANDLESTICK STRATEGY WITH SOLDIERS AND CROWS
'Author: Jerry D'Ambrosio & Barbara Star, TASC Oct 2017
'Coded by: Richard Denning 8/05/2017
'www TradersEdgeSystems.com

Function BULL_WHITE_SOLDIER(dayCount)
'dayCount = 3 
Dim BullWS As Boolean
If countof(C[1]<C[2],dayCount,0)=dayCount Then
    If C[1]<C[2] And C[1]<O[1] And O>C[1] And C>O[1] And O<O[1] Then
        BullWS = True
    End If
Else BullWS = False
End If 
BULL_WHITE_SOLDIER = BullWS    
End Function
'-------------------------------------------------------------------------
Function BEAR_BLACK_CROW(dayCount)
'dayCount = 3 
Dim BearBC As Boolean
If countof(C[1]>C[2],dayCount,0)=dayCount Then
    If C[1]>C[2] And C[1]>O[1] And O<C[1] And C<O[1] And O>O[1] Then
        BearBC = True
    End If
Else BearBC = False
End If
BEAR_BLACK_CROW = BearBC    
End Function
'--------------------------------------------------------------------------
Function COUNTOF(rule As BarArray, countLen As Integer, offset As Integer)
Dim count As Integer
Dim counter As Integer
    For counter = 0 + offset To countLen + offset - 1 
        If rule[counter] Then 
            count = count + 1
        End If
    Next
COUNTOF = count
End Function
'---------------------------------------------------------------------------
Sub SOLDIERS_CROWS(minPriceBull,minPriceBear,minVolume,volAvgLen,dayCount,exitBarsLong,exitBarsShort)
'minPriceBull = 1 
'minPriceBear = 10 
'minVolume = 100000
'volAvgLen = 50 
'dayCount = 5 
'exitBarsLong = 7
'exitBarsShort = 1

If C>minPriceBull And Average(V,volAvgLen)>minVolume Then
    If BULL_WHITE_SOLDIER(dayCount)=True Then
        Buy("LE",1,0,Market,Day)
    End If
End If
If BarsSinceEntry >= exitBarsLong Then 
    ExitLong("LX","",1,0,Market,Day)
End If

If C>minPriceBear And Average(V,volAvgLen) Then
    If BEAR_BLACK_CROW(dayCount)=True Then
        Sell("SX",1,0,Market,Day)
    End If
End If
If BarsSinceEntry >= exitBarsShort Then
    ExitShort("SX","",1,0,Market,Day)
End If 
End Sub
'----------------------------------------------------------------------------------

—Richard Denning
info@TradersEdgeSystems.com
for TradersStudio

BACK TO LIST

logo

NINJATRADER: OCTOBER 2017

The soldiers and crows strategy, as discussed in the article “A Candlestick Strategy With Soldiers And Crows” by Jerry D’Ambrosio and Barbara Star in this issue, is available for download at the following links for NinjaTrader 8 and for NinjaTrader 7. Included is an indicator named EastMeetsWestCandlesticks, which can be used to view the bars as described in the article.

Once the file is downloaded, you can import the indicator into NinjaTader 8 from within the Control Center by selecting Tools → Import → NinjaScript Add-On and then selecting the downloaded file for NinjaTrader 8. To import into Ninja­Trader 7 from within the Control Center window, select the menu File → Utilities → Import NinjaScript and select the downloaded file.

You can review the strategy’s source code in NinjaTrader 8 by selecting the menu New → NinjaScript Editor → Strategies from within the Control Center window and selecting the SoldiersAndCrows file. The indicator’s source code can be viewed in NinjaTrader 8 by selecting the menu New → NinjaScript Editor → Indicators from within the Control Center window and selecting the EastMeetsWestCandlesticks file.

You can review the strategy’s source code in NinjaTrader 7 by selecting the menu Tools → Edit NinjaScript → Strategy from within the Control Center window and selecting the SoldiersAndCrows file. The indicator’s source code can be viewed in NinjaTrader 7 by selecting the menu Tools → Edit NinjaScript → Indicators from within the Control Center window and selecting the EastMeetsWestCandlesticks file.

A sample chart is shown in Figure 7.

Sample Chart

FIGURE 7: NINJATRADER. The NX in June and July of 2016 shows examples of the bullish one white soldier entry followed by either the stop-loss or profit target exit method. The strategy includes options for the different stop-loss, profit target, and entry methods described in the article.

NinjaScript uses compiled DLLs that run native, not interpreted, which provides you with the highest performance possible.

—Raymond Deux & Patrick Hodges
NinjaTrader, LLC
www.ninjatrader.com

BACK TO LIST

logo

UPDATA: OCTOBER 2017

The Traders’ Tip for this month is based on the article by Jerry D’Ambrosio and Barbara Star in this issue, “A Candlestick Strategy With Soldiers and Crows.”

In the article, the authors propose a candlestick strategy in much discussion recently, with both long and short scenarios of strategy claiming a record on NYSE stocks of 60% (approximately) forecasting accuracy since January 1, 2013. A simple stochastic and/or RSI is proposed to exit these trades.

The Updata code for this article is in the Updata library and may be downloaded by clicking the custom menu and system library. Those who cannot access the library due to firewall issues may paste the code shown below into the Updata custom editor and save it.

DISPLAYSTYLE 3LINES 
PLOTSTYLE HISTOGRAM
INDICATORTYPE CHART    
INDICATORTYPE3 CHART
Parameter "VolAvg" #Period=50   
Parameter "Thresh.(x1000)" #Thresh=100  
Parameter "RSI Period" #RSIPer=14  
NAME "Vol Avg " #Period 
NAME3 "RSI " #RSIPer
@AvgVolume=0
@RSI=0 
FOR #CURDATE=0 TO #LASTDATE  
   'Exits
    If OrderIsOpen=-1 And @RSI<30
       Cover Close
    ElseIf OrderIsOpen=1 And @RSI>70
       Sell Close
    Endif  
    'Entries
    '50-day average volume is greater than 100,000
    @AvgVolume=SGNL(VOL,#Period,M)   
    @RSI=RSI(#RSIPer) 
    If VOL>@AvgVolume And VOL>#Thresh*1000 
       'Black Crow
       '• Yesterday's close was less than the day before
       '• Yesterday's close was less than its open 
       If Close(1)>Close(2) And Close(1)>Open(1) 
          '• Today's open is lesser than yesterday's close
          '• Today's close is lesser than yesterday's open 
          '• Today's open is more than yesterday's open
          If Close<Open(1) And Open<Close(1) And Open>Open(1) 
             '• As of yesterday's close, price had been closing
             ' higher for three days. 
             If Close(2)>Close(3) And Close(3)>Close(4)
                SHORT OPEN
             EndIf  
          EndIf  
       EndIf
       'White Soldier
       '• Yesterday's close was less than the day before
       '• Yesterday's close was less than its open 
       If Close(1)<Close(2) And Close(1)<Open(1) 
          '• Today's open is greater than yesterday's close
          '• Today's close is greater than yesterday's open 
          '• Today's open is less than yesterday's open
          If Close>Open(1) And Open>Close(1) And Open<Open(1) 
             '• As of yesterday's close, price had been closing
             ' lower for three days. 
             If Close(2)<Close(3) And Close(3)<Close(4)
                BUY OPEN
             EndIf  
          EndIf  
       EndIf              
    EndIf
    @PLOT=VOL
    @PLOT2=@AvgVolume 
    @PLOT3=@RSI
Next

A sample chart is shown in Figure 8.

Sample Chart

FIGURE 8: UPDATA. The soldier and crows candle strategy is applied to the SPY ETF of daily resolution.

—Updata support team
support@updata.co.uk
www.updata.co.uk

BACK TO LIST

Originally published in the October 2017 issue of
Technical Analysis of STOCKS & COMMODITIES magazine.
All rights reserved. © Copyright 2017, Technical Analysis, Inc.