Slight disappointment this morning.
My nice formula is not as efficient in real time due to 
RequestTimedRefresh random interval.
 From time to time, there is a lag between the click and the code 
action, execution/reaction times are better in static usage (not in RT).

LButtonTrigger = GetCursorMouseButtons() & 1; seems better than & 9

I'am looking for AB built-in improvements better than CTRL R.




reinsley a écrit :
> Thank you Ed, I learn by small step.
> 
> Here is the application that is easier to use than CTRL R.
> 
> It seems that I can't store the default value to retrieve it at the 
> openning, I need a click to display Fibo lines.
> 
> Next evolution will be to use the same formula in two panes without 
> interaction between the vars.
> 
> Best regards
> 
> // Fibonacci with GFX adjustment
> 
> /*
> Fibonacci with GFX adjument by two buttons in right margin
> Easier to use than AB parameters windows.
> Set "Blank bars in the right margin = 10"
> to avoid the following SetChartOptions
> 
> //SetChartOptions( 2, chartHideQuoteMarker );
> 
> */
> 
> RequestTimedRefresh( 1 );
> 
> SetChartBkColor(49);
> 
> function DrawButton( Text, x1, y1, x2, y2, BackColor )
> {
>      GfxSetOverlayMode( 0 );
>      GfxSelectFont( "Tahoma", 12, 800 );
>      GfxSelectPen( colorBlack );
>      GfxSetBkMode( 1 );
>      GfxSelectSolidBrush( BackColor );
>      GfxSetBkColor( BackColor );
>      GfxSetTextColor( 1 );
>      GfxRectangle( x1, y1, x2, y2 );
>      GfxDrawText( Text, x1, y1, x2, y2, 32 | 1 | 4 );
> }
> 
> step = 0.05;
> 
> pds = Param("pds", 0.30, 0.05, 5, 0.05);
> StaticVarSet("pds", pds);
> sDefaultValue= Nz(StaticVarGet("pds"));
> /*
> sDefaultValue = StaticVarGet ( "sDefaultValue" );
> StaticVarSet( "sDefaultValue", 0.30 ); // medium value in 5 minutes 
> timeframe
> 
> _TRACE("sDefaultValue= "+sDefaultValue);
> */
> 
> pxchartwidth = Status( "pxchartwidth" );
> shiftM = 40;
> XOffset  = StaticVarGet( "XOffset" );
> YOffset  = StaticVarGet( "YOffset" );
> XOffset  = pxchartwidth - shiftM ; // X1 minus button
> YOffset  = 0;//Y1 minus button
> SquareSide = 20;
> X1m = XOffset  ;
> X2m = Xoffset + SquareSide ;
> Y1m = YOffset  ;
> Y2m = yOffset + SquareSide ;
> // Draw Minus Button
> DrawButton( "-", Xoffset, yOffset, Xoffset + SquareSide , yOffset + 
> SquareSide , colorRed );
> 
> shiftP = 17;
> XOffsetP  = StaticVarGet( "XOffset" );
> YOffsetP  = StaticVarGet( "YOffset" );
> XOffsetP  = pxchartwidth - shiftP ; // X1 plus button
> YOffsetP  = 0;//Y1 plus button
> X1p = XOffsetP  ;
> X2p = XoffsetP + SquareSide ;
> Y1p = YOffsetP  ;
> Y2p = yOffsetP + SquareSide ;
> // Draw Plus Button
> DrawButton( "+", XoffsetP, yOffsetP, XoffsetP + SquareSide , yOffsetP + 
> SquareSide , colorGreen );
> 
> //LButtonTrigger = GetCursorMouseButtons() & 1;
> LButtonTrigger        = GetCursorMouseButtons() == 9;
> numClicks = Nz( StaticVarGet( "counter" ), sDefaultValue );
> 
> if ( LButtonTrigger )
> {
>      MousePx  = Nz( GetCursorXPosition( 1 ) );
>      MousePy  = Nz( GetCursorYPosition( 1 ) );
> 
>      CursorInMinus = MousePx > X1m AND MousePx < X2m AND MousePy > Y1m 
> AND MousePy < Y2m;
>      CursorInPlus = MousePx > X1p AND MousePx < X2p AND MousePy > Y1p 
> AND MousePy < Y2p;
> 
>      if ( CursorInMinus )
>      {
>          DrawButton( "-", Xoffset, yOffset, Xoffset + SquareSide , 
> yOffset + SquareSide , colorYellow );
>          StaticVarSet( "counter", numClicks - step   );
>      }
> 
>      if ( CursorInPlus )
>      {
>          DrawButton( "+", XoffsetP, yOffsetP, XoffsetP + SquareSide , 
> yOffsetP + SquareSide , colorYellow );
>          StaticVarSet( "counter", numClicks + step   );
>      }
> }
> 
> //Title = "Clicks Counter: " + StaticVarGet( "counter" );
> 
> _SECTION_BEGIN( "Price" );
> //_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} \nOp %g, \nHi 
> %g, \nLo %g, \nCl %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( 
> ROC( C, 1 ) ) ));
> Plot( C, "Close", ParamColor( "Color", colorBlack ), styleNoTitle | 
> styleCandle  | styleThick );
> _SECTION_END();
> 
> _SECTION_BEGIN( "Fibonacci" );
> //Offset = 5; //use two sheets: one with 5 and another with 7, or maybe 
> other offset value
> //Avgmov = Offset * MA( abs( ROC( C, 1 ) ), 20 );
> //per = LastValue( Avgmov );//original value
> per = StaticVarGet( "counter" );//Param( "Pivot %", 0.3, 0.05, 6, 0.05 );
> _TRACE("per = "+per );
> x = Cum( 1 );
> Range = 0.01;
> PS = TroughBars( L, per, 1 ) == 0;
> xa = LastValue( ValueWhen( PS, x, 1 ) );//x from last trough
> Ya = LastValue( ValueWhen( PS, L, 1 ) );//y (Low) last trough
> PR = PeakBars( H, per, 1 ) == 0;
> xb = LastValue( ValueWhen( PR, x, 1 ) );//x from last peak
> Yb = LastValue( ValueWhen( PR, H, 1 ) );//y (High) last peak
> Trough_ReTest = abs( ( L / ya ) - 1 ) < Range;
> Peak_ReTest = abs( ( H / yb ) - 1 ) < Range;
> Trough_Cross = Cross( ya, C );
> Peak_Cross = Cross( C, yb );
> 
> //UP = upSwing DN = downSwing
> UP = xb > xa;
> //upSwing
> DN = xa > xb;
> //DownSwing
> 
> 
> RT23_6 = IIf( UP, yb - ( yb - ya ) * 0.236, IIf( DN, ya + ( yb - ya ) * 
> 0.236, -1e10 ) );
> 
> RT38_2 = IIf( UP, yb - ( yb - ya ) * 0.382, IIf( DN, ya + ( yb - ya ) * 
> 0.382, -1e10 ) );
> 
> RT50_0 = IIf( UP, yb - ( yb - ya ) * 0.500, IIf( DN, ya + ( yb - ya ) * 
> 0.500, -1e10 ) );
> 
> RT61_8 = IIf( UP, yb - ( yb - ya ) * 0.618, IIf( DN, ya + ( yb - ya ) * 
> 0.618, -1e10 ) );
> 
> RT78_6 = IIf( UP, yb - ( yb - ya ) * 0.786, IIf( DN, ya + ( yb - ya ) * 
> 0.786, -1e10 ) );
> 
> RT127_2 = IIf( UP, yb - ( yb - ya ) * 1.272, IIf( DN, ya + ( yb - ya ) * 
> 1.272, -1e10 ) );
> 
> RT161_8 = IIf( UP, yb - ( yb - ya ) * 1.618, IIf( DN, ya + ( yb - ya ) * 
> 1.618, -1e10 ) );
> 
> //RT261_8 = IIf( UP, yb - ( yb - ya ) * 2.618, IIf( DN, ya + ( yb - ya ) 
> * 2.618, -1e10 ) );
> 
> RT = IIf( UP, -100 * ( yb - L ) / ( yb - ya ), 100 * ( H - ya ) / ( yb - 
> ya ) );//Retracement_Value
> 
> InZone = C<yb & C>ya;
> 
> Plot( IIf( x > xa, ya, -1e10 ), "", colorBrown, 1 + 8 );//"Bottom"
> Plot( IIf( x > xb, yb, -1e10 ), "", colorBrown, 1 + 8 );//"Top"
> 
> xab = IIf( xb > xa, xb, xa );
> 
> //Retracements
> 
> Plot( IIf( x >= xab + 1, RT23_6, -1e10 ), "", colorWhite, 1 );//"23,6% 
> Retr."
> 
> Plot( IIf( x >= xab + 1, RT38_2, -1e10 ), "", colorGreen, 1 );//"38,2% 
> Retr."
> 
> Plot( IIf( x >= xab + 1, RT50_0, -1e10 ), "", colorYellow, 1 );//"50,0% 
> Retr."
> 
> Plot( IIf( x >= xab + 1, RT61_8, -1e10 ), "", colorRed, 1 + 8 );//"61,8% 
> Retr."
> 
> Plot( IIf( x >= xab + 1, RT78_6, -1e10 ), "", colorBlue, 1 + 8 
> );//"78,6% Retr."
> 
> Plot( IIf( x >= xab + 1, RT127_2, -1e10 ), "", colorSkyblue, 1 
> );//"127,2% Retr."
> 
> Plot( IIf( x >= xab + 1, RT161_8, -1e10 ), "", colorLavender, 1 
> );//"161,8% Retr."
> 
> //Plot( IIf( x >= xab + 1, RT261_8, -1e10 ), "", colorDarkGreen, 1 
> );//"261,8% Retr."
> 
> _SECTION_END();
> 
> _N( Title =  StrFormat( "{{NAME}} - {{INTERVAL}} {{DATE}} \nOp : %g \nHi 
> : %g \nLo : %g \nCl : %g (%.1f%%) {{VALUES}}\n", O, H, L, C, 
> SelectedValue( ROC( C, 1 ) ) )
>               + "per Fib = " + WriteVal( per, 1.2 ) + " \nCurrent 
> Correction = " + WriteVal( RT, 1.0 ) + "%" );
> 
> 
> Edward Pottasch a écrit :
>> Reinsley,
>>
>> I believe you need to use set and get, like:
>>
>> pds = Param("pds", 10, 5, 100, 1);
>> StaticVarSet("pds", pds);
>> pds = Nz(StaticVarGet("pds"));
>>
>> Title = "pds: " + pds;
>>
>> rgds, Ed
>>
>>
>> ----- Original Message ----- 
>> From: "reinsley" <[email protected]>
>> To: <[email protected]>
>> Sent: Sunday, November 08, 2009 2:38 PM
>> Subject: Re: [amibroker] Increase and decrease a var with two GFX buttons.
>>
>>
>>
>> Hello Ed,
>>
>> Yes, I started from examples in the UKB. I missed the library entry,
>> however this code is huge and not easy to understand the vars.
>> Thank you to point this interesting formula, a lot of things to dissect...
>>
>> One of the many issues I met before to see the Aron's example is in the
>> following code.
>> For some reason, the default value is 1 as I expected 10 !
>> AB's rules have reasons that basic user ignores.
>>
>> // param static var
>>
>> pds = Param("pds", 10, 5, 100, 1);
>> pds = StaticVarSet("pds", pds);
>> Title = "pds: " + pds;
>>
>> Best regards
>>
>>
>>
>> Edward Pottasch a écrit :
>>> not sure about the answer to your question but I am sure you know about
>>> the code on buttons that has been published in the UKB. You might also
>>> want to check this library entry which I also still have to study but
>>> looks very interesting:
>>>
>>> http://www.amibroker.com/members/library/formula.php?id=1175
>>> <http://www.amibroker.com/members/library/formula.php?id=1175>
>>>
>>> regards, Ed
>>>
>>>
>>>
>>>
>>>
>>>
>>>     ----- Original Message -----
>>>     *From:* Reinsley <mailto:[email protected]>
>>>     *To:* [email protected] <mailto:[email protected]>
>>>     *Sent:* Saturday, November 07, 2009 6:58 PM
>>>     *Subject:* [amibroker] Increase and decrease a var with two GFX 
>>> buttons.
>>>
>>>
>>>
>>>     Hello,
>>>
>>>     I would like to decrease Myparam of 0.25 on each clic inside the red
>>>     button.
>>>
>>>     I complicated with static var but Myparam comes back to 5 as it is
>>>     declared at the beginning of the formula.
>>>
>>>     How to decrease a var with a GFX button ?
>>>
>>>     To give an idea of what I want to do , once this point solved, my
>>>     next step will be to increase of 0.25 the same Myparam with a Plus
>>>     button to adjust a Fibonacci step. I will add Fibonacci code at the
>>>     very end.
>>>
>>>     AB parameters windows lacks some ergonomics in real time.
>>>
>>>     I draw the buttons in the upper right side, after the bars, as quote
>>>     marker will not be activate.
>>>
>>>     Thanks for the help
>>>
>>>     Best regards
>>>
>>>     // draw a red square + inside click
>>>
>>>     //SetChartOptions( 2, chartHideQuoteMarker );
>>>
>>>     Myparam = Param( "TheValue", 5, 0, 5, 0.25 );
>>>     StaticVarSet( "Myparamstat ", Myparam );
>>>
>>>     Myparam = StaticVarGet( "Myparamstat " );
>>>     _TRACE( "Myparamstat = " + Myparam );
>>>
>>>     function DrawButton( Text, x1, y1, x2, y2, BackColor )
>>>     {
>>>     GfxSetOverlayMode( 0 );
>>>     GfxSelectFont( "Tahoma", 12, 800 );
>>>     GfxSelectPen( colorBlack );
>>>     GfxSetBkMode( 1 );
>>>     GfxSelectSolidBrush( BackColor );
>>>     GfxSetBkColor( BackColor );
>>>     GfxSetTextColor( 1 );
>>>     GfxRectangle( x1, y1, x2, y2 );
>>>     GfxDrawText( Text, x1, y1, x2, y2, 32 | 1 | 4 );
>>>     }
>>>
>>>     shift = 40;
>>>     XOffset = StaticVarGet( "XOffset" );
>>>     YOffset = StaticVarGet( "YOffset" );
>>>
>>>     pxchartwidth = Status( "pxchartwidth" );
>>>     XOffset = pxchartwidth - shift ; // X1
>>>     YOffset = 0;//Y1
>>>     SquareSide = 20;
>>>
>>>     X1m = XOffset ;
>>>     X2m = Xoffset + SquareSide ;
>>>     Y1m = YOffset ;
>>>     Y2m = yOffset + SquareSide ;
>>>
>>>     DrawButton( "-", Xoffset, yOffset, Xoffset + SquareSide , yOffset +
>>>     SquareSide , colorRed );
>>>
>>>     LButtonTrigger = GetCursorMouseButtons() == 9;
>>>     _TRACE( "LButtonTrigger = " + LButtonTrigger );
>>>
>>>     if ( LButtonTrigger )
>>>     {
>>>     MousePx = Nz( GetCursorXPosition( 1 ) );
>>>     MousePy = Nz( GetCursorYPosition( 1 ) );
>>>
>>>     CursorInMinus = MousePx > X1m AND MousePx < X2m AND MousePy > Y1m
>>>     AND MousePy < Y2m;
>>>     _TRACE( "CursorInMinus = " + CursorInMinus );
>>>
>>>     if ( CursorInMinus )
>>>     {
>>>     DrawButton( "-", Xoffset, yOffset, Xoffset + SquareSide , yOffset +
>>>     SquareSide , colorYellow );
>>>     Myparam = StaticVarGet( "Myparamstat " );
>>>     Myparam = Myparam - 0.25;
>>>     _TRACE( "Myparamstat2 = " + Myparam );
>>>     RequestTimedRefresh( 1 );
>>>     }
>>>     }
>>>
>>>
>>
>>
>> ------------------------------------
>>
>> **** IMPORTANT PLEASE READ ****
>> 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/
>>
>> Yahoo! Groups Links
>>
>>
>>
>>
>>
>> ------------------------------------
>>
>> **** IMPORTANT PLEASE READ ****
>> 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/
>>
>> Yahoo! Groups Links
>>
>>
>>
>>
> 
> 
> 
> ------------------------------------
> 
> **** IMPORTANT PLEASE READ ****
> 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/
> 
> Yahoo! Groups Links
> 
> 
> 
> 



------------------------------------

**** IMPORTANT PLEASE READ ****
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/

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Reply via email to