Simple Coding Help - No Promise.

ocil

Well-Known Member
#11
Don't know about the magic, but i recently changed my primary intraday charts to the one posted by Pratap here on TJ . . . and i have been coding for years :D

He must have spent 100s of hours developing those charts over a period of time . . . If we appreciate getting, then no harm in trying to give back a little . . ,

Cheers

:) Happy
Hi Happy Sing can you post the link of Pratap post. Thanks for your help. :thumb:
 
#13
any one tell me can i add sound effect in amibroker when my price reach to my target price.

For eg. I purchase Bank nifty @ 10500 and my target is 10650 and stoploss is 10475.

I want to set alert if price reach to 10650 and second alert if price reach to my stop loss price 10475.

if any one know about these pls tell me.

thank you seniors in advance,.
i got the answer.but the problem is i donno how to use this.can you pl explain how it can be done HAPPY?
AlertIF function has limitations that the chart must be active when this alert goes off . . .

So if you are in your kitchen munching something and the chart is active you will get the alert. . .
but if you are at the trading desk but browsing some interesting sites the alert may not sound . . . .

code is simple and must be also there in amibroker help

Code:
AlertIF( Sell, "SOUND C:\\Windows\\Media\\Ding.wav", "Audio alert", 2 );
use any sound file you need, just make sure to change the path in the above line, notice that we need to use an extra dash i.e. \\ instead of one \

instead of sell u can use the condition cross(H, My_Target)

Sample Code . . .

Code:
T = Param("MY Target",5990,5000,6250,10);
S = Param("MY Stop L",5930,5000,6250,10);

AlertIf(Cross(H,T), "SOUND C:\\Windows\\Media\\Ding.wav", "Target alert", 2 );
AlertIf(Cross(S,L), "SOUND C:\\Windows\\Media\\Ding.wav", "Stop alert", 2 );

Plot(T, "Target", colorRed, styleThick);  	
Plot(S, "Stop", colorRed, styleThick);
 
Last edited:

mastermind007

Well-Known Member
#15
#16
Hello Friends

I am starting this thread for helping anyone who requires small changes in AFLs or AFL coding done for small / simple requirements that can be clearly defined.

What does not go is conversion . . . from Amibroker to anything else . . . or from anything else to Amibroker . . .

Debugging requested for copy/paste AFLs, Please don't post huge AFLs with zillions of lines of code for debugging

I will not be available for any conversions and I am not interested in debugging some-one else's copy/pasted work and lastly . . .
Not interested in hacking/craking any ones work . . .

Only if have a clearly definable task to be coded I maybe able to help . . . No Promises but will try within my limitations . . .


As an example, recently one of our friends wanted a motivational message to be included in his Charts,
I enjoyed doing that, as i could easily empathize with why he wanted that . . .


Cheers

:) Happy
Very nice initiative Happy ....... :thumb: :clapping:
 
#17
Hi Happy! Thanks for your excellent offer! It would be a pity not to avail of it. May I ask for your expert advice on two coding issues? Here they go.....

1) I want to store a value in variable X and do not want to lose it when it will be initialised at the next loop...
......
......
X=0;
X=X+1;///I want to store this value of X which is now= 1
STRX=NumToStr(X,1.0, true);
NUMX=StrToNum (STRX);
X=NUMX;

This should return a value of 1 for X and should not become 0 even after initialisation at X=0 line. But I am getting a syntax error message at the NUMX line.

2) Sell=IIf (close<=0.998*priceatbuy,1,0);

This line is supposed to sell when the current price is <= 0.998 * buy price and NOT to do anything otherwise. Am I correct? But it is doing nothing at all.

Would be obliged to get help.
 
#18
Hello Sandip

Not an expert by any count

1) I want to store a value in variable X and do not want to lose it when it will be initialised at the next loop...
......
......
X=0;
X=X+1;///I want to store this value of X which is now= 1
STRX=NumToStr(X,1.0, true);
NUMX=StrToNum (STRX);
X=NUMX;

This should return a value of 1 for X and should not become 0 even after initialisation at X=0 line. But I am getting a syntax error message at the NUMX line.
Not really clear about this requirement, . . .

Ambroker deals with everything as arrays, i.e when we say

x = Close;

the value assigned is actually that of the current bar, effectively the above is equivalent to

x = Close and x[i+1] = Close[i+1] and so on . . .

So as the bar change the value of x will change, if you want x to carry a value when specific condition is true try using

x = ValueWhen(EXPRESSION, ARRAY, n = 1) ;

Also look at use of Get/Set StaticVariable, some sample code from ami library

Code:
procedure xStaticVarSet( SName, SValue )
{
 global SVKey;
 InIndicator = Status("Action") == 1;
 if( InIndicator ) StaticVarSet(Sname+SVKey, Svalue);
}
function xStaticVarGet( SName )
{
 global SVKey;
 if( IsNull( Var = StaticVarGet(Sname+SVKey) ) ) Var = 0;;
 return Var;
}
URL for above: http://www.amibroker.com/library/detail.php?id=1213&hilite=StaticVarSet

Let me know if any of this was helpful.

2) Sell=IIf (close<=0.998*priceatbuy,1,0);

This line is supposed to sell when the current price is <= 0.998 * buy price and NOT to do anything otherwise. Am I correct? But it is doing nothing at all.

Would be obliged to get help.
Amibroker Help file has a sample code . . .

Code:
Buy = Cross( MACD(), Signal() ); 

priceatbuy=0; 

for( i = 0; i < BarCount; i++ ) 
{ 
     if( priceatbuy == 0 && Buy[ i ] ) 
     priceatbuy = BuyPrice[ i ]; 

     if( priceatbuy > 0 && SellPrice[ i ] > 1.1 * priceatbuy ) 
     { 
       Sell[ i ] = 1; 
       SellPrice[ i ] = 1.1 * priceatbuy; 
       priceatbuy = 0; 
     } 
     else 
       Sell[ i ] = 0; 
}
Here they are using it for target you can easily convert it into stop loss sell :)

Cheers

:) Happy
 

dell

Well-Known Member
#19
very nice initiative for helping fellow traders .......thank you sirji ...........

sir , plz add explorer lines for exploring/scanning of yellow candles in below code .....

_SECTION_BEGIN("Price");
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

w = Wilders(C,20);
CandlCol = IIf(L > w, colorGreen, IIf(H < w, colorRed,colorYellow));
SetBarFillColor(IIf(C < O, CandlCol, GetChartBkColor()) );
Plot(C,"",CandlCol,styleCandle|styleNoTitle);
Plot(W, "Wilders", IIf(w > Ref(w,-1), colorGreen, colorRed),styleThick);

_SECTION_END();

thanks a lot ....
 
#20
very nice initiative for helping fellow traders .......thank you sirji ...........

sir , plz add explorer lines for exploring/scanning of yellow candles in below code .....

_SECTION_BEGIN("Price");
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

w = Wilders(C,20);
CandlCol = IIf(L > w, colorGreen, IIf(H < w, colorRed,colorYellow));
SetBarFillColor(IIf(C < O, CandlCol, GetChartBkColor()) );
Plot(C,"",CandlCol,styleCandle|styleNoTitle);
Plot(W, "Wilders", IIf(w > Ref(w,-1), colorGreen, colorRed),styleThick);

_SECTION_END();

thanks a lot ....
In amibroker exploration has 2 parts
1. the condition for which you want to filter rows
2. formatting of the output

as you already know the condition it becomes v simple just equate it to the keyword filter

Code:
Filter=(L < w) AND (H > w);
For formatting check keyword AddColumn in ami help few samples

Code:
AddColumn( Close, "Close", 1.2 );
AddColumn( MACD(), "MACD", 1.4 , IIf( MACD() > 0, colorGreen, colorRed ) );
AddTextColumn( FullName(), "Full name", 77 , colorDefault );

Cheers

:) Happy
 

Similar threads