BLOCK OF codes, examples, learning , my experience

cheap

Active Member
#1
When i started asking question regarding Timeframe , got stuck..
I find folks who are here for lot of years, they also find difficulties, lot of people provided solution,
at the end i got it was all wrong after 1 month
so if new guy ask such question , kindly look at it.

I will start it by TIMEFRAMEEXPAND, FILTER = 0; EXAMPLES.
will write here , if i gonna be member and learn new stuff..

regards

I don't need any thanks, i am not being rude, I really find weird, when not a single afl got worked out such ways,..
I didn't even included some of order flow stuff , delta into it. I know that such answer i won't get even in 1 year for sure. but anyways, once i'm done with these little system, i find limitation (cdone)

Don't get provoke by this, this is what i just think so sharing.

I will post atleast 5 Timeframexpand examples from sources.

I FIND ONE TRADITION : FEEDING EGO, I DIDN'T GET IT. I MEAN, YOU WANT TO TEASE, NO PROBLEM, .. WHY NOT SEEK FOR RIGHT SOLUTION?
Disclaimer: it's just my opinion, so sharing in this thread.
 
Last edited:

cheap

Active Member
#2
FIRST MISTAKE WAS NOT USING TIMEFRAMEEXPAND when using timeframeset() and timeframerestore();
I GOT IT AFTER 1 MONTH, NO ONE POINTED IT THIS STUFF

just get a sense by looking examples from various what is it?
I am not even coder, so programmer and other level i dont know.
but who were, they didn't told such things.


Code:
TimeFrameSet( in5Minute ); // switch to 5 minute frame 

/* MA now operates on 5 minute data, ma5_13 holds time-compressed 13 bar MA of 5min bars */ 

ma5_13 = MA( C, 13 );
[COLOR="Red"]TimeFrameRestore(); // restore time frame to original 
[/COLOR]
TimeFrameSet( inHourly ); // switch now to hourly 

mah_9 = EMA( C, 9 ); // 9 bar moving average from hourly data 

[COLOR="red"]TimeFrameRestore(); // restore time frame to original 
[/COLOR]
Plot( Close, "Price", colorWhite, styleCandle ); 

// plot expanded average 

Plot( [COLOR="red"]TimeFrameExpand( ma5_13, in5Minute)[/COLOR], "13 bar moving average from 5 min bars", colorRed ); 
Plot( [COLOR="red"]TimeFrameExpand( mah_9, inHourly[/COLOR]), "9 bar moving average from hourly bars", colorRed );

THIS ONE IS FROM COMMON CODING MISTAKES

Code:
TimeFrameExpand( ) is required to match data with original time frame

The TimeFrameSet( ) replaces current price/volume arrays: open, high, low, close, volume, openint, avg with time-compressed bars of specified interval once you switched to a different time frame all calculations and built-in indicators operate on selected time frame. To get back to original interval call TimeFrameRestore( ) function. [COLOR="red"]The TimeFrameExpand( ) is used to decompress array variables that were created in different time frame. [/COLOR]Decompressing is required to properly display and use the array created in different time frame.

EXAMPLE

Incorrect code:

TimeFrameSet( inWeekly ); 
MA14_Weekly = MA( Close, 14 ); 
TimeFrameRestore(); 
Buy = Cross( Close, MA14_Weekly ); // WRONG - Close and MA15_Weekly use different time scales

The above formula is wrong, as MA14_Weekly variable should be EXPANDED to match original timeframe. The right contents should be:

Correct code:

TimeFrameSet( inWeekly ); 
MA14_Weekly = MA( Close, 14 ); 
TimeFrameRestore(); 
Buy = Cross( Close, [COLOR="red"]TimeFrameExpand[/COLOR]( MA14_Weekly, inWeekly ) ); // [COLOR="red"]CORRECT, expanded weekly MA can be matched against daily close
[/COLOR]
EXAMPLE 2:

Incorrect code:

TimeFrameSet( inWeekly ); 
MA14_Weekly = MA( Close, 14 ); 
TimeFrameRestore(); 
Buy = Cross( Close, [COLOR="red"]TimeFrameExpand[/COLOR]( MA14_Weekly, inDaily ) ); // WRONG

[COLOR="red"]It’s always necessary to indicate in TimeFrameExpand( ) function, which timeframe was  variable calculated in.[/COLOR] So if MA14_Weekly was calculated in out of weekly data, inWeekly should be the correct parameter of TimeFrameExpand( ) function.

Correct code:

TimeFrameSet( inWeekly ); 
MA14_Weekly = MA( Close, 14 ); 
TimeFrameRestore(); 
Buy = Cross( Close, [COLOR="red"]TimeFrameExpand[/COLOR]( MA14_Weekly, inWeekly ) ); // CORRECT
THIS IS FROM USING LOOPS WITH TIMEFRAME FUNCTION

Code:
Version( 5.90 );

Plot( Close, "Close", colorBlack );

// switch to higher timeframe
TimeFrameSet( inWeekly );

smooth = 0.2;
myAMA = Close;

// new 5.90 function that counts leading Nulls
start = NullCount( Close );

// looping code
for ( i = start + 1; i < BarCount; i++ )
{
    // this part will execute only after the first non-null bar has been identified
    myAMA[ i ] = Close[ i ] * smooth + myAMA[ i - 1 ] * ( 1 - smooth );
}

// regular AMA function for comparison
weeklyAMA = AMA( Close, 0.2 );

//restore original time-frame
TimeFrameRestore();

[COLOR="red"]// plot expanded values retrieved from Weekly frame
Plot( TimeFrameExpand( myAMA, inWeekly[/COLOR] ), "weekly AMA loop", colorRed );
Plot([COLOR="red"] TimeFrameExpand([/COLOR] weeklyAMA, inWeekly ), "weekly AMA", colorBlue, styleDots );

the last LOOP WAS NOT ABOUT TIMEFRAME LOOP? IF THIS IS TIMEFRAME LOOP, HOW WOULD YOU USE TIMEFRAMEEXPAND() FUNCTION?
ANYONE?
 
Last edited:

cheap

Active Member
#3
learning:

I WAS SEEING FEW AFL, GOT SOME NEW STUFF LIKE

Code:
if (SelectedValue(Buy)==1) Say("BUY Now ");
if (SelectedValue(Sell)==1) Say("Sell Now");
when you click on it , it will say it .
Code:
Buy = Cross(C, UpFractal); //[COLOR="Blue"]WHEN YOU USE OUTPUT FROM TWO COLUMNS FROM EXPLORATION, WOULD YOU STILL USE CROSS? 
I MADE ONE CONDITION LIKE IF BAR   A PATTERN BETWEEN 1 TO 5MIN.  AND 10 TO 15 MIN. THEN MAKE BUY CONDITION . 
WOULD YOU USE  AND OR + SIGN FOR THAT ? OR ? [/COLOR]
[/COLOR][/COLOR]
Sell = Cross(DownFractal,C);
Short=Sell;
Cover=Buy;
Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );

AlertIf( Buy,"SOUND C:\\Windows\\Media\\Chord.wav", "Audio alert", 2 );
AlertIf( Sell,"SOUND C:\\Windows\\Media\\Ding.wav", "Audio alert", 2 );

PlotShapes(IIf(Buy,shapeUpArrow,shapeNone), colorBrightGreen, 0, Low, Offset=-15);
PlotShapes(IIf(Sell, shapeDownArrow,shapeNone), colorPink, 0, High,
Offset=-15);
//WHEN YOU USE OUTPUT FROM TWO COLUMNS FROM EXPLORATION, WOULD YOU STILL USE CROSS?
I MADE ONE CONDITION LIKE IF BAR A PATTERN BETWEEN 1 TO 5MIN. AND 10 TO 15 MIN. THEN MAKE BUY CONDITION .
WOULD YOU USE AND OR + SIGN FOR THAT ? OR ?


This piece of code needed when
1. when made Buy and Sell condition
then only you can use Alertif and PlotShapes Function,
In some cases i have seen they use plot then plotshapes

Code:
something = ValueWhen(
//your formula

);

Plot(Ref(something,2), "Up Fractal", colorGreen,styleDots,styleThick);
Plot(Ref(something,2), "Down Fractal",colorRed, styleDots,styleThick);
I guess it plots drawing like horizontal dotted lines
 
Last edited:

vijkris

Learner and Follower
#4
When i started asking question regarding Timeframe , got stuck..
I find folks who are here for lot of years, they also find difficulties, lot of people provided solution,
at the end i got it was all wrong after 1 month


I will start it by TIMEFRAMEEXPAND, FILTER = 0; EXAMPLES.
will write here , if i gonna be member and learn new stuff..

regards

I don't need any thanks, i am not being rude, I really find weird, when not a single afl got worked out such ways,..
I didn't even included some of order flow stuff , delta into it. I know that such answer i won't get even in 1 year for sure. but anyways, once i'm done with these little system, i find limitation (cdone)

.
FIRST MISTAKE WAS NOT USING TIMEFRAMEEXPAND when using timeframeset() and timeframerestore();
I GOT IT AFTER 1 MONTH, NO ONE POINTED IT THIS STUFF

just get a sense by looking examples from various what is it?
I am not even coder, so programmer and other level i dont know.
but who were, they didn't told such things.
bro ,

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


edit: instead of further cluttering your thread, removing unnecessary lines from my post. my mistake :p
u continue with your examples. it will surely help others

Kindly do not take it this way , read the post of last post by Trash,



NOW MY SUGGESTION IS :
READ THIS TRASH POST





kindly DON'T GET EXCITED, KINDLY READ WHERE HE WAS INTENDING ABOUT..

JUST ONLY TWO POST AWAY FROM YOUR POST I POSTED THAT EXAMPLE ALREADY , KINDLY SEE IT
AS I SAID IT'S MY PERSON OPINION, MY THINKING, NOT BLAMING..IT'S JUST MY VIEWS .. IT'S ONLY FOR WHO SEEK FOR MULTI TIMEFRAME LITTLE DEEPLY NOT FOR OSCILLATOR AND SUCH STUFF ... SO KINDLY DON'T SPREAAD SUCH THINGS LIKE SPOONFEED, JUST CLOSE THIS STUFF, LET ME GO WIITH MY THREAD .

didn know u went through so much pain. sorry for disturbing

regards.
 
Last edited:

cheap

Active Member
#5
bro , apologies for disturbing the flow of the thread, just a friendly advice, pls don't get offended.

u said u r not a coder and u wanted to learn. right?
how much effort did u make to learn ?
the way u started this thread indicates that u r angry bcos no one SPOON FED U ....

I m not a coder but since I never wanted to be spoon fed, I learnt coding reading books, reading ami manual and HELP FILE.

BTW do u know that help file exists in amibroker???????

The timeframe thing which u understood after 1 month. "NO ONE told u " is your complaint. If u would have read the help file u NEED NOT DEPEND ON ANYONE ELSE FOR UNDERSTANDING ABT EXPAND FUNCTION..

HERE IS SCREENSHOT OF HELP FILE:



next time onwards if u have any doubts regarding coding, first put an effort to learn by reading the help file.

without knowing basics u cant create any code.

Kindly do not take it this way , read the post of last post by Trash,



NOW MY SUGGESTION IS :
READ THIS TRASH POST

Yes we can. See reply #5
http://amibrokerforum.proboards.com/thread/14/addrow-function-vrs-5-91?page=1&scrollTo=580



Once again, if your output is solely done via Addrow then using Filter var makes no sense!!

Once again No. 2, if your output is solely done via Addrow then Filter is set to ZERO. Zero is equal to false. Filter variable (being non zero) is used if you want to create output via AddColumn.

So what does it mean if you add a line like the second one

Code:
Filter = 0;

if(LastValue(Filter))
    Addrow(...);
Since filter is false it means that no output of AddRow will ever occur.
So remove that nonsense line if(LastValue(Filter)). It makes no sense in regards to AddRow.


Don't listen to people who give wrong advice.

That refers to TimeFrame functions also. Always use TimeFrameExpand. That's the only proper way. Don't listen to people who don't understand that a code has to properly work under any circumstances. That's only achieved by using correct expanding. TimeFrameExpand always follows after using restore. TimeframeExpand has three different expanding modes. Use the proper one.

TimeFrameExpand is not supported for N-range and N-Volume bars though.

http://amibrokerforum.proboards.com/...rame-functions


As for the actual "problem", it is actually three loops since it is three dimensions. All loops are outside of time frame procedure. There is no loop within timeframeset... timeframerestore in this case. First loop iterates through time frames (so it is the loop you already have in place), second loop that follows after expanding iterates through patterns (see dynamic variables, alternatively you may use switch statement within timeframeset..timeframerestore) and third loop iterates (partial) barcount.

Also there are no multiple lines of WriteIf() being used! Do you want to tell me that you would write 100 lines of Writeif if you want to output 100 patterns or other comparisons? Are you kidding? We don't want to create amateurish code. We want to create intelligent code.

Also once again there is just one line required that does the expanding of all available patterns. Why? Because we do like intelligent code, don't we.
Also it's needless to say that Addrow follows at the end outside of time frame procedure.

As aside there are also examples where there are actually 4 dimensions applied as seen in 2nd picture here http://amibrokerforum.proboards.com/...1&scrollTo=580
There 1st dimension is bar number, 2nd dimension (column) is period of indicator, 3rd dimension is time frame and 4th dimension is the indicator version.

Long story short I have gone through it "all". I know how AddRow works and how you get any output presented by it. Don't listen to people who haven't ever used it and don't know how it works but give improper advice just leading to nothing else but problems sooner or later.

Study it! Use the several debugging methods being available in order to investigate what happens when you do this or do that http://amibrokerforum.proboards.com/...arty-tutorials

Rome wasn't built after one day too.


kindly DON'T GET EXCITED, KINDLY READ WHERE HE WAS INTENDING ABOUT..

JUST ONLY TWO POST AWAY FROM YOUR POST I POSTED THAT EXAMPLE ALREADY , KINDLY SEE IT
AS I SAID IT'S MY PERSON OPINION, MY THINKING, NOT BLAMING..IT'S JUST MY VIEWS .. IT'S ONLY FOR WHO SEEK FOR MULTI TIMEFRAME LITTLE DEEPLY NOT FOR OSCILLATOR AND SUCH STUFF ... SO KINDLY DON'T SPREAAD SUCH THINGS LIKE SPOONFEED, JUST CLOSE THIS STUFF, LET ME GO WIITH MY THREAD .

[BRO, YOU NOT GETTING PAIN OF LITTLE OUT OF BOX THING, I HAVE TO DO PM , PEOPLE NOT INTERESTED, PEOPLE SAYS I DO KNOW LIMITED, I AM LETTING THERE PERMISSION TO COME THERE , TRYING TO FIND AROUND INTERNET, WAITING , HAVING PATIENCE, AL THE THINGS AND AT THE END EVERYTHING DONE IS WRONG. IT'S FOR MTF FOLKS, WHO DOESN'T GET TRAPPED JUST AT STARTING, IF I DON'T POST IT, THEY WILL WASTE MONTHS WITHOUT KNOWING ANYTHING.

BTW MAKING MY FUN IS NOT A ISSUE FOR ME, THESE LITTLE IDEAS ARE.
/
 
Last edited:

cheap

Active Member
#6
bro ,

next time onwards if u have any doubts regarding coding, first put an effort to learn by reading the help file.

without knowing basics u cant create any code.


i guess you read enough HELP FILE.

i do assuME , YOU READ HELP FILE ABOUT TIMEFRAMEEXPAND, SO YOU MAYBE KNOW ABOUT IT.

Code:
_SECTION_BEGIN("Formula 41");
SetOption("NoDefaultColumns", True ); 

AddColumn( Null, "Symbol", 1, colorDefault, colorDefault, 70 );
AddColumn( Null, "DateTime", 1, colorDefault, colorDefault, 150 );
AddColumn( Null, "bar", 1, colorDefault, colorDefault, 70 );



dt = DateTime(); 
 filter = 0; //outside the loop


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

   TimeframeSet(i * in1Minute);
   
   up= C>O; 



   bar= Name() + "\t";
   bar= bar+ DateTimeToStr(LastValue(DateTime()))+ "\t"; 
 

   x= StrFormat("%02g-min", i);
   bar = bar+ WriteIf(up,  x, "\t");

  
        addRow(bar );
    
  TimeframeRestore();  
m1 = TimeFrameExpand(up,in1Minute);


for(i=1; i<=5; i++) {
 TimeframeSet(i * in1Minute);
up= C > O; //[if there is a bar, between 1 to 5 min.]
  TimeframeRestore();
}
m2= TimeFrameExpand(up, in1minute)

for(i=10; i<=15; i++) {
 TimeframeRestore();
up= C > O; //[if there is a bar, between 10 to 15 min.]
TimeframeRestore();
}
//m3 = TimeFrameExpand(up, in1minute) //or do we need to write in10minutes,('interval' must match the value used in TimeFrameCompress or TimeFrameSet)

m3 = TimeFrameExpand(up, in10minute);
Buy = m2 AND m3; // m2 + m3;

PlotShapes( shape, IIf( Buy, colorGreen, colorRed );
Buy = Exrem(Buy,Sell);
Sell =Exrem(sell,Buy);

}
_SECTION_END();
KINDLY SHOW IT WHERE DO YOU PUT TIMEFRAME EXPAND IN THIS, WHAT IS WRONG IN THIS? I DO BELIEVE READING HELP FILE CAN SOLVE IT AND YOU READ IT ALREADY .
KINDLY TELL HOW WOULD YOU USE LOOPING(TIMEFRAME LOOPING) IN TIMEFRFAMEEXPAND FUNCTION ? I GUESS HELP FILE MIGHT SOLVE IT.


KINDLY GIVE ME 15 MIN. I WILL SPECIALLY MAKE BOLD CHARACTERS IN TRASH'S POST FOR YOU, YOU DONT GONNA READ ALL THE POST.
 
Last edited:

cheap

Active Member
#7
Originally Posted by trash View Post
....

Once again, if your output is solely done via Addrow then using Filter var makes no sense!!

Once again No. 2, if your output is solely done via Addrow then Filter is set to ZERO. Zero is equal to false. Filter variable (being non zero) is used if you want to create output via AddColumn.

So what does it mean if you add a line like the second one

Code:
Filter = 0;

if(LastValue(Filter))
Addrow(...);
Since filter is false it means that no output of AddRow will ever occur.
So remove that nonsense line if(LastValue(Filter)). It makes no sense in regards to AddRow.


Don't listen to people who give wrong advice.

That refers to TimeFrame functions also. Always use TimeFrameExpand. That's the only proper way.
Don't listen to people who don't understand that a code has to properly work under any circumstances. That's only achieved by using correct expanding. TimeFrameExpand always follows after using restore. TimeframeExpand has three different expanding modes. Use the proper one.

TimeFrameExpand is not supported for N-range and N-Volume bars though.

http://amibrokerforum.proboards.com/...rame-functions


As for the actual "problem", it is actually three loops since it is three dimensions. All loops are outside of time frame procedure. There is no loop within timeframeset... timeframerestore in this case. First loop iterates through time frames (so it is the loop you already have in place), second loop that follows after expanding iterates through patterns (see dynamic variables, alternatively you may use switch statement within timeframeset..timeframerestore) and third loop iterates (partial) barcount.

Also there are no multiple lines of WriteIf() being used! Do you want to tell me that you would write 100 lines of Writeif if you want to output 100 patterns or other comparisons? Are you kidding? We don't want to create amateurish code. We want to create intelligent code.

Also once again there is just one line required that does the expanding of all available patterns. Why? Because we do like intelligent code, don't we.
Also it's needless to say that Addrow follows at the end outside of time frame procedure.

......
There 1st dimension is bar number, 2nd dimension (column) is period of indicator, 3rd dimension is time frame and 4th dimension is the indicator version.

Long story short I have gone through it "all". I know how AddRow works and how you get any output presented by it. Don't listen to people who haven't ever used it and don't know how it works but give improper advice just leading to nothing else but problems sooner or later.

......

Rome wasn't built after one day too.

improper advice just leading to nothing else but problems sooner or later.


I MADE THIS SPECIALLY FOR YOU, NOT MY WORDS .I MADE IT BOLD FOR YOU AND BIG SIZE, YOU DON'T NEED TO READ ALL POST
YOUR WELCOME IF YOU WANT TO READ FULL POST http://www.traderji.com/amibroker/101561-mtf-timeframe-scan-output-scanning-timeframe-not-pattern-single-timeframe-p2-12.html#post1155085
 
Last edited:

cheap

Active Member
#8
IT'S WEIRD, SOMETIMES TO SOLVE A LITTLE PROBLEM, YOU HAVE TO SELL YOUR COMPLETE IDEA... TELL THEM EVERYTHING, THEY GET IT AND GIVE NOTHING ... OR REPLY
PEOPLE GET IT, GRASP IT, GIVE NOTHING .. WHAT A TEASE !
GIVE ADVISE , THINGS THEY NEVER THOUGHT IN THEIR LIFE
ANYWAYS , YOU JUST LOSE YOUR THINGS, AND GET NOTHING!
i DON'T KNOW WHAT IS IT OR NOT ... WHAT TO CALL IT .

ANYWAYS FEELS WEIRD ..
I DID IT, I WILL GET HAMMERED I KNOW..

ANYWAYS WILL POST NEW CODES, IF I GET ONES ..
 

mastermind007

Well-Known Member
#9
IT'S WEIRD, SOMETIMES TO SOLVE A LITTLE PROBLEM, YOU HAVE TO SELL YOUR COMPLETE IDEA... TELL THEM EVERYTHING, THEY GET IT AND GIVE NOTHING ... OR REPLY
PEOPLE GET IT, GRASP IT, GIVE NOTHING .. WHAT A TEASE !
GIVE ADVISE , THINGS THEY NEVER THOUGHT IN THEIR LIFE
ANYWAYS , YOU JUST LOSE YOUR THINGS, AND GET NOTHING!
i DON'T KNOW WHAT IS IT OR NOT ... WHAT TO CALL IT .

ANYWAYS FEELS WEIRD ..
I DID IT, I WILL GET HAMMERED I KNOW..

ANYWAYS WILL POST NEW CODES, IF I GET ONES ..
Life's like that
 

bunti_k23

Well-Known Member
#10
IT'S WEIRD, SOMETIMES TO SOLVE A LITTLE PROBLEM, YOU HAVE TO SELL YOUR COMPLETE IDEA... TELL THEM EVERYTHING, THEY GET IT AND GIVE NOTHING ... OR REPLY
PEOPLE GET IT, GRASP IT, GIVE NOTHING .. WHAT A TEASE !
GIVE ADVISE , THINGS THEY NEVER THOUGHT IN THEIR LIFE
ANYWAYS , YOU JUST LOSE YOUR THINGS, AND GET NOTHING!
i DON'T KNOW WHAT IS IT OR NOT ... WHAT TO CALL IT .

ANYWAYS FEELS WEIRD ..
I DID IT, I WILL GET HAMMERED I KNOW..

ANYWAYS WILL POST NEW CODES, IF I GET ONES ..
true better to learn by our own....nice and informative thread ,i was also confused in MTF functions..:thumb:
 

Similar threads