Return to Snippet

Revision: 43812
at March 31, 2011 07:55 by ram321


Initial Code
[LegacyColorValue = true]; 
[IntrabarOrderGeneration = false];

//	Range expansion template for TradeStation with RSI conditions


Variables:
maxexposure(1000),
type(2),
sharetotrade(1),	
Length(55),
pct(2),
FastAvg(0),
MedAvg(0),
SlowAvg(0),
totalup(0),
totaldown(0),
totalflat(0),
upi(0),
downi(0),
flati(0),
upd(0),
downd(0),
flatd(0),
upw(0),
downw(0),
flatw(0),
Tim1(0),
Tim2 (0) ,
ShareOrPosition(0) ,
ProfitTargetAmt (0),
StopLossAmt(0) ,
BreakevenFloorAmt(0) ,
DollarTrailingAmt(0) ,
PctTrailingFloorAmt (0) ,
PctTrailingPct(0) ,
ExitOnClose(false) ,nshares(0),
peak(0),valley(0),trend(0),SIMController(1);



Tim1 =1230 ;
Tim2 =1230 ;
ShareOrPosition= 1 ;
ProfitTargetAmt =12; 

BreakevenFloorAmt= 0 ;
DollarTrailingAmt =0 ;
PctTrailingFloorAmt =10 ;
PctTrailingPct= 20 ;
ExitOnClose= true ;


if type=1 then nshares=maxexposure/average(close,10);
if type=2 then nshares=sharetotrade;


FastAvg = AverageFC( c, 5 ) ;
MedAvg = AverageFC( c, 15 ) ;
SlowAvg = AverageFC( c, 30 ) ;




Condition1=Range<Average(Range, Length*pct);  

If Time >=Tim1 and Time <=Tim2  then begin; 
IF MarketPosition<>1 and 
   TradesToday(date)<1
   and Condition1 then 
   Buy Nshares shares Next Bar at Highest(High,Length)+1 point Stop;  
  //1 point == 1 tick
   
 
 IF MarketPosition<>-1 and 
   TradesToday(date)<1
   and Condition1  then
   Sell Short Nshares shares Next Bar at Lowest(Low,Length)-1 point Stop;


end;


if ShareOrPosition = 1 then 
	SetStopShare
else
	SetStopPosition ;

if ProfitTargetAmt > 0 then
	SetProfitTarget( ProfitTargetAmt ) ;

if  (Rsi(c,10)< 70 and  Rsi(c,10)> 30) 
	then begin
	SetStopLoss(250); 
	end  
	else if (Rsi(c,10)> 70 )or  (Rsi(c,10)< 30 and Rsi(c,10)< Rsi(c,10)[1])
        and  barssinceentry> 1 then SetStopLoss(1600)  ;


if BreakevenFloorAmt > 0 then
	SetBreakeven( BreakevenFloorAmt ) ;
if DollarTrailingAmt > 0  then
	SetDollarTrailing( DollarTrailingAmt ) ;
if PctTrailingFloorAmt > 0 and PctTrailingPct > 0 then 
	SetPercentTrailing( PctTrailingFloorAmt, PctTrailingPct ) ;
if ExitOnClose = true then 
	SetExitOnClose ;

Initial URL


Initial Description


Initial Title
automated trading - code1

Initial Tags


Initial Language
C