Simple Coding Help - No Promise.

Code:
_SECTION_BEGIN("RSI");
SetChartOptions(0,0,chartGrid30|chartGrid70);
periods = Param( "Periods", 15, 1, 200, 1 );
R = RSI( periods);
COL= IIf(R>50,ParamColor( "HColor", colorGreen), ParamColor( "LColor", colorRed ));
Plot(R,"RSI", COL , ParamStyle("Style",styleThick));
_SECTION_END();
Happy :)
 
@hungboss1: I suggest - try plotting all those conditions as lines (buy1, buy2, buy3 etc etc etc) first on your chart to see when are the conditions being met. The "Relax" statement has no relevance, since it is not being used to do any evaluations other than within the statement, unless you are using it in some other part of the code. Thanks.
Thanks for your reply but I still can not fix it. As you can see after the first short signal, there is a green star that means closebuy signal because it crosses under violet line. This is wrong signal because it should only show after a buy. Right after that is a red star that means closeshort signal because it cross over violet line again. This is correct signal. In backtesting it only show the correct signal. Hope anyone can give me a hint how to dealwith it.

1550331795015.png
 
Thanks for your reply but I still can not fix it. As you can see after the first short signal, there is a green star that means closebuy signal because it crosses under violet line. This is wrong signal because it should only show after a buy. Right after that is a red star that means closeshort signal because it cross over violet line again. This is correct signal. In backtesting it only show the correct signal. Hope anyone can give me a hint how to dealwith it.

View attachment 33404

@hungboss1: The other option would be put a flag to check "BUY" or "SHORT" active condition within a loop and release the flag when the position is closed out.
 

onequorauser

Well-Known Member
Hi all,

Below is a code for getting the daily ATR on an intraday chart

It works ok if I do not select any bar and keep it towards end of the screen.Please see figure 1
1551240690173.png


However, what happens is that when I move the marker to the left, the values on 15M and 5M start chainging differently. Please see figure 2.
1551240847448.png


I have a feeling that when the marker is moved to left, it moves equivalent number of bars back on the daily b

Can some one please help me change the code to get the daily ATR from previous day irrespective of where I keep the marker in that day.

For example, if I keep the marker anywhere in today's intraday chart it should give me daily atr for yesterday and if I keep the marker anywhere on yesterday's intraday it should give me day before yesterday's daily ATR

TimeFrameSet(inDaily);

YATRp = Param("ATR Period", 10, 2, 100, 1 );
YATR = ATR(YATRp);
YATRYesterday = Ref(YATR,-1)
TimeFrameRestore();

//YATRYesterday = TimeFrameExpand(YATRYesterday, inDaily, expandLast);

Plot(YATR ,"Daily_ATr",colorAqua,styleThick);


Thanks in advance!!
 
Thanks for your reply but I still can not fix it. As you can see after the first short signal, there is a green star that means closebuy signal because it crosses under violet line. This is wrong signal because it should only show after a buy. Right after that is a red star that means closeshort signal because it cross over violet line again. This is correct signal. In backtesting it only show the correct signal. Hope anyone can give me a hint how to dealwith it.

View attachment 33404
can you share the code then we can help you
 
Hi,

I am working on an Exploration using Wavetrend Indicator and I need some guidance on a step. Now I have set a Filter to capture the crossovers of the Wavetrend 1 & 2 to provide the results.

Issue: I need another Filter to capture signals only when the crossover happens between -50 & -60 for BUY and SELL when crossover is between 50 and 60. Since I am very new to Amibroker, I am not able to figure out how to capture the crossover value since the output is only in 1 and 0.

N1=ChannelPeriod;
N2=AvgPeriod;
AvgPrice=Avg; // Typical Price = (H + L + C)/3
ESA = Wilders(AvgPrice,N1);
D = Wilders(abs(AvgPrice-ESA),N1);
CI = (AvgPrice-ESA)/(0.015*D);

WT1 = EMA(CI,N2);
WT2 = MA(WT1,4);

Buy= Cross(WT1,WT2);
Sell= Cross(WT2,WT1);

Filter = Buy OR Sell;

AddColumn(O,"Open",1.2,fgcolor=IIf(Buy,colorWhite,colorWhite),bkcolor=IIf(Buy,colorGreen,colorRed));
AddColumn(C,"Close",1.2,fgcolor=IIf(Buy,colorWhite,colorWhite),bkcolor=IIf(Buy,colorGreen,colorRed));
AddColumn(V,"Volume",1,fgcolor=IIf(Buy,colorWhite,colorWhite),bkcolor=IIf(Buy,colorGreen,colorRed));
//AddColumn(WT1,"WaveTrend 1",1);
//AddColumn(WT2,"WaveTrend 2",1);
AddColumn(IIf(Buy,'B','S'),"Signal",formatChar,fgcolor=IIf(Buy,colorWhite,colorWhite),bkcolor=IIf(Buy,colorGreen,colorRed));
AlertIf(Buy,"SOUND c:\\Windows\\Media\\tada.wav","Audio Alert",1);
AlertIf(Sell,"SOUND c:\\Windows\\Media\\tada.wav","Audio Alert",2);

I would really appreciate any help on this. Thanks.
 
Hello Friends

I am starting this thread for helping anyone who requires small changes in AFLs or AFL coding done for small / simple requirements that can be clearly defined.

What does not go is conversion . . . from Amibroker to anything else . . . or from anything else to Amibroker . . .

Debugging requested for copy/paste AFLs, Please don't post huge AFLs with zillions of lines of code for debugging

I will not be available for any conversions and I am not interested in debugging some-one else's copy/pasted work and lastly . . .
Not interested in hacking/craking any ones work . . .

Only if have a clearly definable task to be coded I maybe able to help . . . No Promises but will try within my limitations . . .


As an example, recently one of our friends wanted a motivational message to be included in his Charts,
I enjoyed doing that, as i could easily empathize with why he wanted that . . .


Cheers

:) Happy
Hello sir, I'm hoping you can please assist me please.

I am simply trying to create a BUY signal when the current bar CLOSES 50% or below from the previous bar.


I thought maybe averaging out the previous bar might work but I'm so lost. hoping someone can help please.

Buy = Ref ((h - l)/ L ,-1)*100;
 

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
 

Similar threads