I am trying to get this formula to work. A trade triggers when the ma slope is above 15, and below 15. The problem is that within a period the slope can reach the values, and before the period is over, it goes back, and the trade is no longer valid. I also use this as a trigger for an autotrader, and also have the problem that a trade is trigged in the middle of a period, and at the end of period the trade is no longer valid. I have tried to cange the MA (0) and (-1) to (-1) and (-2), but i get wrong values and to late triggers. Is it any way to solve this, so it trigges at the open of a new period if the slope value is correct at the close of prvious period without using computeOnClose. Can anyone help please? Thanks.
Announcement
Collapse
No announcement yet.
Please help with formula
Collapse
X
-
karfhans
To avoid false intrabar siignals compute the value of the variable Slope_1 on completed bars only.
To do this enclose the calculation of Slope_1 in a if(getBarState()==BARSTATE_NEWBAR) conditional statement and subtract the value of the study at the prior bar from that of two bars ago instead of the current bar's value from the prior bar's value (see example in the enclosed image).
Alex
Comment