Thanks Trash
Sorry the late acknowledgment had a whole lot of weather and not a whole lot of power here in the west.
Should have known this code was buried somewhere in the AB manual appreciate your pointing me in the right direction.
M of Perth
Switch(ExposureVal)
{
Case < 0.10:
1;
Case (>=0.1 AND <=0.2):
2;
Case >0.2:
3;
}
Is it valid to use boolean logic in case statements as per above or do case values have to be discrete numbers as shown in the AB manual?
M of Perth
Hello
I need a bit of help with the following afl. I want to be able to manually enter an entry date in parameters and plot a target line 5% below the entry date. Could someone please tell me what I have wrong. I get an error in the plot.
HTML Code:Plot( C, "Close", colorBlack , styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); BuyStartDate = ParamDate( "Buy Start Date", "2012-06-01" ); EndDate = ParamDate( "Last Buy Date", "2020-01-01" ); DateOK = IIf(DateNum() >= BuyStartDate , 1, 0); //AND DateNum() <= EndDate Short = Close>1 AND DateOK ; ShortPrice=Close; Cover = RSI(5 ) < 20; CoverPrice=Close; entry = ShortPrice; target1 = entry - (entry * .050); end = LastValue( BarIndex() ); Plot(LineArray(buystartdate,target1, end ,target1,1), "", colorOrange, styleLine); //LineArray( x0, y0, x1, y1, extend = 0, usebarindex = False )
No problems. Inspired by the same book.
Backtest filtered by ASX All Ordinaries (2012), 100K initial equity, min $5000 pos, $35 per trade, no more than 1% of entry bar volume.PHP Code:PositionSize = -20;
PositionScore = 1 - C/10;
XAO = Foreign("XSO","Close");
XAOMA = MA(XAO, 75);
Buy = Sell = 0;
SetTradeDelays(1, 1, 1, 1);
BuyPrice = Close;
SellPrice = Close;
Length = 260; // 1 year
BuySig =
Close > HHV(Ref(Close, -1), Length)
AND XAO > XAOMA
;
SellSig =
Close < Ref( LLV(Close, Length), -1)
OR XAO < XAOMA
;
Buy = ExRem(BuySig, SellSig);
Sell = ExRem(SellSig, BuySig);
ApplyStop(stopTypeLoss, stopModePercent, amount = 25, False );
Jan 2011 - Jun 2012. CAR = 22.33%, MDD = -8.03%
Jan 2004 - Jun 2012. CAR = 21.00%, MDD = -26.41%
Will not make you rich overnight and not that I would trade this system myself, but this an Amibroker thread, not the trading one.
Your code has many errors. First, ParamDate without the third parameter returns an integer in DateNum format, which is rather useless in plots. Second, ShortPrice is an array, as a result all the rest - entry and target1 are arrays too, and LineArray accepts only numbers. Third, 1st parameter in LineArray is a bar index, not a DateNum.Try following and be prepared not to see the line if BuyStartDate is far outside the visible range.
PHP Code:Plot( C, "Close", colorBlack , styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
BuyStartDate = _DT( ParamDate( "Buy Start Date", "2012-06-01", 1) );
EndDate = _DT( ParamDate( "Last Buy Date", "2020-01-01", 1) );
DateOK = IIf(DateNum() >= BuyStartDate , 1, 0); //AND DateNum() <= EndDate
Short = Close>1 AND DateOK ; ShortPrice=Close;
Cover = RSI(5 ) < 20; CoverPrice=Close;
entry = Lookup(ShortPrice, BuyStartDate, -1);
target1 = entry - (entry * .050);
end = LastValue( BarIndex() );
Plot(LineArray(Lookup(BarIndex(), BuyStartDate), target1, end ,target1, 1), "", colorOrange, styleLine);
//LineArray( x0, y0, x1, y1, extend = 0, usebarindex = False )
Hi qsb6irfa
Thanks for telling me that. I dont have any experience with date/ bar index sort of equations and Ive spent a large chunk of the weekend trying to learn. When you look up the amibroker help files their are heaps of different date related types and it becomes a massive learning curve. Im stumped! The original idea came from a formula that I have posted below that plots 3 targets on a chart after a break of support or resistance. All I am trying to do is edit it so instead of it using a break of support or resistance to initiate the target lines I want to manually enter a date in parameters to start it. I cant find any afl's on the net that I can learn from so I really need some help. The last thing I tried was
Short =Cross( DateNum(),ParamDate( "Start Date","2012-05-01",0 ));
but this is probably wrong too based on what you have said. Do I have to write a loop for the entry or is it just something simple? Is paramdate ok to use? Sorry Ive run out of ideas
HTML Code:Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); showsl = ParamToggle("Stop Loss Line", "Show|Hide", 0); res=HHV(H,10); sup=LLV(L,10); avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0)); avn=ValueWhen(avd!=0,avd,1); s5d=IIf(avn==1,sup,res); if (showsl == 0) {Plot(s5d,"Stop Loss",colorCustom14,styleDots);} exitlong = Cross(s5d, H); PlotShapes(exitlong * shapeNone, colorBlack,0,H,-10); exitshort = Cross(L, s5d); PlotShapes(exitshort * shapeNone, colorBlack,0,L,-15); Buy = exitshort; Sell = exitlong; Buy = ExRem(Buy,Sell); Sell = ExRem(Sell,Buy); for(i=BarCount-1;i>1;i--) { if(Buy[i] == 1) { entry = C[i]; sig = "BUY"; sl = s5d[i]; tar1 = entry + (entry * .050); tar2 = entry + (entry * .075); tar3 = entry + (entry * .100); bars = i; i = 0; } if(Sell[i] == 1) { sig = "SELL"; entry = C[i]; sl = s5d[i]; tar1 = entry - (entry * .050); tar2 = entry - (entry * .075); tar3 = entry - (entry * .100); bars = i; i = 0; } } Offset = 20; Clr = IIf(sig == "BUY", colorLime, colorRed); ssl = IIf(bars == BarCount-1, s5d[BarCount-1], Ref(s5d, -1)); sl = ssl[BarCount-1]; Plot(LineArray(bars-Offset, tar1, BarCount, tar1,1), "", Clr, styleLine, Null, Null, Offset); Plot(LineArray(bars-Offset, tar2, BarCount, tar2,1), "", Clr, styleLine, Null, Null, Offset); Plot(LineArray(bars-Offset, tar3, BarCount, tar3,1), "", Clr, styleLine, Null, Null, Offset); _SECTION_END();
qsb6irfa thanks to you I have solved it. I thought a bit about what you said and I think the difference in the end was the zero on the end of the paramdate part.
Short =Cross( DateNum(),ParamDate( "Start Date","2012-05-01",0 ));
When I use this it works fine. Thanks mate!!
Hi folks,
Quick question for AB aficionados - is there a way to control text size for PlotText function?
Thanks in advance
Dre
Concern should drive us into action and not into a depression. No man is free who cannot control himself.
Could someone help me plot the value of pSAR for the following day, as a small horizontal line on the chart, using this formula?
SAR tomorrow = SAR today + AF(EP trade - SAR(today)
where AF = acceleration factor, and EP = highest high reached yesterday
I know this isn't the exact formula, but it's sort of close.
Thanks.
Note to self: Big upside patterns (R1). Profit target 90% R1/R2.
Thanks colion, excellent.
Just in case anyone else is wondering about the next day value for the pSAR, it will depend on OHLC values and may vary significantly during the day. Unfortunately there are many supposedly reputable websites that say you can calculate ahead of time what that value will be.
Note to self: Big upside patterns (R1). Profit target 90% R1/R2.
Concern should drive us into action and not into a depression. No man is free who cannot control himself.
Once you jump into low level graphics then as far then as I know you have to go in all the way. Have you seen the tutorial at http://www.amibroker.com/guide/h_lowlevelgfx.html? Of course, if you are satisfied with one font for the entire chart you can use Tools >> Preferences >> Miscellaneous to change the font. I believe that these are your two choices.
Concern should drive us into action and not into a depression. No man is free who cannot control himself.
Bookmarks