Hello everyone,
This particular code i got it over the internet. It looks backward, hence the signals appear after some time.
Would some one be able to modify this code, so as to:
- The buy and sell prices appear at the PRESENT BAR, though the signals appear at the back.
- Another set of fresh signals appear at the PRESENT or FOLLOWING BAR, after the appearance of backward signals.
- or at least the buy and sell prices are sent from the present bar, for AUTOMATED TRADING to work.
thanks in advance.
here is the code
_SECTION_BEGIN("Price");
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", ParamColor("Color", colorRed ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
_SECTION_BEGIN("Marva Mid R-Line Signal");
x = Cum(1);
lastx = LastValue( x );
Daysback = 10;
aa = LastValue( LinRegIntercept( Close, Daysback) );
bb = LastValue( LinRegSlope( Close, Daysback ) );
y = Aa + bb * ( x - (Lastx - DaysBack) );
//Plot( Close, "Close", colorRose, styleCandle );
Plot( IIf( x >= (lastx - Daysback), y, -1e10 ), "LinReg", colorYellow );
per1=Param ("per1", 0.325,0.1,50,0.10);
perc=per1;
x1=BarIndex();xx=SelectedValue(x);
t1=SelectedValue(ValueWhen(PeakBars(C,perc)==0,x)) ;
H1=SelectedValue(ValueWhen(PeakBars(C,perc)==0,C)) ;
t11=SelectedValue(ValueWhen(TroughBars(C,perc)==0, x));
H11=SelectedValue(ValueWhen(TroughBars(C,perc)==0, C));
g=t1>t11;
shape=IIf(g,shapeDownTriangle*(x==t1),shapeUpTriangle*(x ==t11));
Color=IIf(g,colorRed,colorBrightGreen);
PlotShapes(shape,color);
Buy= (x=t1);
Sell= (x=t11);
AlertIf( Buy , "SOUND C:\\Windows\\Media\\Ding.wav", "Audio alert", 2 );
AlertIf(Sell , "SOUND C:\\Windows\\Media\\Ding.wav", "Audio alert", 2 );
_SECTION_END();