Timframe in Afl Function.

#1
Hello Guys, I am using following code for intraday scanning , it works fine. But when I want to use it for Daily , I am unable to code this please help.
HTML:
function MyMTFfunc( timeframe, expandmode )
{
    TimeFrameSet( timeframe );
   
    a = StochK( periods = 14, ksmooth = 3 );
    b = StochD( periods = 14, Ksmooth = 3, Dsmooth = 3 ) ;
    
    D1 = a<1000;
    TimeFrameRestore();

    VarSet( "K" + timeframe, TimeFrameExpand( a, timeframe, expandmode ) );
    VarSet( "D" + timeframe, TimeFrameExpand( b, timeframe, expandmode ) );
   

    return TimeFrameExpand( D1, timeframe, expandmode );
}

expandmode = expandLast;
TF1 = MyMTFfunc( inDaily, expandmode );
TF2 = MyMTFfunc( 3*inDaily, expandmode );
TF3 = MyMTFfunc( 6*inDaily, expandmode );


k1 = K300; //300 for 5min
k2 = K900; //900 for 15min
k3 = K1800;//1800 for 30min
d1 = D300; 
d2 = D900; 
d3 = D1800;
........... //Rest of coding
Now 300,900,1800 is the second for intraday . What I have to write in place of them for coding in Daily, 3day, 6day timeframe.. Please Help
 

jagankris

Well-Known Member
#2
Hello SagaRocks,

I understand you are learning amibroker.
Just my suggestion - don't start new thread for every question you have.
But just have one thread and keep posting all your questions in the same thread.
So you will get better response and will be easy to keep track.
 

trash

Well-Known Member
#3
Hello Guys, I am using following code for intraday scanning , it works fine. But when I want to use it for Daily , I am unable to code this please help.
HTML:
function MyMTFfunc( timeframe, expandmode )
{
    TimeFrameSet( timeframe );
   
    a = StochK( periods = 14, ksmooth = 3 );
    b = StochD( periods = 14, Ksmooth = 3, Dsmooth = 3 ) ;
    
    D1 = a<1000;
    TimeFrameRestore();

    VarSet( "K" + timeframe, TimeFrameExpand( a, timeframe, expandmode ) );
    VarSet( "D" + timeframe, TimeFrameExpand( b, timeframe, expandmode ) );
   

    return TimeFrameExpand( D1, timeframe, expandmode );
}

expandmode = expandLast;
TF1 = MyMTFfunc( inDaily, expandmode );
TF2 = MyMTFfunc( 3*inDaily, expandmode );
TF3 = MyMTFfunc( 6*inDaily, expandmode );


k1 = K300; //300 for 5min
k2 = K900; //900 for 15min
k3 = K1800;//1800 for 30min
d1 = D300; 
d2 = D900; 
d3 = D1800;
........... //Rest of coding
Now 300,900,1800 is the second for intraday . What I have to write in place of them for coding in Daily, 3day, 6day timeframe.. Please Help

The reason is that you don't understand how the function works because the solution was once not provided by you but by me in this thread.
http://www.traderji.com/amibroker/9...tores-multi-timeframe-values.html#post1063236

I studied c, java, c++ etc 3 years ago. :
That's a joke for a life time!
 

mastermind007

Well-Known Member
#4

trash

Well-Known Member
#7
Error in formula please correct
Simply don't use a code that you do not understand yourself.
Do you even know what it is doing?
You do? So what is it doing?

Code:
function MyMTFfunc( timeframe, expandmode )
{
    // solution by trash who understands how his original function works
    // http://www.traderji.com/amibroker/98157-how-one-variable-stores-multi-timeframe-values.html#post1063236
    TimeFrameSet( timeframe );
   
    a = StochK( periods = 14, ksmooth = 3 );
    b = StochD( periods = 14, Ksmooth = 3, Dsmooth = 3 ) ;
    
    D1 = a<1000;
    TimeFrameRestore();

    _min = timeframe / 60;
    VarSet( "K" + _min, TimeFrameExpand( a, timeframe, expandmode ) );
    VarSet( "D" + _min, TimeFrameExpand( b, timeframe, expandmode ) );   

    return TimeFrameExpand( D1, timeframe, expandmode );
}

expandmode = expandLast;
tmfrm = inDaily;
TF1 = MyMTFfunc( tmfrm, expandmode );
TF2 = MyMTFfunc( 3*tmfrm, expandmode );
TF3 = MyMTFfunc( 6*tmfrm, expandmode );

// You wanna know what each number means and where it comes from and when it is initialized?
// See the function's inner working. OK?
k1 = K1440;
k2 = K4320; 
k3 = K8640;

d1 = D1440; 
d2 = D4320; 
d3 = D8640;
 

Similar threads