Forum Replies Created
-
AuthorPosts
-
Stephen JamesMember
ASX Tick Sizes
Code:TS = IIf(C < 0.10, 0.001, IIf(C < 2.00, 0.005, 0.01));Stephen JamesMemberProfit Target Looping
Code:Buy = 0;
Sell = 0;
LStop = Null;
PriceAtBuy = 0;
LBIT = 0;
ProfitTarget = Null;for (j = 1; j < BarCount; j++) { if (PriceAtBuy==0 AND LE[j]) { Buy[j] = True; BuyPrice[j] = Open[j]; PriceAtBuy = BuyPrice[j]; LStop[j] = Max(TrailStop[j-1],TrailStop[j]); LStop[j-1] = TrailStop[j-1]; ProfitTarget[j] = PriceAtBuy*1.2; LBIT[j] = 1; if (LBIT[j]==1 AND L[j] <= LStop[j-1])//low breaches the stop price set yesterday { Sell[j] = True; SellPrice[j] = Min(Open[j],LStop[j-1]);//accounts for an opening gap down PriceAtBuy = 0; } } else if (PriceAtBuy > 0)
{
LBIT[j] = LBIT[j-1]+1;if (LBIT[j]>1)
{
LStop[j] = Max(LStop[j-1],TrailStop[j]);
ProfitTarget[j] = ProfitTarget[j-1];//forms an array in the same manner as trail stop
}if (LBIT[j]>1 AND H[j] >= ProfitTarget[j-1])//high breaches profit target
{
Sell[j] = True;
SellPrice[j] = Max(Open[j],ProfitTarget[j-1]);//accounts for opening gap higher
PriceAtBuy = 0;
}if (LBIT[j]>1 AND L[j] <= LStop[j-1]) { Sell[j] = True; SellPrice[j] = Min(Open[j],LStop[j-1]); PriceAtBuy = 0; } } }
Stephen JamesMemberTo clear the cache go to File>Database Settings>Flush cache
Also, if you are editing whilst the debugger is on, that could cause issues. I think I read somewhere that you should not edit whilst the debugger is running but I’ll check that out further.
Stephen JamesMemberI can’t seem to replicate the issue either.
Stephen JamesMemberGood idea, I’ll try and replicate the issue.
Stephen JamesMemberFor those that are brand new to AmiBroker and did not have previous versions. The debugger was introduced in the latest version, 6.10, so although its an official release, its very possible there are still bugs to sort out, being a new feature.
Stephen JamesMemberI just copied this off one of my scans but you can adapt it:-
Spread = H-L;
StrongClose = C >= (L + (Spread * 75)/100);Stephen JamesMemberIf you just want to reference a set bar number ago you could try something like LBIT[j-5] == 0 in the entry condition but that does not cover 2,3 or 4 bars ago etc.
I guess you could extend that to LBIT[j-2]==0 AND LBIT[j-3]==0 etc etc. It may not be ideal but could be enough to at least test your theory for now.
Stephen JamesMemberGood question! I haven’t come up with a solution within looping yet, but for testing purposes for the time being you could create another file and discard the looping. Then BarsSince should work.
Stephen JamesMemberYou have to use another file. The ADX is a provided indicator however, so you’ll find it in the charts tab and then scroll down to the indicators folder.
Stephen JamesMemberOne way would be to create an array of the PriceAtBuy value, as you did in the Breakeven stop lesson – e.g. BuyLevel
Then in your plot formula use LStop > BuyLevel instead.
Stephen JamesMemberJust be aware that is using Buy Price which could be an issue. For example, If you are buying on the open then you are computing the MA’s on the same bar at the end of the day, having already bought at open. It may or may not make much of a difference, but something to test.
As an alternative, you could use the previous close or price on which the position sizing is done, as well as previous day’s volume.
Stephen JamesMemberPerhaps revisit the profit target task again. The code would be the same structure, but with a scale in instead of a sell.
Coding piece by piece often helps too – i.e. get the scale in working before adding code to restrict it to one scale in only.
Stephen JamesMemberI like your use of the explorer to debug – its a valuable tool. Well done.
Stephen JamesMemberMy understanding is that Foreign(“~~~EQUITY”, “C” ) data is populated after a backtest and the values are not available in the way you are trying to use it in standard backtesting mode.
There is also some contention as to its accuracy so it may be something to avoid.
As I mentioned, a derivative of price and/or volume may be a better option.
-
AuthorPosts