Durham, North Carolina
Experience: Beginner
Platform: TS
Trading: Futures
Posts: 26 since Mar 2022
Thanks Given: 24
Thanks Received: 2
|
Hello,
Thanks in advance. Can some kind soul suggest a replica that I can use instead of setpercentrailing that works in Intrabar as well? I would like this "fire" within a bar/next tick.
It works with my strategy pretty well as long as Intrabar is NOT turned on.
===========================================================
inputs:
MovingAverageLength( 10 ),
PercentPriceChange( 1 ),
MaximumDailyLoss( 500 ),
InitialStopLossAmount( 200 ),
TrailEnableAmount( 200 ),
TrailPercent( 25 ),
TradeWithTrend( true ) ;
variables:
MovAvgValue( 0 ),
MovAvgUpperBand( 0 ),
MovAvgLowerBand( 0 ),
MaxLossReached( false ),
StartingPL( 0 ),
PL( 0 ),
CS( 0 ) ;
once SetStopContract ;
MovAvgValue = Average( Close, MovingAverageLength ) ;
MovAvgUpperBand = MovAvgValue
+ MovAvgValue * PercentPriceChange * .01 ;
MovAvgLowerBand = MovAvgValue
- MovAvgValue * PercentPriceChange * .01 ;
CS = CurrentSession( 0 ) ;
PL = OpenPositionProfit + NetProfit ;
// Max Loss For Session
if CS <> CS[1] then
begin
StartingPL = PL[1] ;
MaxLossReached = false ;
end ;
if StartingPL - PL >= MaximumDailyLoss then
MaxLossReached = true ;
if MaxLossReached = true then
begin
Sell ( "MaxLoss LE" ) next bar at Market ;
Buy To Cover ( "MaxLoss SE" ) next bar at Market ;
end
else
begin
if TradeWithTrend then
begin
if Close < MovAvgUpperBand then
Buy ( "MA Trend LE" ) next bar
at MovAvgUpperBand Stop ;
if Close > MovAvgLowerBand then
Sell Short ( "MA Trend SE" ) next bar
at MovAvgLowerBand Stop ;
end
else
begin
if Close < MovAvgUpperBand then
SellShort ( "MA Fade SE" ) next bar
at MovAvgUpperBand Limit ;
if Close > MovAvgLowerBand then
Buy ( "MA Fade LE" ) next bar
at MovAvgLowerBand Limit ;
end ;
end ;
SetStopLoss( InitialStopLossAmount ) ;
SetPercentTrailing( TrailEnableAmount, TrailPercent ) ;
SetExitOnClose ;
|