Require modification of this code

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:

  1. The buy and sell prices appear at the PRESENT BAR, though the signals appear at the back.
  2. Another set of fresh signals appear at the PRESENT or FOLLOWING BAR, after the appearance of backward signals.
  3. 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();

Just great. Posting code from who-knows-where. Without reference to original author
and wanting somebody to write modifications for you for nothing.

Hire programmer and pay him. You are not going to get everything for free.

Besides, the code you got from “nowhere” is wrong. It includes basic coding mistakes mentioned in the manual: http://www.amibroker.com/guide/a_mistakes.html
and overall the formula is pretty much useless. I can see that the formula is a patchwork of many little pieces taken from others put together but somebody who does not have any clue of what he/she is doing. Trading such rubbish would be suicide.

3 Likes