Coding an Exit method - AmiBroker | futures io social day trading

Coding an Exit method
 Updated: May 2nd, 2015 (09:51 AM) Views / Replies: 3,205 / 11 Created: May 2nd, 2014 (12:18 AM) by Alessandro47 Attachments: 0

 Welcome to futures io.

# Coding an Exit method

 June 1st, 2014, 04:21 PM #11 (permalink) Elite Member Toronto, Canada   Futures Experience: Advanced Platform: Amibroker, Multicharts Favorite Futures: Stocks   Posts: 3 since Mar 2013 Thanks: 0 given, 1 received Trailing Stops A few good examples of trailing stops in Amibroker. From the Traders Tips section of Technical Analysis of Stocks and Commodities magazine, May 2009: Version(5.20); // requires v5.20 SetBarsRequired(sbrAll); // get start date Start = Cross( DateNum(), ParamDate(„Start date”, „2005-10-30” ) ); Started = Flip( Start, 0 ); StopMode = ParamToggle(„Stop Mode”, „Fixed|Chandelier” ); StopLevel = Param(„Fixed perc %”, 14, 0.1, 50, 0.1)/100; StopATRFactor = Param(„Chandelier ATR multiple”, 4, 0.5, 10, 0.1 ); StopATRPeriod = Param(„Chandelier ATR period”, 14, 3, 50 ); // calculate support and resistance levels if( StopMode == 0 ) // fixed percent trailing stop { sup = C * ( 1 - stoplevel ); res = C * ( 1 + stoplevel ); } else // Chandelier ATR-based stop { sup = C - StopATRFactor * ATR( StopATRPeriod ); res = C + StopATRFactor * ATR( StopATRPeriod ); } // 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 = Start OR Cross( C, trailArray ); Sell = Cross( trailArray, C ); PlotShapes(Buy*shapeUpArrow,colorGreen,0,trailarray); PlotShapes(Sell*shapeDownArrow,colorRed,0,trailarray); Plot( Close,”Price”,colorBlack,styleBar); Plot( trailARRAY,”trailing stop level”, colorRed ); —Tomasz Janeczko

Futures Experience: Intermediate
Platform: AMIBROKER
Favorite Futures: Stocks

Posts: 2 since Sep 2014

 A few good examples of trailing stops in Amibroker. From the Traders Tips section of Technical Analysis of Stocks and Commodities magazine, May 2009: Version(5.20); // requires v5.20 SetBarsRequired(sbrAll); // get start date Start = Cross( DateNum(), ParamDate(„Start date”, „2005-10-30” ) ); Started = Flip( Start, 0 ); StopMode = ParamToggle(„Stop Mode”, „Fixed|Chandelier” ); StopLevel = Param(„Fixed perc %”, 14, 0.1, 50, 0.1)/100; StopATRFactor = Param(„Chandelier ATR multiple”, 4, 0.5, 10, 0.1 ); StopATRPeriod = Param(„Chandelier ATR period”, 14, 3, 50 ); // calculate support and resistance levels if( StopMode == 0 ) // fixed percent trailing stop { sup = C * ( 1 - stoplevel ); res = C * ( 1 + stoplevel ); } else // Chandelier ATR-based stop { sup = C - StopATRFactor * ATR( StopATRPeriod ); res = C + StopATRFactor * ATR( StopATRPeriod ); } // 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 = Start OR Cross( C, trailArray ); Sell = Cross( trailArray, C ); PlotShapes(Buy*shapeUpArrow,colorGreen,0,trailarray); PlotShapes(Sell*shapeDownArrow,colorRed,0,trailarray); Plot( Close,”Price”,colorBlack,styleBar); Plot( trailARRAY,”trailing stop level”, colorRed ); —Tomasz Janeczko

please , i need to change the start date from long side to short side
thanks

 futures io > Coding an Exit method

Upcoming Webinars and Events (4:30PM ET unless noted)

Elite only

Elite only

January

## Ran Aroussi: TBA

Elite only

 Similar Threads Thread Thread Starter Forum Replies Last Post Pitrader EasyLanguage Programming 5 January 30th, 2014 10:12 AM sr114 AmiBroker 2 January 16th, 2013 11:46 AM DarkPoolTrading Traders Hideout 1 May 28th, 2012 05:47 AM buylosellhi MultiCharts 6 November 15th, 2011 09:38 PM johni EasyLanguage Programming 10 July 1st, 2011 07:44 AM

All times are GMT -4. The time now is 08:46 PM.

 Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io All information is for educational use only and is not investment advice.There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-10 in 0.08 seconds with 19 queries on phoenix via your IP 54.83.122.227