Why i=0; is not a numeric in afl

#12
In Amibroker any variable you declare is considered an array. Therefore, you are getting the error. However, if you use i=0 in a for loop then it is a number.

-Anant
Hello

Posting after a gap of 2 years and straight into helping others with code :up:

Welcome back to TJ


.
 

MSN1979

Well-Known Member
#14
To know what it is use typeof
Code:
i = 0;
printf("i = %s",typeof(i));
@MSN1979 no need of loop for 3rd condition.
typeof returns array in interpretation window. it tells me that i=0 is an array and i need to use a numeric or boolean in IF condition, so are u guys saying without a for loop there is no other way of declaring a numeric or boolean?

If thats is the case how do I solve my code?
 
#15
typeof returns array in interpretation window. it tells me that i=0 is an array and i need to use a numeric or boolean in IF condition, so are u guys saying without a for loop there is no other way of declaring a numeric or boolean?

If that's is the case how do I solve my code?
Hi MSN

Not gone through the code snippet you want to resolve,
but for all conditional statements you give a Boolean Data type (true / false) input
and not an assignment, etc

again a simple e.g. should explain it . . .

Code:
i = 0;
if (SelectedValue( i ) == 0)
    p = 10;
else
    p = 100;

.
 
Last edited:

MSN1979

Well-Known Member
#16
Hi MSN

Not gone through the code snippet you want to resolve,
but for all conditional loops you give a Boolean Data type (true / false) input
and not an assignment, etc

again a simple e.g. should explain it . . .

Code:
i = 0;
if (SelectedValue( i ) == 0)
    p = 10;
else
    p = 100;

.

Funny thing happened, went into infinite loop when used in for loop

I know I can use break statement in loops, but if in case codes gets executed in infinite loop is there any way to Stop after code execution? Like we can do it in C or java or .Net?

I cant find all this info in amibroker site or google, hence asking.
 
#17
Have you referred to Amibroker Help ?

Do that and search for

Keyword "Break" :)


.
 

MSN1979

Well-Known Member
#18
Have you referred to Amibroker Help ?

Do that and search for

Keyword "Break" :)


.
Thanx for quick reply but I already know how to use Break, I am asking how to stop the loop after execution
I used a pop up window and after that it did not let me do anything else and spammed like millions of popwindows

So is there any way after I have clicked on apply indicator , i can stop the loop while the codee is getting executed real time?
 

MSN1979

Well-Known Member
#19
Happy bro, satish bro, anant bro and HappyLife thanx for your help, my code is working now,

Happy_Singh that line u shared above seemed to have fixed the problem.

I have another problem now, Buy is getting generated multiple times, I only want it to generate once after firstbarofdayhigh is broken.

So I am sharing this code with everyone, the code is very basic, but for new guys like me it took me 3 days to fix it.

// This Code is not 100% error free
// This Code is made on ORB concept of break of 15 min candle high, it works fine on 3 min 5 min but has problems on 1 min as Opening values are lost.

//OBJECTIVE /OUTCOME of this code
//Compare Price of 2 Candles AND Compare it with opening candle High AND then take subsequent action
// If Price breaks high of opening candle in second candle code should check and exit, after that no need to keep comparing
// If price does not break high in 2nd candle or subsequent n candles. it should keep check until a breakout and then break/exit

newday = Day() != Ref( Day(), -1 );
firstbarOfDayOpen = ValueWhen( newday, Open );
firstbarOfDayHigh = ValueWhen( newday, High );
firstbarOfDayLow = ValueWhen( newday, Low );
firstbarOfDayClose = ValueWhen( newday, Close );
GfxTextOut( "First Bar High Value is " + firstbarofDayHigh, 20, 20 );
GfxTextOut( "First Bar Low Value is " + firstbarofDayLow, 20, 40 );

z=0;
if (z<1)
{



if (High[BarCount-1]> SelectedValue(FIRstbarofdayhigh))
{
GfxTextOut( "Higer Bar is Current Bar " + H[BarCount-1], 20, 60 );

y=High[BarCount-1];
GfxTextOut( "Sunny Your Trade Executed @ " + y, 20, 80 );
z=1;
}

if (High[BarCount-1]< SelectedValue(FIRstbarofdayhigh))
{
GfxTextOut( "Sunny is Waiting for a trade " + H[BarCount-1], 20, 80 );

}


}
 
Last edited:

asnavale

Well-Known Member
#20
Hi MSN, is this code meant for Long trades (BUY) only? Is there a different rule for Short trades (SELL). What about Target and Stoploss ? I am asking because I am trying to refine the code.

-Anant
 

Similar threads