Kindly see this article:
https://www.amibroker.com/guide/a_mistakes.html
“=” (assignment) vs “==” (equality check)
Using parentheses
IIf function
IIf is for arrays, WriteIf is for strings
if-else statement needs boolean (or single numeric expression), not array
Barcount vs BarIndex()
TimeFrameExpand( ) is required to match data with original time frame
Code:
IIf is for arrays, WriteIf is for strings
IIf functions should be used to handle arrays, if you need conditional text function use WriteIf instead.
EXAMPLE
Incorrect code:
variable = IIf(Condition, "Text 1","Text 2" ); // WRONG
IIf( ) function returns array, NOT STRING, so it’s impossible to assign text to variable with use of IIF. Use WriteIf( ) function instead:
Correct code:
variable = WriteIf( condition, "Text 1", "Text 2" ); // CORRECT
if-else statement needs boolean (or single numeric expression), not array
simple meant, if else doesn't execute array.
if( Close > Open ) // WRONG
Close and Open, like if we want to intend for specific bar we do it Close[x] some value there, if it's not mentioned, that means it's for all .
since it's array , it's not right to do it.
==
This is something interesting, but you need to look for more examples
Code:
Barcount vs BarIndex()
There is a fundamental difference between BarCount and BarIndex(). BarCount is a numeric variable that holds just one number (the count of elements in array). On the other hand BarIndex() is a function that returns ARRAY representing consecutive index of each bar.
EXAMPLE
Incorrect code:
for (i = 0; i < BarIndex();i++ ) // WRONG
{
// your formula
}
It’s not allowed to use ARRAY inside for loop, and Barindex() returns ARRAY. That is why it’s necessary to change the formula.
Correct code:
for (i =0 ; i < BarCount ;i++ ) // CORRECT
{
//your formula
}
==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.
On MTF , NOT LOT OF WORK IS DONE , SO YOU'VE TO BE CAREFUL
LEARNING:
PATIENCE IS NOTHING I TELL YOU, IF YOU HAVE FOLKS AROUND YOU , THEY WILLING TO MAKE SOMETHING, IT WILL WORK ..
IF YOU DONT HAVE, SIMPLE! YES SIMPLE! YOU WON'T GET IT!
WHAT TO DO?
YES! SEARCH NEXT....
ON EARTH , THERE'S NO SINGLE GUY WHO CAN CLAIM I KNOW SOMETHING WHICH SOMEONE ELSE DOESN'T KNOW, ATLEAST FOR ALL PROFESSION THAT WE DO KNOW.
SO NATURE IS FAIR FOR YA! LOOK FOR AGAIN AND AGAIN ..
IF YOU DONT! GUESS WHAT?
YOU ARE OBLIGED TO SAY , YOU WASTED TIME ! ISN'T IT SO?