Hi - How about something like this? Not tested... Sys1Buy= Cross(Trend,0); Sys1Sell=Cross(0, Trend); Sys1In = Flip( Sys1Buy, Sys1Sell ); Sys1Out = NOT Sys1In;
Sys2Buy = Cross( Close ,TrailStop ); Sys2Sell = Cross( TrailStop ,Close); Sys2In = Flip( Sys2Buy, Sys2Sell ); Sys2Out = NOT Sys2In; Buy = ( Sys1In AND Sys2Buy ) OR ( Sys2In AND Sys1Buy ); Sell = ( Sys1Out AND Sys2Sell ) OR ( Sys2Out AND Sys1Sell ); Might need to Exrem after... Steve ----- Original Message ----- From: ziad aljalsi To: [email protected] Sent: Saturday, September 22, 2007 2:18 PM Subject: [amibroker] hlep me in this formula i have vere nice formula it give me buy and sell signal i added 3 formula in one so it give me nice rusalt i am not belive the buy or sell signal until boht of conditon give me buy or sell some time both of them give me buy in same day so i blive it but if one of them give me buy and other conditon was still in sell positon i dont want to see buy signal untial the other give buy and i do not want to see any buy or sell untill both are in same position exampl: first conditon give buy signal today and other conditon stell in sell position do not show any buy signal . until the secand give buy then put the buy signal in the day wich second is give the buy and the sell also. here is the formula and i make red high light on what i want _SECTION_BEGIN("VOLATILITY SYSTEM"); EntrySignal = C > ( LLV( L, 20 ) + 2 * ATR( 10 ) ); ExitSignal = C < ( HHV( H, 20 ) - 2 * ATR( 10 ) ); Color = IIf( EntrySignal, colorBlue, IIf( ExitSignal, colorOrange, colorGrey50 )); TrailStop = HHV( C - 2 * ATR(10), 15 ); ProfitTaker = EMA( H, 13 ) + 2 * ATR(10); /* plot price chart and stops */ Plot( TrailStop, "Trailing stop", colorBrown, styleThick | styleLine ); Plot( ProfitTaker, "Profit taker", colorLime, styleThick ); Plot( C, "Price", Color, styleBar | styleThick ); /* plot color ribbon */ Plot( 1, "", Color, styleArea | styleOwnScale | styleNoLabel, -0.1, 50 ); _SECTION_END(); _SECTION_BEGIN("good"); period = Param("Period", 13, 1, 240, 1); mult = Param("Multiplier", 1.7, 1, 240, 0.1); f=ATR(period); VS[0] = Close[0]; trend[0] = 0; HighC[0]=0; Lowc[0]=0; for( i = period+1; i < BarCount; i++ ) { vs[i] = vs[i-1]; trend[i] = trend[i-1]; highC[i] = HighC[i-1]; lowc[i] = lowc[i-1]; if ((trend[i]>=0) && ( C[i] <VS[i] )) { trend[i] =-1; HighC[i] = C[i]; lowc[i] = C[i]; } if ((trend[i]<=0) && (C[i] >VS[i])) { trend[i]=1; HighC[i] = C[i]; lowc[i] = C[i]; } if (trend[i]==-1) { if (C[i]<lowc[i]) lowc[i] = C[i]; VS[i]= lowc[i]+ (mult*f[i]); } if (trend[i]==1) { if (C[i]>HighC[i]) HighC[i] = C[i]; VS[i]= HighC[i]-(mult*f[i]); } } Buy= Cross(Trend,0) +Cross( Close ,TrailStop ); Sell=Cross(0, Trend) + Cross( TrailStop ,Close); Plot( C, "Close", ParamColor("Color", colorBlack), ParamStyle("Styel",styleLine,styleCandle|styleBar|styleThick)); Plot(VS, "Vol Stop",IIf(trend==1,10,11 ),styleThick); mkol = IIf( Trend==1, 10, 11); Plot(5, "ribbon", mkol, styleNoRescale|styleArea|styleNoLabel, 0, -5); // Weekly trend PlotShapes((Buy*1)+(Sell*2),IIf(Buy,colorGreen,colorRed) ); shape = Buy * shapeUpArrow + Sell * shapeDownArrow; // Suppor / Resistance Lines // zezo July-23-2007 //******************************** _SECTION_BEGIN("Price"); SetChartOptions(0,chartShowArrows|chartShowDates); if ( ParamToggle("Tooltip shows", "All Values|Only Prices" ) ) { ToolTip=StrFormat("Open: %g\nHigh: %g\nLow: %g\nClose: %g (%.1f%%)\nVolume: "+NumToStr( V, 1 ), O, H, L, C, SelectedValue( ROC( C, 1 ))); } Plot( C, "Close", ParamColor("Color", colorBlack), ParamStyle("Styel",styleLine,styleCandle|styleBar|styleThick)); _SECTION_END(); _SECTION_BEGIN("Sup / Res Lines"); SRswitch = ParamToggle("Sup / Res Lines","On,Off"); CHLswitch = ParamToggle("Hi Low / Close","Hi Low,Close"); NoLines = Param("No of Lines",1,1,30,1); Sen = Param("Sensitivity",.01,.01,100,.01); Rcolor=ParamColor( "Res Color", colorRed ); Rstyle=ParamStyle( "Res Style", styleLine); Scolor=ParamColor( "Sup Color", colorLime ); Sstyle=ParamStyle( "Sup Style", styleLine ); y=0; x=0; for( i = 1; i < NoLines+1 ; i++ ) { Y[i]=LastValue(Peak(IIf(CHLswitch,C,H),Sen,i)); x[i]=BarCount - 1 - LastValue(PeakBars(IIf(CHLswitch,C,H),Sen,i)); Line = LineArray( x[i], y[i], Null, y[i], 1 ); Plot( IIf(SRswitch,Null,Line), "", Rcolor, Rstyle ); Y[i]=LastValue(Trough(IIf(CHLswitch,C,L),Sen,i)); x[i]=BarCount - 1 - LastValue(TroughBars(IIf(CHLswitch,C,L),Sen,i)); Line = LineArray( x[i], y[i], Null, y[i], 1 ); Plot( IIf(SRswitch,Null,Line), "", Scolor, Sstyle ); } _SECTION_END(); Chng = StrFormat("Change (%.2f%)", C - Ref(C,-1)); Per = StrFormat(" Per: (%.1f%%)", SelectedValue( ROC( C, 1 ))); Title = Name() + " {{INTERVAL}}" + " " + Date() + EncodeColor( colorBlack ) + " Open: " + O + EncodeColor( colorDarkGreen ) + " High: " + H + EncodeColor( colorDarkRed ) + " Low: " + L + EncodeColor( colorDarkBlue ) + " Close: " + C + EncodeColor( colorBlack ) + " Vol: " + WriteVal( V, 1.0 ) + "\n" + Chng + Per + " " + EncodeColor( colorBlack ) + FullName(); Send instant messages to your online friends http://uk.messenger.yahoo.com
