NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

Write a note in this area. It's really easy to share _SECTION_BEGIN( "Time-Based Exits" );
tn = TimeNum();

MultATR = Param( "ATR Multiplier", 2, 1, 4, 0.5 );
PerATR = Param( "ATR Period", 14, 3, 89, 1 );
_ATR = ATR( PerATR );

//A Simple Demo strategy
Per = Param( "Swing Periods", 15, 3, 144, 1 );
HigherHighs = HHV( H, Per );
LowerLows = LLV( L, Per );
_Buy = Cross( H, Ref( HigherHighs, -1 ) );
_Short = Cross( Ref( LowerLows, -1 ), L );

//Array Initialization
Buy = Sell = Short = Cover = TSL = Null;
LongFlag = ShortFlag = 0; //Simple flags

//Using Loop to generate signals
for( i = 0; i < BarCount; i++ )
{
//Long Positions
if( _Buy[ i ] AND LongFlag == 0 AND tn[ i ] < 144500 )
{
Buy[ i ] = 1;
LongFlag = 1; //To record that we are in Long position
}
if( LongFlag )
{
if( TSL[ i - 1 ] > H[ i ] - _ATR[ i ] * MultATR )
TSL[ i ] = TSL[ i - 1 ];
else
TSL[ i ] = H[ i ] - _ATR[ i ] * MultATR;
}

if( ( _Short[ i ] OR ( L[ i ] < TSL[ i - 1 ] ) OR tn[ i ] >= 144500 ) AND LongFlag == 1 )
{
Sell[ i ] = 1; //Selling-off the Long position
LongFlag = 0; //Reseting LongFlag back to False, to denote that we are no longer in "Long" position
}

//Short Positions
if( _Short[ i ] AND ShortFlag == 0 AND tn[ i ] < 144500 )
{
Short[ i ] = 1;
ShortFlag = 1; //To record that we are in Short position
}
if( ShortFlag )
{
if( TSL[ i - 1 ] < L[ i ] + _ATR[ i ] * MultATR )
TSL[ i ] = TSL[ i - 1 ];
else
TSL[ i ] = L[ i ] + _ATR[ i ] * MultATR;
}

if( ( _Buy[ i ] OR H[ i ] > TSL[ i - 1 ] OR tn[ i ] >= 144500 ) AND ShortFlag == 1 )
{
Cover[ i ] = 1; //Covering the Short position
ShortFlag = 0; //Reseting ShortFlag back to False, to denote that we are no longer in "Short" position
}
}

//Plotting
Plot( C, "", colorDefault, styleBar | styleThick );
Plot( HigherHighs, "Highs", colorDarkGreen, styleDashed | styleNoRescale );
Plot( LowerLows, "Lows", colorBrown, styleDashed | styleNoRescale );

PlotShapes( IIf( Buy, shapeUpArrow, shapeNone ), colorBrightGreen, 0, L, -30 ); //Long Entry
PlotShapes( IIf( Sell, shapeSmallDownTriangle, shapeNone ), colorBrown, 0, H, -15 ); //Long Exit

PlotShapes( IIf( Short, shapeDownArrow, shapeNone ), colorRed, 0, H, -30 ); //Short Entry
PlotShapes( IIf( Cover, shapeSmallUpTriangle, shapeNone ), colorDarkGreen, 0, L, -15 ); //Short Exit

Plot( TSL, "TSL", colorPink, styleThick | styleNoRescale ); //Trailing Stop-Loss
_SECTION_END();with others. Click here ...
     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.