Amibroker with IB

bunti_k23

Well-Known Member
#52
Test it on multiple tf 1min to hourly also include the backtesting func in this code it is nt happening.
 
#54
am trying to make this autotrading but for some reason because this file is repainting the multiple orders are going on every signal - so we cannot judge if the file has been profitable in the day or not

can you add a line to the afl that will append the valid signals price and time in a file for later analysis

i havent found a code to do that anywhere on the net.

will fix that and run the file in real market data, a paper trading account and test it out

today at
5 s the afl was profitable and the number of trades is very high
5 m the afl was profitable but the trades were very less
 

bunti_k23

Well-Known Member
#55
am trying to make this autotrading but for some reason because this file is repainting the multiple orders are going on every signal - so we cannot judge if the file has been profitable in the day or not

can you add a line to the afl that will append the valid signals price and time in a file for later analysis

i havent found a code to do that anywhere on the net.

will fix that and run the file in real market data, a paper trading account and test it out

today at
5 s the afl was profitable and the number of trades is very high
5 m the afl was profitable but the trades were very less
Dont know bro how to repair that repainting part maybe a coder shd help us , yes u try by urself thank u.
 

pareshR

Well-Known Member
#56
StopMode = ParamList("Stop Mode", "Fixed|Chandelier|Modified ATR" );

StopLevel = Param("Fixed perc %", 1, 0.1, 5, 0.1)/100;

StopATRFactor = Param("ATR multiple", 4, 0.5, 10, 0.1 );
StopATRPeriod = Param("ATR period", 14, 3, 50,1 );

// calculate support and resistance levels
if( StopMode == "Fixed" ) // fixed percent trailing stop
{
sup = C * ( 1 - stoplevel );
res = C * ( 1 + stoplevel );
}
else // Chandelier ATR-based stop
if( StopMode == "Chandelier" )
{
sup = C - StopATRFactor * ATR( StopATRPeriod );
res = C + StopATRFactor * ATR( StopATRPeriod );
}
else
{
HL = H - L;
MAHL = 1.5 * MA( HL, StopATRPeriod );
HiLo = IIf( HL < MAHL, HL, MAHL );
H1 = Ref( H, -1 );
L1 = Ref( L, -1 );
C1 = Ref( C, -1 );
Href = IIf( L <= H1, H - C1, ( H - C1 ) - ( L - H1 ) / 2 );
Lref = IIf( H >= L1, C1 - L, ( C1 - L ) - ( L1 - H ) / 2 );

diff1 = Max( HiLo, HRef );
diff2 = Max( diff1, LRef );

ATRmod = Wilders( diff2, StopATRPeriod );

sup = C - StopATRFactor * ATRmod ;
res = C + StopATRFactor * ATRmod ;
}

// calculate trailing stop line
trailARRAY = Null;
trailstop = 0;
for( i = 1; i < BarCount; i++ )
{
//if( Started[ i ] == 0 ) continue;

if( C[ i ] > trailstop AND C[ i - 1 ] > trailstop )
trailstop = Max( trailstop, sup[ i ] );
else
if( C[ i ] < trailstop AND C[ i - 1 ] < trailstop )
trailstop = Min( trailstop, res[ i ] );
else
trailstop = IIf( C[ i ] > trailstop, sup[ i ], res[ i ] );

trailARRAY[ i ] = trailstop;
}

// generate buy/sell signals based on crossover with trail stop line
Buy = Cross( C, trailArray );
Sell = Cross( trailArray, C );

PlotShapes(Buy*shapeUpArrow,colorGreen,0,trailarray);
PlotShapes(Sell*shapeDownArrow,colorRed,0,trailarray);

Plot( Close,"Price",colorBlack,styleBar);
//SetBarFillColor( colorYellow );
TRAILCOLOR =IIf(C>trailARRAY,colorBlue,colorRed);
Plot( trailARRAY,"trailing stop level", TRAILCOLOR, styleLine );

In this afl use these settings and post the results here.
then You can try with different settings and find which is more suitable.


image hosting free

Hello

How to manage Stop loss ? ( one and 3 minutes charts)

generally i m following " trailing stop loss ", but when market high volatile then its very high (stock likes Tatasteel, Tatamot, Rcap, Rinfra etc)

thx
 

bunti_k23

Well-Known Member
#57
Dear bait waiting eagerly for ur reply......:D
 
#58
Dear bait waiting eagerly for ur reply.....
have managed to test position and then send the buy order at the buy signal
think have fixed the non repainting code somehow - not fixed but did a workabout.

on the real market condition it seems that 5 s time frame generates small losses on everytrade - nifty futures and every buy & sell will generate a loss of 150 to 500 rs

now trying it in the one minute time frame. will let it run for whole day will post a pic and trade log of today.
 
#59
pareshR
Hello

How to manage Stop loss ? ( one and 3 minutes charts)

generally i m following " trailing stop loss ", but when market high volatile then its very high (stock likes Tatasteel, Tatamot, Rcap, Rinfra etc)

thx
1. trailing stop loss : if you are using IB then it has this stop loss. generally stop loss is very tight specially for volatile stocks.

i have not found a way to put the stop loss in the afl but will look into this
so that when a signal comes - i am improving the afl by bunti_k23 am putting stop loss and profit taking orders in the afl

if you have IB the order types that i am putting is as follows

when the afl gives the signals then submit a mkt order,
with an OCA group in which one order is Stop loss - a STP order and other is a Profit taking order - a REL order at the same time so the order instead of using the afl to generate the exit order the exit from the postion will be on hitting either the stop loss or profit taking order.

the profit order should be better than the signals generated by the afl that is my thinking

this implementation will take some time but i guess it will be better than the AFL and will lock in more profit.

if you broker is not ib then you can generally use LMT orders for stop loss
is submit a market order and then if it is filled send a limit order for better protection of funds. LMT orders are there on all brokers.
 

bunti_k23

Well-Known Member
#60
have managed to test position and then send the buy order at the buy signal
think have fixed the non repainting code somehow - not fixed but did a workabout.

on the real market condition it seems that 5 s time frame generates small losses on everytrade - nifty futures and every buy & sell will generate a loss of 150 to 500 rs

now trying it in the one minute time frame. will let it run for whole day will post a pic and trade log of today.
In the afl the signal is generated when the candle closes below the st line.but when the candle is forming and breking the st line and reverting back in this mean time the signals are appearing and disappearing .is that what you called repainting??? If yes then bro u only have to take the trade when the signal candle is completed and another candle is forming and that too if the filter rule is satisfied ,
Buy only when the high of the signal candle brks and sell only when liw of the signal candle brks
 

Similar threads