Simple Coding Help - No Promise.

Sirs,
Following Para is lifted from Zerodha Zconnect WebPage:

" Instead of having a fixed stop loss, if you want the stop loss to trail, that is automatically go up/down when the contract moves in your direction, click on trailing SL and along with the SL mention trailing ticks. Trailing ticks will be the movement of the contract/stock for which the SL will change.
Let me explain this with an example, Nifty is at 6807, I decide to short expecting some retracement, my target is 400 ticks (20 points – 6787) and stop loss is 200 ticks (10 points – 6817).
If I choose Trailing Stoploss of 200 ticks(10 points) and select Trailing ticks as 40 (2 points). What this would mean is that when Nifty moves from 6807 to 6805 (2 points movement in your direction), automatically the stop will go from 6817 to 6815, similarly if Nifty goes from 6807 to 6804, the stop loss would also move to 6814. So if I had used a trailing SL, when markets went to 6790 my SL would now have been 6800 which would get executed on the way up and conserving my profits. "


Is it Possible to Code (or already available) an AFL wid the EXACT above Conditions (preferably in Points Mode ) which wud Generate SELL / COVER Signals when the above conditions r met.

Thank U All

...Shiraj....
 
hi friends,

I want to apply the following system.
Buy = Cross (ema 5, ema 20)
Sell = Cross ( ema 20 , ema 5) Or trailing stop after 5 same color bars in direction of buy.

I have coded this in afl however I am not able to achieve 2nd part of sell.

Consec5 = Close>Ref(Close,-1)AND Ref(Close,-1)>Ref( Close,-2) AND Ref(Close,-2)>Ref( Close,-3)
AND Ref(Close,-3)>Ref( Close,-4) AND Ref(Close,-4)>Ref( Close,-5);

This above condition tests if previous 5 candles are up or not.
If Consec5= True then Sell should be close below previous bar low.
This condition must continue till Sell signal is hit or Cross over of ema(20,5)

This is what i have done but 2nd part is not working
Sell= Cross(EMA (C,5),EMA (C,20)) OR (Consec5 AND Close <= Ref(Low,-1));
Thank you
 
Sirs,
Following Para is lifted from Zerodha Zconnect WebPage:

" Instead of having a fixed stop loss, if you want the stop loss to trail, that is automatically go up/down when the contract moves in your direction, click on trailing SL and along with the SL mention trailing ticks. Trailing ticks will be the movement of the contract/stock for which the SL will change.
Let me explain this with an example, Nifty is at 6807, I decide to short expecting some retracement, my target is 400 ticks (20 points – 6787) and stop loss is 200 ticks (10 points – 6817).
If I choose Trailing Stoploss of 200 ticks(10 points) and select Trailing ticks as 40 (2 points). What this would mean is that when Nifty moves from 6807 to 6805 (2 points movement in your direction), automatically the stop will go from 6817 to 6815, similarly if Nifty goes from 6807 to 6804, the stop loss would also move to 6814. So if I had used a trailing SL, when markets went to 6790 my SL would now have been 6800 which would get executed on the way up and conserving my profits. "


Is it Possible to Code (or already available) an AFL wid the EXACT above Conditions (preferably in Points Mode ) which wud Generate SELL / COVER Signals when the above conditions r met.

Thank U All

...Shiraj....
This ought to do it....
SD = 10; //
TD = 20; // 2 * SD
ShortPrice = ValueWhen(Short, C);
SSL = C + SD;
SSL = Min(Ref(SSL, -1), C + SD);
ST = ShortPrice - TD;
 

cellclinic

Well-Known Member
Hello Friends ...

Need Help once more ...

Kindly let me know that how can i make layout in amibroker 5.7 ... Means let say .. 3 charts are opened & i select nifty so both 3 charts gets nifty automatically then if i selected crudeoil all 3 charts switched to crudeoil and so on ...

Kindly help me with the solution ....
 

casoni

Well-Known Member
Hello ,
How about this ... for stoploss of 20 points

[Altered Tomasz Janeczko code ]


sup=L - 20;
res=H+20;

ta = Null;
ts = 0;
for( i = 1; i < BarCount; i++ )
{

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

ta[ i ] = ts;
}
Plot(ta,"Stop",6,512);
plot(Close,"",3,132);
 
Hello Friends ...

Need Help once more ...

Kindly let me know that how can i make layout in amibroker 5.7 ... Means let say .. 3 charts are opened & i select nifty so both 3 charts gets nifty automatically then if i selected crudeoil all 3 charts switched to crudeoil and so on ...

Kindly help me with the solution ....
Right click on chart... go to symbol Link and select a Link there (Eg: Link 1). Do the same for all the three windows and from then on, any change will be across all three window
 

Similar threads