AFL code for Candle

#11
x is an array storing True or False i.e One or Zero, that is what you are getting, right or wrong your decision . . .

Happy :)
 

MSN1979

Well-Known Member
#12
Sir, it is giving 1 n 0 for true n false condition :)

Hi romeo thanx so its a Boolean operator, so we have 1 and 0 this part is clear. Now even if its a Boolean operator why we only have 5 values? If we look above the chart posted above value of x changed much more then 5 times? ( I am saying this by the number of times it has plotted the dots on chart)
 

Romeo1998

Well-Known Member
#13
Sir, its bcoz of the periodicity selected in exploration, periodicity in exploration seems to be Daily n chart is of 5 mins, hence chart has more dots n exploration has only 5 values
 

MSN1979

Well-Known Member
#14
This code is posted by Josh on Vijay Thread. It has few errors. It should only print a pivot if
1543043352450.png

first candle high is taken out by "n" number of candles. and only after second high is broken it should print a minor pivot low, exactly same for pivot highs.

Also in case a pivot is taken out directly by 1 candle then also it should print a pivot. I would request Happy and Romeo to look into this.


_SECTION_BEGIN("Trading System - Parameters");

pivotoff = ParamToggle("Pivot Off","No|Yes",0);

if (pivotoff == 0) {

SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", colorWhite, styleNoTitle | styleCandle);
SV_LP=Param("Lookback Period for pivot?",4,2,50,1);
PH = H > Ref(HHV(H,SV_LP),-1) AND Ref(HHV(H,SV_LP),SV_LP)<=H;
PHP = ValueWhen(PH,H);
PL = L < Ref(LLV(L,SV_LP),-1) AND Ref(LLV(L,SV_LP),SV_LP)>=L;
if(ParamToggle("Suppress Successive Same Pivots?","No,Yes")){
PH = ExRem(PH,PL);
PL = ExRem(PL,PH);
}
if(ParamToggle("Plot Pivots?","No,Yes",1)){
PlotShapes(IIf(PH,shapeSmallCircle,shapeNone),colorGreen,0,H,12);
PlotShapes(IIf(PL,shapeSmallCircle,shapeNone),colorRed,0,L,-12);
}
}
_SECTION_END();

/*************************End of Pivot Breakout System***************************/
_N(Title = StrFormat(EncodeColor( colorPaleGreen ) + "{{NAME}} - {{INTERVAL}} {{DATE}} " + " Open %g," + " Hi %g, "
+ " Lo %g, " + " C %g {{VALUES}}", O, H, L, C )
+EncodeColor( colorRed ) + "\n"+", LH = " + NumToStr(Ref(H,-1), 1.4) + ", LL = "
+ NumToStr(Ref(L,-1), 1.4) + ", LH2 = " + NumToStr(Ref(H,-2), 1.4) + ", LL2 = " + NumToStr(Ref(L,-2), 1.4));
 

mastermind007

Well-Known Member
#15
Storing of data is handled by Amibroker. you need to simply use the data array....

One way to see five min candle on 1 min chart is follows

Minx = Minute();

fiveMin = (Minx % 5) == 0;

fiveMinOpn = ValueWhen(fiveMin, Open);
fiveMinHgh = Iif(fiveMin, High, HHV(High , BarsSince(fiveMin) + 1));
fiveMinLow = IIf(fiveMin, Low , LLV(Low , BarsSince(fiveMin) + 1));
fiveMinCls = ValueWhen(fiveMin, Close);
 

mastermind007

Well-Known Member
#16
To test whether it breaches five min low, you can write....
lowbreached = Low < fiveMinLow;

If you want value of low that broke the price, you need to write

breaker = IIf(Low < fiveMinLow, Low, Null);

If you mix and match array variables and scaler variables, amibroker will whine sometimes but most of the time it will hide the error and slow down the execution
 

doss186

Well-Known Member
#17
No Bro

On 5 min chart we have
What I mean is at 9:15 we have first candle. Second candle starts at 9:20 and ends at 9:25. So I would simply like to store data for both 5 min candles and compare its OHLC values.
If you want to store the difference between 5min candle you have to define what is firstbar, secondbar and so on.
I think you meant is this?
 

Attachments

MSN1979

Well-Known Member
#18
If you want to store the difference between 5min candle you have to define what is firstbar, secondbar and so on.
I think you meant is this?
yes this is great. my end result is DYNAMICALLY compare candles till I have the following result and keep repeating it till end of day with marking pivots of all charts. If you need more understanding , I am trying to code Vijay break of 3 bar method called as pivot.

For plotting MPL - Minor Pivot low on chart on 5 min chart

IF First candle high is broken by 2nd candle OR n number of candles.
And 2nd high is broken by 3rd candle or subsequent number of n candles
OR
Last mph is directly taken out even by 1 or 2 candles then also low should be mpl or Pivot Low

For Plotting MPH - Minor Pivot High
IF First candle LOW is broken by 2nd candle OR n number of candles.
And 2nd Candle Low is broken by 3rd candle or subsequent number of n candles
OR
Last mpl is directly taken out even by 1 or 2 or n number of candles then also low should be mph or Pivot High
 
Last edited: