please suggest something about this problem(same value for everybar from time2)
@sandeep.sd9 I am deliberately not providing code for all of your questions because I want you to think about the problem and work your way through it. If you don't put the effort into doing that, you will never become a self-sufficient AFL developer. If you prefer to have someone else do all the development work for you, then I suggest you find a reliable contractor and pay them to do it.
In this particular case, I think that all you need to do is change this:
PlotShapes(IIf(val >= MovingAvg, shapeUpArrow, shapeNone),colorRed, 0, L);
PlotShapes(IIf(H-L>= MovingAvg, shapeUpArrow, shapeNone),colorRed, 0, L);
In other words, you should be looking at the range of the current bar, not the range of the most recent bar with timestamp time2.
This is my final code moving average is correct and range is also correct but my plot shape is fluctuating
plz help me how to make it static
ParamRange = Param("MovingRange",15,5,500,1);//read the data from user
ParamPercentHigh = Param("HighPercent",1,0.25,6,0.01);
ParamPercentLow = Param("LowPercent",1,0.25,6,0.01);
time = TimeNum(); // intializing all time from chart
LastVisibleTime = Ref(SelectedValue(time),0);
RangeVal = ValueWhen(TimeNum()==LastVisibleTime ,H-L);// value fromm specific time
Range = TimeFrameCompress(RangeVal , inDaily);//select single bar from every day and compress it
MovingAvg =MA(range,ParamRange );// periods to be calculate.
MovingAvgExpand = TimeFrameExpand(MovingAvg, inDaily);//expand the compress bar for display the
value of bar
//_TRACE("MovingAvg "+MovingAvgExpand );
//_TRACE("BarRange " +RangeVal );
HighCondition=RangeVal >= ParamPercentHigh *MovingAvgExpand ;//condtion for ploting
LowCondition=RangeVal <= ParamPercentLow *MovingAvgExpand ;
PlotShapes(IIf(HighLowExrem, shapeHollowStar, shapeNone), colorGreen,0, L);//ploting shape
@sandeep.sd9 please tell me what you're trying to do here:
HighCondition=RangeVal >= ParamPercentHigh *MovingAvgExpand ;//condtion for ploting LowCondition=RangeVal <= ParamPercentLow *MovingAvgExpand ; HighLowExrem=ExRem(HighCondition,LowCondition);
Because I doubt that this code is doing what you want.
code is working fine i have calculated manually values they are matching
I have problem only while plotting
my plot shape is fluctuating plz help me to make it static
Glad you figured it out @sandeep.sd9. Forum members would probably appreciate it if you posted your final solution.
@mradtke This is My final solution
RangeVal35 =0;//intialization MovingAvg35 =0; RangeVal35 =ValueWhen(TimeNum()== 121959,H-L); Range35 = TimeFrameCompress(RangeVal35 , inDaily);//select single bar from every day and compress it MovingAvg35 =MA(Range35 ,5 );// periods to be calculate. MovingAvgExpand35 = TimeFrameExpand(MovingAvg35, inDaily);//expand the compress bar for display the value of bar _TRACE("MovingAvgExpand35 "+MovingAvgExpand35 ); _TRACE("RangeVal35 " +RangeVal35 ); HighCondition35=RangeVal35 >=MovingAvgExpand35 ;//condtion for ploting PlotShapes(IIf(HighCondition35 AND TimeNum()== 121959,shapeUpArrow, shapeNone), colorGreen,0, L);//ploting shape