Here is a dummy version of my program:
/*=====================================================================
OPTIONS/SETTINGS
=====================================================================*/
InitialEquity = 100000;
PositionSize = 10000;
CommissionAmount = 10;
SetOption("UseCustomBacktestProc", 0); // Enable custom backtesting
SetOption("InitialEquity", InitialEquity);
SetOption("MinPosValue", PositionSize*0.99); // Minimum dollar amount required to open the position in the backtester/optimizer
/*
// Set to "PositionSize" for fixed position sizes, otherwise the position size can fall between
// "PositionSize" and "MinPosValue".
// Set to 0 to have as much funds in the market as possible,
// with the downside of varying positions sizes. Use this with caution.
*/
SetOption("MaxOpenPositions", 1000); // Maximum number of open positions, range between 1 and 1000, 1000 means limited only by available funds
SetOption("PriceBoundChecking", 1); // True: Adjust prices so that they fall within the High-Low range
SetOption("CommissionMode", 2); // Use $ amount
SetOption("CommissionAmount", CommissionAmount); // Broker's commission (fixed value)
SetOption("UsePrevBarEquityForPosSizing", 1); // True: Use previous bar closing equity to perform position sizing
SetOption("AllowSameBarExit", 0); // False: Trade is exited & we move to next bar ignoring other signals
SetOption("NoDefaultColumns", 0); // Do not display the default columns (Symbol and Date)
SetOption("ExtraColumnsLocation", 1); // Allows the location change of custom columns added during backtest/optimization.
SetOption("MinShares", 1); // Minimum number of shares required to open the position in the backtester/optimizer
SetOption("AllowPositionShrinking", 0); //
SetOption("ReverseSignalForcesExit", 0); // Reverse entry signal forces exit of existing trade
SetOption("FuturesMode", 0); //
SetOption("AccountMargin", 100); // Account margin requirement - 100 = no margin
SetOption("InterestRate", 0); //
SetOption("EveryBarNullCheck",0); //
SetOption("HoldMinBars",0); // > 0 - disables exit during user-specified number of bars
SetOption("EarlyExitBars",0); // > 0 - causes that special early exit (redemption) fee is charged
SetOption("EarlyExitFee",0); // Defines the % (percent) value of early exit fee
SetOption("EarlyExitDays",0); // > 0 - causes that special early exit (redemption) fee is charged
//SetOption("DisableRuinStop",1); // Built-in ruin stop is disabled
SetOption("RefreshWhenCompleted",0); // Refresh All after Automatic-Analysis operation (scan/exploration/backtest/optimize) is completed.
SetOption("SeparateLongShortRank", 1); // Backtester maintains TWO separate "top-ranked" signal lists
SetOption("MCEnable", 1); // Value == 0 disables MC simulation, Value == 1 enables MC only in portfolio backtests (default),
// Value == 2 forces MC to be enabled everywhere (in every mode including optimization - SLOW !)
SetOption("MCRuns", 1000); // define number of MC simulation runs (realizations)
/*=====================================================================
EXPLORATION
=====================================================================*/
// Dummy Values
ROCShort = ROC(C,5);
ROCLong = ROC(C,10);
Buy = ROCShort > 5;
Sell = ROCShort < 5;
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
PositionScore = ROCShort;
NumShares = 1000;
BuyOffer = C * 1.03;
PctRiskTrade = 10;
RiskAmount = 1000;
InitialStopLoss = C - ATR(10);
SellOffer = C * 0.8;
// Set Column Sort Order
switch(Status("action")) {
case actionScan:
SetSortColumns(3, 2, 4);
break;
case actionExplore:
SetSortColumns(1,2);
break;
case actionBacktest:
break;
}
Filter = Buy OR Sell;
AddTextColumn(Date(), "Date", 1, colorDefault, colorDefault, 80);
AddTextColumn(Name(), "Ticker", 1, colorDefault, colorDefault, 80);
// Exploration Analysis - this column displays the close price
AddColumn(Close, "Close Price", 1.3, colorDefault, colorDefault, 80);
// Exploration Analysis - primary filter criteria
AddColumn(IIf(Buy, ROCShort, Null), "ROCShort",colorDefault, colorDefault, -1);
AddColumn(IIf(Buy, ROCLong, Null), "ROCLong");
// Exploration Analysis - this column displays the position score
AddColumn(IIf(Buy, PositionScore, Null), "Position Score", 1.2, colorDefault, colorDefault, -1);
// Exploration Analysis - this column displays the desired/target Buy Price (same as close)
AddColumn(IIf(Buy, Close, Null), "Buy Price", 1.3, colorWhite, colorDarkGreen, -1);
// Exploration Analysis - this column displays the desired/target quantity of shares to buy (if entered at desired Buy Price)
AddColumn(IIf(Buy, NumShares, Null), "# Shares", 1, colorDarkGreen, -1);
// Exploration Analysis - this column displays the desired/target Position Size (if entered at desired Buy Price)
AddColumn(IIf(Buy, PositionSize, Null), "* Position Size *", 1.2, colorWhite, colorPaleBlue, -1);
// Exploration Analysis - this column displays pre-auction buy offer price (+3% premium added to the last closing price)
AddColumn(IIf(Buy, BuyOffer, Null), "* Buy Offer *", 1.3, colorWhite, colorPaleBlue, -1);
// Exploration Analysis - this column displays the total ($) you will pay for the qty of shares at the +3% premium
AddColumn(IIf(Buy, NumShares * BuyOffer, Null), "Buy Cost", 1.2, colorDefault, colorDefault, -1);
// Exploration Analysis - this column displays the percent risk on this trade
AddColumn(IIf(Buy, PctRiskTrade, Null), "% Risk/Trade", 1.2, colorDefault, colorDefault, -1);
// Exploration Analysis - this column displays the total dollar risk on this trade
AddColumn(IIf(Buy, RiskAmount, Null), "$ Risk/Trade", 1.2, colorDefault, colorDefault, -1);
// Exploration Analysis - this column displays the initial stop loss (exit EOW with Next Day order for Monday's open)
AddColumn(IIf(Buy, InitialStopLoss, Null), "Stop Loss", 1.3, colorDefault, colorDefault, -1);
// Exploration Analysis - this column displays the GTFO stop (ISL - 20%: enter this into the market as a limit order)
AddColumn(IIf(Buy, InitialStopLoss * 0.8, Null), "GTFO Loss", 1.3, colorWhite, colorPaleBlue, -1);
// Exploration Analysis - this column displays pre-auction sell offer price (-3% discount to the last closing price)
AddColumn(IIf(Sell, SellOffer, Null), "Sell Offer", 1.2, colorWhite, colorRed, -1);
/*=====================================================================
CHARTING
=====================================================================*/
function DateNumToDateFull(nDate,index)
{
dt = DateTimeConvert(2,nDate,Null);
ds = DateTimeFormat("%A, %B %d, %Y",dt[index]);
return ds;
}
InTrade = Flip(Ref(Buy,-1),Ref(Sell,-1));
TrailStopReason = Null;
TrailStopPrice = C - (3 * ATR(14));
// Trailing Stop Reason message
stopMessage = "";
stopMessageString = ",- TRAILING STOP,- %.0f x DOWN BAR STOP,- PROFIT STOP";
idx=TrailStopReason[SelectedValue(BarIndex())];
stopMessage = StrExtract(stopMessageString,idx);
if (idx == 2) stopMessage = StrFormat(stopMessage,StopDownBars);
SetChartOptions(1, chartShowDates, chartGridMiddle, 0, 0, 0);
_N(Title = StrFormat("{{NAME}} - %s - {{INTERVAL}} - %s\nOpen %g, Hi %g, Lo %g, Close %g (%.1f%%)\n{{VALUES}} %s",
FullName(),DateNumToDateFull(DateNum(),SelectedValue(BarIndex())), O, H, L, C, SelectedValue(ROC(C, 1)), stopMessage ));
Plot(Close, "Close", ParamColor("Color", colorDefault), styleNoTitle | ParamStyle("Style") | GetPriceStyle());
// Show ROC for selected bar
Plot(ROCShort,"ROCShort", colorBrightGreen, styleNoDraw | styleOwnScale);
Plot(ROCLong,"ROCLong", colorBrightGreen, styleNoDraw | styleOwnScale);
// Show Trailing Stop Price and Reason if in a trade
Plot(IIf(InTrade,TrailStopPrice,Null),"Trailing Stop Price", colorRed, styleLine | styleThick);
Plot(IIf(InTrade,TrailStopReason,Null),"Trailing Stop Reason", colorWhite, styleNoDraw);
// Show Buy and Sell Arrows
PlotShapes(Buy*shapeUpArrow,colorGreen,0,Low);
PlotShapes(Sell*shapeDownArrow,colorRed,0,High);
// Show Buy and Sell price on the chart on the Buy and Sell bar (not the Trigger Bar)
textdist = 1.5*ATR(10);
for( i = 1; i < BarCount; i++)
{
if (Buy[i - 1]) PlotText("Buy\n@ " + Prec (Open[i],2), i, L[i] - textdist[i], colorWhite); // Displays white buy price (opening price) under the white box (buy bar)
if (Sell[i - 1]) PlotText("Sell\n@ " + Prec (Open[i],2), i, H[i] + textdist[i], colorWhite); // Displays yellow sell price (opening price) above the yellow circle (sell bar)
}
I run an explore and can double-click the results to navigate to that symbol in the chart.
If the only change I make to the program is:
SetOption("NoDefaultColumns", 1); // Do not display the default columns (Symbol and Date)
I get Error 706: Show Arrows feature needs a Trades List.
Settings -> Report -> Trade List is selected.
I want to display Date then Ticker in that order. I also want to be able to double click the row and navigate to the ticker in the chart.
How do I make that happen?