Simple Coding Help - No Promise.

LOVEENAJYOTHI

Well-Known Member
Dear Master Coders/Seniors,
Humble rquest for kind Help/Guidance/SampleCode


There are some AFLs available which create Buttons on the Chart to Buy/Sell/Short/Cover.

Now i Need to Add an additional condition to my Regular Buy condition so that whenever a BUY Button is pressed on chart, the AFL should consider the action as a BuyCondition==True and Trigger a Buy signal in Chart/Scan/Explore
and Most Importantly the Buy Signal should remain permanently or atleast until the close of AmiBroker.

Plz HELP
Thank u
Regards
 
your variables produced by VarSet() are "M1", "M2", "M3"

Is M2 same as "M2" ?

When you do VarGet()

M = VarGet("M1") when i=1
M = VarGet("M2") when i=2
M = VarGet("M3") when i=3
So what is your M2 ?

So the amibroker tell you, I donn't understand M2, because is not initialise
thanks
Code:
Plot( C, ""+Interval(2), styleCandle );

for( i = 1; i < 3; i++ )
{

    TimeframeSet( i*in1Minute );
    up = C > O;
    TimeframeRestore();
    
VarSet( "M"+ i, TimeFrameExpand( up, i*in1Minute , expandPoint ) );
// Doesn't  M2  =  TimeFrameExpand( up, 2*in1Minute , expandPoint );
m = VarGet( "M" + i );

   for( b = 0; b < BarCount; b++ )
    {
if( M[b] )   PlotText(" "+(i), b, L[b]-1-(i), colorRed);

if ( [COLOR="Red"]VarGet("M2[b]")[/COLOR])
{
[SIZE="3"][B]PlotText( "_m" , b, L[ b ]-1-dist[1], colorgold );
[/B][/SIZE]}


}
}
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
If i write , i can't see _m line when there is 2 number under candle.

Each variable represent each number under candle .


If i assign same m2 as here it's VarGet("M2") ..below it does plot _m , with VarGet("M2") it's not plotting _m
Code:
Plot( C, ""+Interval(2), styleCandle );
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
dt = DateTime();
SetBarsRequired( -2, -2 );
expandmode=expandPoint;

    TimeframeSet( in1Minute );   //  TimeframeSet(i * in1Minute);    
    up = C > O;
    M1 = TimeFrameExpand( up, in1Minute , expandPoint ); 
    TimeframeRestore();
 
    TimeframeSet( 2*in1Minute );
     up = C > O; 
    M2 = TimeFrameExpand( up, 2*in1Minute , expandPoint );
    TimeframeRestore();
     
     dist = 0.1*ATR(1);
    for( b = 0; b < BarCount; b++ )
{
//------  yellow is the Invertedhammer  with NO space
if( m1[b] ) PlotText( "1" , b, L[ b ]-1-dist[1], colorRed );  
if( m2[b] ) PlotText( "2" , b, L[ b ]-1.4-dist[1], colorRed );
if( b > 11 )
[COLOR="Red"][SIZE="2"]if (m2[b])
PlotText( "_m" , b, L[ b ]-1-dist[1], colorgold );
}[/SIZE][/COLOR]
 
Last edited:

KelvinHand

Well-Known Member
thanks

Code:
Plot( C, ""+Interval(2), styleCandle );

for( i = 1; i < 3; i++ )
{

    TimeframeSet( i*in1Minute );
    up = C > O;
    TimeframeRestore();
    
VarSet( "M"+ i, TimeFrameExpand( up, i*in1Minute , expandPoint ) );
// Doesn't  M2  =  TimeFrameExpand( up, 2*in1Minute , expandPoint );
m = VarGet( "M" + i );

   for( b = 0; b < BarCount; b++ )
    {
if( M[b] )   PlotText(" "+(i), b, L[b]-1-(i), colorRed);

if ( [COLOR="Red"]VarGet("M2[b]")[/COLOR])
{
[SIZE="3"][B]PlotText( "_m" , b, L[ b ]-1-dist[1], colorgold );
[/B][/SIZE]}


}
}
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
If i write , i can't see _m line when there is 2 number under candle.

Each variable represent each number under candle .


If i assign same m2 as here it's VarGet("M2") ..below it does plot _m , with VarGet("M2") it's not plotting _m
Code:
Plot( C, ""+Interval(2), styleCandle );
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
dt = DateTime();
SetBarsRequired( -2, -2 );
expandmode=expandPoint;

    TimeframeSet( in1Minute );   //  TimeframeSet(i * in1Minute);    
    up = C > O;
    M1 = TimeFrameExpand( up, in1Minute , expandPoint ); 
    TimeframeRestore();
 
    TimeframeSet( 2*in1Minute );
     up = C > O; 
    M2 = TimeFrameExpand( up, 2*in1Minute , expandPoint );
    TimeframeRestore();
     
     dist = 0.1*ATR(1);
    for( b = 0; b < BarCount; b++ )
{
//------  yellow is the Invertedhammer  with NO space
if( m1[b] ) PlotText( "1" , b, L[ b ]-1-dist[1], colorRed );  
if( m2[b] ) PlotText( "2" , b, L[ b ]-1.4-dist[1], colorRed );
if( b > 11 )
[COLOR="Red"][SIZE="2"]if (m2[b])
PlotText( "_m" , b, L[ b ]-1-dist[1], colorgold );
}[/SIZE][/COLOR]


You already got the M2, why
still want to
if(b>11)
if (m2)
....

why not as below:

if( m2 )
{
if( b > 11 )
PlotText( "_m" , b, L[ b ]-1-dist[1], colorgold );
else
PlotText( "2" , b, L[ b ]-1.4-dist[1], colorRed );
}
 

LOVEENAJYOTHI

Well-Known Member
Dear Master Coders/Seniors,
Humble rquest for kind Help/Guidance/SampleCode


There are some AFLs available which create Buttons on the Chart to Buy/Sell/Short/Cover.

Now i Need to Add an additional condition to my Regular Buy condition so that whenever a BUY Button is pressed on chart, the AFL should consider the action as a BuyCondition==True and Trigger a Buy signal in Chart/Scan/Explore
and Most Importantly the Buy Signal should remain permanently or atleast until the close of AmiBroker.

Plz HELP
Thank u
Regards
Kelvin
:sos: Pleeeeeaaaaaaaaazzzzzzzzzzzz
 
You already got the M2, why
still want to
if(b>11)
if (m2)
....

why not as below:

if( m2 )
{
if( b > 11 )
PlotText( "_m" , b, L[ b ]-1-dist[1], colorgold );
else
PlotText( "2" , b, L[ b ]-1.4-dist[1], colorRed );
}


yes but
My problem is when i tried VarGet("M2"); it's not showing _m line

Code:
Plot( C, ""+Interval(2), styleCandle );

for( i = 1; i < 3; i++ )
{

    TimeframeSet( i*in1Minute );
    up = C > O;
    TimeframeRestore();
    
VarSet( "M"+ i, TimeFrameExpand( up, i*in1Minute , expandPoint ) );
// Doesn't  M2  =  TimeFrameExpand( up, 2*in1Minute , expandPoint );
m = VarGet( "M" + i );

   for( b = 0; b < BarCount; b++ )
    {
if( M[b] )   PlotText(" "+(i), b, L[b]-1-(i), colorRed);

if ( [COLOR="Red"]VarGet("M2[b]")[/COLOR])
{
PlotText( "_m" , b, L[ b ]-1-dist[1], colorgold );
}


}
}
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
If i write , i can't see _m line when there is 2 number under candle.

Each variable represent each number under candle .
 
Last edited:

trash

Well-Known Member
Hello,
why varset is not assigning value right or Is there any issue?
when i do manually,
When there is 2 number under candle I can plot _m line
When i try to same stuff with loop, I get error m2 not initiated
and I tried to initiated with varset


VarSet( "M" + i, TimeFrameExpand( up, i*in1Minute , expandPoint ) );
// Doesn't M2 = TimeFrameExpand( up, 2*in1Minute , expandPoint );


BELOW CODE WORKING FINE
Code:
Plot( C, ""+Interval(2), styleCandle );
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
dt = DateTime();
SetBarsRequired( -2, -2 );
expandmode=expandPoint;

    TimeframeSet( in1Minute );   //  TimeframeSet(i * in1Minute);    
    up = C > O;
    M1 = TimeFrameExpand( up, in1Minute , expandPoint ); 
    TimeframeRestore();
 
    TimeframeSet( 2*in1Minute );
     up = C > O; 
    M2 = TimeFrameExpand( up, 2*in1Minute , expandPoint );
    TimeframeRestore();
     
     dist = 0.1*ATR(1);
    for( b = 0; b < BarCount; b++ )
{
//------  yellow is the Invertedhammer  with NO space
if( m1[b] ) PlotText( "1" , b, L[ b ]-1-dist[1], colorRed );  
if( m2[b] ) PlotText( "2" , b, L[ b ]-1.4-dist[1], colorRed );
if( b > 11 )
[COLOR="Red"][SIZE="2"]if (m2[b])
PlotText( "_m" , b, L[ b ]-1-dist[1], colorgold );
}[/SIZE][/COLOR]


BELOW CODE IS NOT WORKING FINE , SAME STUFF TRIED WITH LOOP
Code:
Plot( C, ""+Interval(2), styleCandle );

for( i = 1; i < 3; i++ )
{

    TimeframeSet( i*in1Minute );
    up = C > O;
    TimeframeRestore();
    
[COLOR="Red"]VarSet( "M" + i, TimeFrameExpand( up, i*in1Minute , expandPoint ) );
// Doesn't  M2  =  TimeFrameExpand( up, 2*in1Minute , expandPoint );[/COLOR]
M = VarGet( "M" + i );

   for( b = 0; b < BarCount; b++ )
    {
if(M[b] )   PlotText(" "+(i), b, L[b]-1-(i), colorRed);

if (M2[b])
{
PlotText( "" , b, y[ b ], colorRed );
}


}
}
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );


First of all using Varset/Get makes no sense here because the same can be achieved without it. So you're just doing additional overhead without any advantage.

Secondly as for the reason why m2 is not recognized is because you have a loop there and m2 is true only when i == 2! So during iteration when "i" is lower than 2 then there is no m2 var. In order to remove error you would have to add

Code:
if ( i == 2 )
And this one VarGet("M2") of your most recent code is completely wrong (subscript within varget string).

But again using VarSet/VarGet in your specific case of implementation makes no sense. Remove it.

Thirdly why do you loop entire Barcount for plotting text? Iterate visible chart area!

Also disabling QuickAfl via SetBarsRequired( -2, -2 ); is overhead.

Long story short you don't know what you are doing there.
 

trash

Well-Known Member
your variables produced by VarSet() are "M1", "M2", "M3"

Is M2 same as "M2" ?

When you do VarGet()

M = VarGet("M1") when i=1
M = VarGet("M2") when i=2
M = VarGet("M3") when i=3
So what is your M2 ?

So the amibroker tell you, I donn't understand M2, because is not initialise
If you set a variable with VarSet() then it can be called via VarGet or by using variable name being equal to VarSet string.

His problem is that he doesn't know that m2 is true only when i == 2.
 

KelvinHand

Well-Known Member
PHP:
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );

//Plot( C, ""+Interval(2), styleCandle );
dist = 0.1*ATR(1);

for( i = 1; i < 3; i++ )
{

    TimeframeSet( i*in1Minute );
    up = C > O;
    TimeframeRestore();
    
   VarSet( "M"+ i, TimeFrameExpand( up, i*in1Minute , expandPoint ) );
}

for( i = 1; i < 3; i++ )
{
   m = VarGet( "M" + i );

   if (i==2)
   {
      M2= VarGet( "M" + i );

      for( b = 0; b < BarCount; b++ )
       if( M2[b] )
         PlotText( "_m" , b, L[ b ]-1-dist[1], colorgold );
   }
   else
   {
      for( b = 0; b < BarCount; b++ )
        if( M[b] )   PlotText(" "+(i), b, L[b]-1-(i), colorRed);
   } 
 
}

As trash stressed to you "Varset/Get makes no sense here" as is what i m going to tell you.
But for the demo purpose here.
 
Last edited:
First of all using Varset/Get makes no sense here because the same can be achieved without it. So you're just doing additional overhead without any advantage.

Secondly as for the reason why m2 is not recognized is because you have a loop there and m2 is true only when i == 2! So during iteration when "i" is lower than 2 then there is no m2 var. In order to remove error you would have to add
Code:
if ( i == 2 )
hello,

Secondly as for the reason why m2 is not recognized is because you have a loop there and m2 is true only when i == 2! So during iteration when "i" is lower than 2 then there is no m2 var. In order to remove error you would have to add

I'm using loop less than 3 , 2 is already within loop as just below
for( i = 1; i < 3; i++ )

----
if ( i == 2 ) is for just one condition
What if i use
VarSet( "M" + i, TimeFrameExpand( up, i*in1Second , expandPoint ) );

1 minute consist 60 seconds so i have to write if ( i == 2 ) ,....if ( i == 60 ) for each condition ..

same way if i write for,between 10 seconds to 30 seconds
i == 10 to ..... i ==29, i ==30, I've to write for each condition

And this one VarGet("M2") of your most recent code is completely wrong (subscript within varget string).

Isn't VarGet("M2") represent 2 number under candle,so why can't it print _m ?


yes Firstvisiblebar,Lastvisiblebar can be used instead using bar loop, but it doesn't help to plot _m ..
 
Last edited:

KelvinHand

Well-Known Member
Kelvin
:sos: Pleeeeeaaaaaaaaazzzzzzzzzzzz
I wont do for you anything when i see this post.
Because, Your are like same person on the other tread, you request something, but want the code expert to do all the work from head to tail.

your case, must go and find the code for you.
Why not you to and present the code here, and describe properly how
to be done so save time for the code expert.


I also got a lot work to do.
Sorry. I think too complicated for me. Not interested.
 

Similar threads