Revision: 43813
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at March 31, 2011 07:56 by ram321
Initial Code
[LegacyColorValue = true];
[IntrabarOrderGeneration = false];
// Tradestation Range expansion and other conditions V2
Variables:
maxexposure(1000),
type(2),
sharetotrade(1),
Length(55),
pct(12),
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);
Tim1 =1230 ;
Tim2 =1240 ;
ShareOrPosition= 1 ;
ProfitTargetAmt =12;
BreakevenFloorAmt= 0 ;
DollarTrailingAmt =0 ;
PctTrailingFloorAmt =1;
PctTrailingPct= 5 ;
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 {and other conditions} then
Buy Nshares shares Next Bar at Highest(High,Length)+1 point Stop;
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( 600) ;
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 - code2
Initial Tags
Initial Language
C