Hello
Also Me I have a Question here that is about the " XShift " I would like to project into future from last Bar. Below is the code . how can we do that?
@ Milosz I start this code few weeks ago and I was interesting about the Xshift and not for the main code but yes right SelectedValue(BI)
@ Alan try this. diff = ( stop - start); "\ndiff Bi to Bi "+ WriteVal(diff);
Apparently we are going to answer slow-slow all the questions that Posted by: abdullahalrafee1, with this conversation, and I really like that.
fxshrat wrote: "using SetBarsRequired( sbrall, sbrall ); just makes code slow because of using all bars"
First of all… yes FX he is right. But all of us we know that about SetBarsRequired(). I think?
And I really like him answer my question.
For example, if my selected area from point A to point B is 1000 bars before the last bar. And now I like to Zoom maybe to 150 visible bars and also to press key "END" to see the future bars. How can I do this without not using SetBarsRequired()?
Thanks in advance
Panos
// Panos-travelToTheFuture.afl Mod by fxshrat
// this version contain SparseCompress function
SetChartOptions(0,chartShowArrows|chartShowDates);
Plot( C, "Price", colorGrey50, stylebar ) ;
///////////Find the Start and End barindex by pressed by CLR or Shift + Left mouse Click////////////
B = GetCursorMouseButtons();
Control_Pressed = GetAsyncKeyState( 17 ) < 0; // CONTROL key pressed,
Shift_Pressed = GetAsyncKeyState( 16 ) < 0; // Shift key pressed,
bi=BarIndex(); Lbi =LastValue(bi);
if( B & 1 AND CONTROL_Pressed )
{
StartBi = SelectedValue( BI );
StaticVarSet( "StartBi" + getchartid(), StartBi ) ;
}
if( B & 1 AND Shift_Pressed )
{
endBi = SelectedValue( BI );
StaticVarSet( "endBi" + getchartid(), endBi );
}
if ( B & 4) { StaticVarRemove("*Bi"+ getchartid()); }
//////////////////////////////////////////////////////////
start = StaticVarGet( "StartBi" + getchartid() );
stop = StaticVarGet( "endBi" + getchartid() );
qfdb = Status( "quickaflfirstdatabar" );
printf( "startBi: %g\nendBi: %g", (qfdb + start), (qfdb + stop) );
Plot( bi == start, "StartBI", colorgreen, styleHistogram | styleDashed | styleOwnScale | styleNoLabel ); // start bar styleHistogram
Plot( bi == stop, "stopBI", colorred, styleHistogram | styleDashed | styleNoLabel | styleOwnScale ); // End bar styleHistogram
_N(title= Name() +","+Date()+", Chart Interval: " + Interval(2)+"\n Open "+O +", High " +H +", Low "+L +", Close "+C+ ", "+"(" +WriteVal(ROC(C,1),1.2)+"%)" +", Spread " + WriteVal((H-L)/TickSize ,1)) ;
diff = ( stop - start); "\ndiff Bi to Bi "+ WriteVal(diff); // for Alan BarsDifference
/// Find The First Bar of the Day In intraday and plot Vertical Line
NewDay = IIf( Interval() < inDaily, Day(), Month() );
NewDay = NewDay != Ref( NewDay , -1 );
Plot(NewDay, "", colorGrey40, styleHistogram | styleOwnScale );
/////////////////SparseCompress By Aron///////////////////////
Segment = BarIndex() > start AND BarIndex() < stop ;
x = SparseCompress( Segment, C ); // Returns the Close Of the Selected Area
// // attempt XShift from selected Bar or Newday or LastBar
Plot ( x , "", colorBlue, styleline ,0,0, LastValue(NewDay,True) );
On 06-03-16 6:42 PM, Alan alan@thenorthams.us [amibroker] wrote:
So if I wanted to use this code to perform some function like find the difference between the two prices I would use for variables
"bi == start" as one variable and "bi == stop" as the second variable and subtract the two like this: diff = bi == stop - bi == start. Is this correct?
On 3/6/2016 11:45 AM, fxshrat wrote:
That code has some flaws/overkills
overkill:
using SetBarsRequired( sbrall, sbrall ); just makes code slow because of using all bars
If you want to know overall bi in Information window then use status( "quickaflfirstdatabar" )
Like so,
qfdb = status( "quickaflfirstdatabar" );
printf( "startBi: %g\n
endBi: %g", (
qfdb + start), (qfdb + stop) );
Then you don't require SetBarsRequired(sbrall)
coding flaws:
using LastValue( SelectedValue( bi ) )
just use SelectedValue( bi )
since both LastValue and SelectedValue are used on arrays but not on scalars.
Using both together makes not sense.
some other note
IIf(bi==start,1,0) can be repalced by just using bi == start (same for stop)
StaticVarSet( "StartbarBi"+getchartid(), SelectedValue(BI)) is never called by any StatiVarGet.
So it is code cadaver, so to say. So it can be removed. It just confuses.
![]()
![]()
Posted by: Panos Boufardeas <panosbouf@gmail.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (10) |
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
EmoticonEmoticon