Thank you very much Mike, I take hard time with it. Thanks again Regards
--- In [email protected], "Mike" <sfclimb...@...> wrote: > > > Hi, > > After a quick test, I believe that comparing the SelectedValue of > BarSinceCrossgreen vs. BarSinceCrossred will give you what you want. > Basically, you want to know which occured most recently (i.e. which has > had fewer bars pass since it happened). > > One_Houre_Green_Cross = Cross( MACD(), Signal() ); > One_Houre_Red_Cross = Cross( Signal(), MACD() ); > BarSinceCrossgreen = BarsSince( One_Houre_Green_Cross ); > BarSinceCrossred = BarsSince( One_Houre_Red_Cross ); > BarSinceCrossUp = StrFormat( " %g ", BarSinceCrossgreen, SelectedValue( > ROC( C, 1 ) ) ); > BarSinceCrossDown = StrFormat( " %g ", BarSinceCrossred, SelectedValue( > ROC( C, 1 ) ) ); > > GfxSelectFont( "Arial", 12, 700 ); > GfxSetBkMode( 1 ); > pxHeight = Status( "pxchartheight" ); > t = pxHeight; > x5 = 101; > > if ( SelectedValue( BarSinceCrossGreen ) < SelectedValue( > BarSinceCrossRed ) ) > { > offset = 50; > GfxSetTextColor( colorGreen ); > GfxTextOut( BarSinceCrossUp, x5, t - offset ); > } > else > { > offset = 25; > GfxSetTextColor( colorRed ); > GfxTextOut( BarSinceCrossDown, x5, t - offset ); > } > > GfxSelectFont( "Arial", 9, 700 ); > GfxSetTextColor( colorWhite ); > > Bar = "Bar"; > x4 = 78; > > GfxTextOut( Bar, x4, t - offset ) ; > > > Mike > > > --- In [email protected], "Mohammed" <softnews2003@> wrote: > > > > Hi Mike, > > > > I try the code you provide here, But I'm not able to add it as part of > my other code. > > > > Can u help please. > > > > Thanks an advince > > > > > > --- In [email protected], "Mohammed" softnews2003@ wrote: > > > > > > Hi Mike, > > > > > > I appreciated your reply. I will try that. > > > > > > > > > Thanks again. > > > Regards > > > > > > > > > --- In [email protected], "Mike" <sfclimbers@> wrote: > > > > > > > > Try something like the following (untested) > > > > > > > > if (LastValue(BarsSinceCrossedGreen) < > LastValue(BarsSinceCrossedRed)) { > > > > // Last cross ever was up > > > > } else { > > > > // Last cross ever was down > > > > } > > > > > > > > Or possibly > > > > > > > > if (SelectedValue(BarsSinceCrossedGreen) < > SelectedValue(BarsSinceCrossedRed)) { > > > > // Last cross up to selection was up > > > > } else { > > > > // Last cross up to selection was down > > > > } > > > > > > > > Mike > > > > > > > > --- In [email protected], "Mohammed" <softnews2003@> > wrote: > > > > > > > > > > > > > > > Hi all, > > > > > > > > > > For the following code I'm using two values to show the number > of bars > > > > > since MACD cross. One value for up and one for down. These > values > > > > > showing both in the chart page, I would like to show only the > last > > > > > values depending to cross if the cross up I need to show the > values for > > > > > up and if it for down cross I need to show the value for down > only. > > > > > Instead of showing both values. > > > > > > > > > > One_Houre_Green_Cross = Cross(MACD(), Signal()); > > > > > One_Houre_Red_Cross = Cross(Signal(), MACD()); > > > > > BarSinceCrossgreen = BarsSince( One_Houre_Green_Cross); > > > > > BarSinceCrossred = BarsSince( One_Houre_Red_Cross); > > > > > BarSinceCrossUp = StrFormat(" %g ", BarSinceCrossgreen, > SelectedValue( > > > > > ROC( C, 1 ) ) ); > > > > > BarSinceCrossDown = StrFormat(" %g ", BarSinceCrossred, > SelectedValue( > > > > > ROC( C, 1 ) ) ); > > > > > > > > > > GfxSelectFont( "Arial", 12, 700 ); > > > > > GfxSetBkMode( 1 ); > > > > > GfxSetTextColor( colorGreen); > > > > > pxHeight = Status( "pxchartheight" ); > > > > > t = pxHeight; > > > > > x5 = 101; > > > > > > > > > > GfxTextOut( BarSinceCrossUp, x5, t -50); > > > > > GfxSetTextColor( colorRed); > > > > > GfxTextOut( BarSinceCrossDown, x5, t -25); > > > > > GfxSelectFont( "Arial", 9, 700 ); > > > > > GfxSetTextColor( colorBlack); > > > > > > > > > > Bar = "Bar"; > > > > > x4 = 78; > > > > > > > > > > GfxTextOut( Bar, x4, t -50) ; > > > > > GfxTextOut( Bar, x4, t -25) ; > > > > > > > > > > Any one can help please. > > > > > Regards > > > > > > > > > > > > > > >
