A basic but imp0rtant questions for AmiBroker Experts!!

#1
Hi Friends!

Is there any inbuilt function or option in AmiBroker which executes 'Limit Order' while backtesting your strategy?
The buy order should be executed only if the price in the next bar touches the limit order that you have placed in AFL code! I hope you understood my point.

Suppose I want to buy reliance next bar at the price C[today]-1% of c[today]. While backtesting this, the Amibroker buys the stock even if price did not touch the desired price. Is there anyway to avoid this???

Awaiting your response eagerly!!
Thank you!
----TIZ---
 

FlowTrader

Active Member
#3
Hi Friends!

Is there any inbuilt function or option in AmiBroker which executes 'Limit Order' while backtesting your strategy?
The buy order should be executed only if the price in the next bar touches the limit order that you have placed in AFL code! I hope you understood my point.

Suppose I want to buy reliance next bar at the price C[today]-1% of c[today]. While backtesting this, the Amibroker buys the stock even if price did not touch the desired price. Is there anyway to avoid this???

Awaiting your response eagerly!!
Thank you!
----TIZ---
Code:
Setup  =  "Your Buy Condition" ;
Buy    =   Ref(Setup,-1) and L < 0.99 * Ref(C,-1);
BuyPrice = 0.99 * Ref(C,-1);
This should take care of it
 
Last edited:
#4
Code:
Setup  =  "Your Buy Condition" ;
Buy    =   Ref(Setup,-1) and C < 0.99 * Ref(C,-1);
BuyPrice = 0.99 * Ref(C,-1);
This should take care of it

Thanks a lot for your suggestion!!
However, I was looking for an inbuilt function which takes limit order. (We have such function in TradeStation).

Anyway, thanks a lot for your reply!
---TIZ---
 

FlowTrader

Active Member
#5
Sorry buddy the above code has a small error in it, it should be.

Code:
Setup  =  "Your Buy Condition" ;
Buy    =   Ref(Setup,-1) and L < 0.99 * Ref(C,-1);
BuyPrice = 0.99 * Ref(C,-1);
I don't know of any such built in function
 

amar_gr

Active Member
#6
Sorry buddy the above code has a small error in it, it should be.

Code:
Setup  =  "Your Buy Condition" ;
Buy    =   Ref(Setup,-1) and L < 0.99 * Ref(C,-1);
BuyPrice = 0.99 * Ref(C,-1);
I don't know of any such built in function
Dear Flowtrader,

I am looking for the code to close an open position at the trailing stop loss (TSL) level, which often occurs intrabar.

I am rather new to afl programming, but have tried to modify this code as below. I am not sure if I understand it fully.

Please let me know if the following code will close an open position at the specified TSL level.

Code:
Sell    =   Ref(TSL,-1) and L > 0.99 * Ref(C,-1);
SellPrice = 0.99 * Ref(C,-1);
I am listing out the original code below, will appreciate your inputs in this regard. Thanks in advance.

Amar.



no=Param( "Swing", 9, 1, 55 );
tsl_col=ParamColor( "Color", colorCycle );

res=HHV(H,no);
sup=LLV(L,no);
avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0));
avn=ValueWhen(avd!=0,avd,1);
tsl=IIf(avn==1,sup,res);

Plot(tsl, _DEFAULT_NAME(), tsl_col, styleStaircase);

Buy=Cover=Cross(C,tsl);
Sell=Short=Cross(tsl,C);
shape=Buy*shapeUpArrow + Sell*shapeDownArrow;
PlotShapes(shape,IIf(Buy,tsl_col,tsl_col),0,IIf(Buy,Low,High));
_SECTION_END();
 
Last edited:

Similar threads