Hi,
I am new to AmiBroker and I require some help with AFL in coding a simple strategy. I want to create the most basic form of a Bullish Engulfing strategy.
Buy on tomorrow's Open when:
- Today's Close > Previous day's Open
- Today's Open < Previous day's Close
Sell on Open after holding on the 7th day (inclusive of Buy Day).
Here is what I have done:
1) Analysis Tab > Settings > Trades
- Set Buy Price = Open, Sell Price = Open
- Set Buy Delay = 0, Sell Delay = 0
2) AFL Script:
Buy = Close > Ref(Open, -1) AND Open < Ref(Close, -1);
Sell = BarsSince(Buy)== 6;
Is this correct? What is the difference between using "Sell = BarsSince(Buy)== 6;" and "Sell = ApplyStop( stopTypeNBar, stopModeBars, 6 );" ?
When I show arrows for actual trades and look at the buy and exit signals, they are not reflecting what I have in mind. The entry signals and exit signals are wrong.
Is there anything wrong with my AFL? Can someone kindly help me out here. Thanks!
I am new to AmiBroker and I require some help with AFL in coding a simple strategy. I want to create the most basic form of a Bullish Engulfing strategy.
Buy on tomorrow's Open when:
- Today's Close > Previous day's Open
- Today's Open < Previous day's Close
Sell on Open after holding on the 7th day (inclusive of Buy Day).
Here is what I have done:
1) Analysis Tab > Settings > Trades
- Set Buy Price = Open, Sell Price = Open
- Set Buy Delay = 0, Sell Delay = 0
2) AFL Script:
Buy = Close > Ref(Open, -1) AND Open < Ref(Close, -1);
Sell = BarsSince(Buy)== 6;
Is this correct? What is the difference between using "Sell = BarsSince(Buy)== 6;" and "Sell = ApplyStop( stopTypeNBar, stopModeBars, 6 );" ?
When I show arrows for actual trades and look at the buy and exit signals, they are not reflecting what I have in mind. The entry signals and exit signals are wrong.
Is there anything wrong with my AFL? Can someone kindly help me out here. Thanks!