Quote from TraderSystem:
Please show some examples.
Copied from Multi-Charts (have highlighted the copyright)
SX profit-target-cum-trailing-stop. The ATR-based profit target becomes active immediately after the entry-bar (the entry-bar is not protected). If the target is not reached in NumBars, the profit target is replaced by a tight trailing stop (based on the previous high).
The IntrabarOrderGeneration attribute is set to false in this strategy because strategy calculations depend on end-of-bar prices. Specifically, the average true range calculation uses end-of-bar prices.
}
[IntrabarOrderGeneration = false]
inputs:
ATRLength( 5 ),
NumATRs( 2 ),
NumBars( 5 ) ;
variables:
MP( 0 ),
TargetPrice( 0 ) ;
MP = MarketPosition ;
if MP = -1 then
begin
if MP[1] <> -1 then
TargetPrice = EntryPrice - AvgTrueRange( ATRLength ) * NumATRs ;
if BarsSinceEntry < NumBars then
Buy To Cover ( "ATTSX-Tgt" ) next bar at TargetPrice limit
else
Buy To Cover ( "ATTSX-Trl" ) next bar at High stop ;
end ;
{ ** Copyright (c) 2005 TradeStation Technologies, Inc. All rights reserved. **
** TradeStation reserves the right to modify or overwrite this strategy component with each release. * }
{ Single-return wrapper function calling multiple-output function; see MULTIPLE-OUTPUT FUNCTIONS note below }
inputs:
Length( numericsimple ) ; { this input assumed to be a constant >= 1 }
variables:
oDMIPlus( 0 ),
oDMIMinus( 0 ),
oDMI( 0 ),
oADX( 0 ),
oADXR( 0 ),
oVolty( 0 ) ;
Value1 = DirMovement( H, L, C, Length, oDMIPlus, oDMIMinus, oDMI, oADX, oADXR, oVolty ) ;
ADX = oADX ;
{
MULTIPLE-OUTPUT FUNCTIONS
A multiple-output function has two types of parameters or "inputs" - input parameters and input/output parameters. The values of the input parameters are passed into the multiple-output function, but not modified by the function. The values of the input/output parameters are passed into the multiple-output function, modified by it, and the modified values are then inherited by - or output to - the calling routine.
The input/output parameters are often used for output purposes only, i.e., the incoming values are ignored. The outputs are in addition to the function return. In multiple-output functions, the function return is generally used to return an error code, though sometimes the return may simply be a dummy value.
The input/output parameters are declared with a "ref" suffix (such as "numericref") in the multiple-output function's declaration statements. For further clarity, the names of the input/output parameters are generally prefixed with an "o" in the function as well as in all the routines that call the function.
The built-in single-return WRAPPER FUNCTIONS that call the multiple-output functions are specialized calling routines designed to offer simplified, alternate pathways to the functionality of the underlying multiple-output functions. In the wrapper functions, the input/output parameters are declared as local variables and generally initialized to zero. They are passed through to the multiple-output function without further modification. After the call, the wrapper function picks out the single output of interest and assigns it as the return of the wrapper function.}
{ ** Copyright (c) 1991-2003 TradeStation Technologies, Inc. All rights reserved. **
** TradeStation reserves the right to modify or overwrite this analysis technique with each release. ** }