Simple Coding Help - No Promise.

ethan hunt

Well-Known Member
AFL problem:

In Scanner:

Once a BUY is triggered an AFL is giving BUY on every candle till SELL is triggered.
Vice-versa for SELL.

In Charts: Using ExRim avoids multiple BUY/SELL Arrows so it is working fine.

Backtesting is working fine, after BUY comes SELL, after SHORT comes COVER. No multiple BUY or SELL entries.

What to do to set the Scanner right ?
--- deleted ---
 
Last edited:

ethan hunt

Well-Known Member
@Happy_Singh

Hi,

Looking for AFL with following conditions:

Several AFLs on web but none suits my requirement. Tried to tweak but failed.

ORB

15min

Buy at break of HIGH of first candle of the day, no entry after 2.15pm.
Target 30 points profit or if Target not met exit at 3.00pm.
SL=Low of first candle.
Entry / Exit at open of next candle.


Short at break of LOW of first candle of the day, no entry after 2.15pm.
Target 30 points profit or if Target not met exit at 3.00pm.
SL=High of first candle.
Entry / Exit at open of next candle.


Brokerage = 0.02% (can be set in back test settings)
Leverage = 4x (Futures) (can be set = 25 in back test settings)


Changeable parameters:
Chart duration - 15min to 5m, 30m, Hourly etc.
Target - can be changed from fixed to fixed (30 to say 50) and also can be changed from fixed to %.
Stoploss - can be changed from High/Low to fixed and %.
Time of exit
Margin (can be set in back test settings)
Minimum number of shares 20 (can be set in back test settings)
Maximum number of shares 1000

Should be Backtestable , Scannable , Explorable.

AFL experts kindly help.

Thanks
Bump-up
 
I have an AFL code copied from somewhere from internet
Code:
//*VALUE BELOW ZERO IS BEARISH, ABOVE ZERO IS BULLISH**//

MYINDI=(((C-Ref(C,-1))/(HHV(H,2)-LLV(L,2)))*(V+Ref(V,-1))/2);

Plot(EMA(MYINDI,10),"A.N.KUMAR INDICATOR",colorBlack,style=styleDots,Min(0,0),Max(0,0),xshift=0,zorder=0,width=1);
Now the problem is on some scripts it is working fine but on some of the scripts it is not showing correctly. I am using Amibroker 5.70 professional edition 32 bit.
Untitled.png

Untitled2.png


Please suggest what could go wrong here :confused:
Edit: Expanding the time frame sometimes works... But still could not figured out the actual issue.
 
Last edited:

Romeo1998

Well-Known Member
I have an AFL code copied from somewhere from internet
Code:
//*VALUE BELOW ZERO IS BEARISH, ABOVE ZERO IS BULLISH**//

MYINDI=(((C-Ref(C,-1))/(HHV(H,2)-LLV(L,2)))*(V+Ref(V,-1))/2);

Plot(EMA(MYINDI,10),"A.N.KUMAR INDICATOR",colorBlack,style=styleDots,Min(0,0),Max(0,0),xshift=0,zorder=0,width=1);
Now the problem is on some scripts it is working fine but on some of the scripts it is not showing correctly. I am using Amibroker 5.70 professional edition 32 bit.
View attachment 35226
View attachment 35227

Please suggest what could go wrong here :confused:
Edit: Expanding the time frame sometimes works... But still could not figured out the actual issue.
Hello :)
This indicator is quite nice, but if anywhere volume is missing, then indicator gets messed up :)
This is what is giving problems ---- C-Ref(C,-1)
if previous close is 55 and current close is 54, 54-55 = -1, if this difference is very small, it will give problems because it is later divided then mutiplied and then its ema is taken :)
 
Last edited:
  • Scanner to scan 100 stocks
  • Buy or Short condition – say c > 200ma or c < 200ma
  • Alertif condition to be generated on a buy/Short
  • A delay of 2 second required BEFORE THE NEXT ALERT IS GENERATED.

How to code the delay portion?

Please help
 

Romeo1998

Well-Known Member
  • Scanner to scan 100 stocks
  • Buy or Short condition – say c > 200ma or c < 200ma
  • Alertif condition to be generated on a buy/Short
  • A delay of 2 second required BEFORE THE NEXT ALERT IS GENERATED.

How to code the delay portion?

Please help
Hello Sir,
we can add time delay between trades like this

Code:
// time when last buy was triggered
t1 = ValueWhen(Buy,TimeNum());

// last buy time + additional time
t2 = t1 + 000002;

// check if current time is more than or equal to t2
t3 =  Now(4) >= t2;

Buy =  t3  AND " buy condition " ;
For the 1st buy signal t1 will always be 0, so t3 will always be true and buy will be triggered, then from second buy onwards t1 will get time of previous buy.
I have not tested this in live trading :)
Best of Luck :)
 
Last edited:

Similar threads