Forum Replies Created
-
AuthorPosts
-
Stephen JamesMember
Save into the report charts folder in AB
Code:eqname = “~~~EQUITY”;
if( Name() != eqname ) SetForeign( eqname );
eq = Close;bslh = HighestBars(eq);
MaxWaitBars = Highest(bslh);
Plot(bslh, “#bars since last high”, colorred, styleHistogram, 0, 10 * LastValue( Highest( bslh ) ) );
Plot(MaxWaitBars, “Max Wait Bars”, colorBlue, styleline);Stephen JamesMemberAdjusted for day to day management (explorations on last bar of data etc).
Unadjusted for backtesting and older data.October 14, 2019 at 10:49 pm in reply to: Migration to IB Australia Pty Ltd: Margin Restrictions for Retail Accounts #110484Stephen JamesMemberI’ve had a bit more of a read and it would seem that it would be a no go for margin.
The account opening process is to fill out some TS agreements to gain access to the TS platform. Then you have open an IB account.
So if you have an existing IB account, I’d say the trading permissions would not change and Australian residents would get diverted to IB Aust if opening a new account.
IB UK do not do trust accounts so that is not an avenue either.
TS are just acting as a referrer to IB it seems, to get their platform exposure and for referrers fees, hence the slightly higher brokerage rates than with direct IB.
October 14, 2019 at 9:51 pm in reply to: Migration to IB Australia Pty Ltd: Margin Restrictions for Retail Accounts #110483Stephen JamesMemberNot too sure Scott. I find it odd that Australian residents are even offered after IB set up here.
It might have to be USD account as the brokerage for AUD denominated is 0.12% trade value Min $7.50, unless that is to trade the ASX – its not clear.
You could contact them with all the relevant questions and see what comes back.
October 14, 2019 at 12:34 am in reply to: Migration to IB Australia Pty Ltd: Margin Restrictions for Retail Accounts #110478Stephen JamesMemberI opened a US account (denominated in USD – brokerage $0.01 per share – min $1) to get access to the TradeStation WebAPI, not a global account.
I tried to get a developer to create an API so I could use in the same manner as IB, but have just recently abandoned the project.
The developer was not impressed with the TS WebAPI and there were security issues that I was not happy with. The developer needed access to the account and order platform. We eventually solved the latter as it does not have links to account proper but I wasn’t happy with any solution to the account access. TS also wanted the developer to fill out paperwork as an authorised signatory for the account. I had a contact at TS who helped me get around that and the platform access but he has recently left the firm. He was very helpful, but otherwise support and service has been rather poor.
Seems to me that the TS WebAPI is mostly used by their in house team that will work with high volume corporate clients. TS are not set up well for external developers unless they are the account holder. External developers who have used it seem very scarce.
The actual order platform is quite good but there a couple of issues for manual order placement.
The MOC order for exits cannot be placed out of markets hours (30 mins before the open is possible from memory), however you can set a time for the exit order to trigger so I am exiting 5 seconds before the close as a testing base.
TS calculates the margin on all orders placed even though they are to buy at limit and does not allow more, so you cannot necessarily place 40 orders for example depending on each stocks margin.
Coding a system in EasyLanguage and automating can be done without the API but due to the above issues I have not investigated it. There seem to be plenty of developers around that do that.
I’ve retested my system around the above issues and have started a trial period to see if reality will match my results using manual orders (it is possible to setup a template with the order type so 40 orders takes me about 25-30 mins to process).
That’s the short version…..
Stephen JamesMemberHere’s a version that can be added to any system. I’m getting suspicious of it though – some comparison with some excel analysis is probably the way to go.
Code:_SECTION_BEGIN(“Custom Backtester”);
//=================================================================================
//Custom Backtester
//=================================================================================
EquityTog = ParamToggle(“Equity Curve”,”Off|On”,0);
EQMA = Param(“Equity Curve MA”,50,2,1000,1);
//———————————————————————————
SetCustomBacktestProc(“”);
if (Status(“action”) == actionPortfolio)
{
bo = GetBacktesterObject(); // Get backtester object
bo.PreProcess(); // Do pre-processing (always required)
MaxOrdersToPlace = 0;
TotalOrdersPlaced = 0;
AveEquity = 0;for (i = 1; i < BarCount; i++) // Loop through all bars { TotalSignalCount = 0; SigCount = 0; AveEquity = bo.EquityArray < MA(bo.EquityArray,EQMA); // Count all entry signals for this bar for (sig = bo.GetFirstSignal(i); sig; sig = bo.GetNextSignal(i)) { if (sig.IsEntry() && sig.IsLong()) TotalSignalCount++; } // Process signals for (sig = bo.GetFirstSignal(i); sig; sig = bo.GetNextSignal(i)) { if (sig.IsEntry() && sig.IsLong()) { SigCount++; if (EquityTog && AveEquity[i-1]) sig.Price = -1; } } // End of for loop over signals at this bar bo.ProcessTradeSignals(i); // Process trades at bar (always required) } // End of for loop over bars bo.PostProcess(); // Do post-processing (always required) } //================================================================================= _SECTION_END();
Stephen JamesMemberJulian
You can replace current CBT code for a limit order, except it does not have any position sizing variables in it as I understand some of yours do.It would need adjustment for any buy at open system.
It uses a CBT object bo.EquityArray so the question at this stage is whether that array continues to take all raw signals when the traded signals are being ignored.
I’ll post a bolt on version later to use with any existing code.
Stephen JamesMemberHere is some code which ‘seems’ to work but I haven’t done any serious testing. Any user therefore will need to do their own analysis and testing to determine if is working as intended.
I’ve added it to the CBT code we use for MR systems.
Code:_SECTION_BEGIN(“Custom Backtester”);
//=================================================================================
//Custom Backtester
//=================================================================================
DailyEntryOrderLimit = MaxPos;
“”;
“Ticker:”;
Ticker = Name();
StaticVarSet(Ticker + “LimitEntryPrice”, Ref(BuyLimit,-1));
“Buy Limit: ” +NumToStr(BuyLimit,1.2);EquityTog = ParamToggle(“Equity Curve”,”Off|On”,0);
EQMA = Param(“Equity Curve MA”,100,2,1000,1);
//———————————————————————————
SetCustomBacktestProc(“”);
if (Status(“action”) == actionPortfolio)
{
bo = GetBacktesterObject(); // Get backtester object
bo.PreProcess(); // Do pre-processing (always required)
MaxOrdersToPlace = 0;
TotalOrdersPlaced = 0;
AveEquity = 0;for (i = 1; i < BarCount; i++) // Loop through all bars { MaxOrdersToPlace = MaxPos - bo.GetOpenPosQty(); TotalSignalCount = 0; SigCount = 0; AveEquity = bo.EquityArray < MA(bo.EquityArray,EQMA); // Count all entry signals for this bar for (sig = bo.GetFirstSignal(i); sig; sig = bo.GetNextSignal(i)) { if (sig.IsEntry() && sig.IsLong()) TotalSignalCount++; } // Process signals for (sig = bo.GetFirstSignal(i); sig; sig = bo.GetNextSignal(i)) { if (sig.IsEntry() && sig.IsLong()) { SigCount++; LimitPrice = StaticVarGet(sig.Symbol + "LimitEntryPrice"); LowPrice = Foreign(sig.Symbol, "Low"); // Restrict number of orders per day if (SigCount > MaxOrdersToPlace OR // Lower in the list than MaxPos less Open positions
SigCount > DailyEntryOrderLimit) // Exceeds max orders per day parameter setting
sig.Price = -1; // Therefore exclude this signal
else
TotalOrdersPlaced++; // Count orders placedif (LimitPrice[i] < LowPrice[i]) // If limit less than Low... sig.Price = -1; // ...Doesn't meet entry trigger criteria else TotalOrdersPlaced++; // Count orders placed if (EquityTog && AveEquity[i-1]) sig.Price = -1; } } // End of for loop over signals at this bar bo.ProcessTradeSignals(i); // Process trades at bar (always required) } // End of for loop over bars bo.PostProcess(); // Do post-processing (always required) st = bo.GetPerformanceStats(0); bo.AddCustomMetric("Total Entry Orders Placed", TotalOrdersPlaced, Null, Null, 0); bo.AddCustomMetric("Fill Rate", NumToStr(((st.getvalue("AllQty") / TotalOrdersPlaced) * 100), 1.0) + "%", Null, Null, 1); } //================================================================================= _SECTION_END();
Stephen JamesMemberThe only issue with using Current and Past is the time of processing the scan, as it contains all current constituents, As long as you have the Norgate code active.
The current watchlist only is fine for daily management but as soon as you start signal checking with previous dates as far back as you are then Current and Past is best.
Stephen JamesMemberDaniel
I have BF.B, HEI.A, LEN.B, FOXA, GOOGL, NWSA, UAA, DISCK, LBRDK, LSXMA, BRK.B
Stephen JamesMemberIan
Try Barssince(MAxover) < 20 Barssince(array) The array needs to return true (1) or false(0) , then assign the condition.
Stephen JamesMemberMy understanding is that AB can only compress time frames from lower to higher (e.g. daily to weekly), not higher to lower.
Stephen JamesMemberDrew
I had a google when I did it and found our big banks have guides that helped me.
e.g. Macquarie
Stephen JamesMemberTakeover by Pfizer Julian
Stephen JamesMemberNo need for CBT.
AddtoComposite has flags for explorations and backtesting such as atcFlagEnableInBacktest.
You can more than one flag in there also – check the user guide for a full list.
atcFlagDeleteValues is also recommended for testing.
-
AuthorPosts