NexusFi: Find Your Edge


Home Menu

 





Suggestions for this code please: SetPercentTrailing


Discussion in TradeStation

Updated
    1. trending_up 829 views
    2. thumb_up 0 thanks given
    3. group 3 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 highjohn 
Durham, North Carolina
 
Experience: Beginner
Platform: TS
Trading: Futures
Posts: 34 since Mar 2022
Thanks Given: 42
Thanks Received: 3

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 ;


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Second Night of US Strikes Crushes Iran June 15 to 3.6% …
Prediction Markets & Event Contracts
Would a node-based workflow for automated trading be useful?
Traders Hideout
May 26 Deadline Dies at 7.5% as US Strikes Iran During C …
Prediction Markets & Event Contracts
Sundays Verdict: Lebanon Locked at 99.85% as Iran June 7 …
Prediction Markets & Event Contracts
Irans Dual Probability: Guns Quiet at 99.95% While Forma …
Prediction Markets & Event Contracts
 
  #2 (permalink)
 njh1618 
Provo, Utah
 
Experience: Advanced
Platform: TradeStation
Trading: NQ, YM, RTY, ES, US, CL, EC, JY
Posts: 5 since Mar 2020
Thanks Given: 1
Thanks Received: 5

HighJohn,

What Symbol and ChartType are you using for this strategy and what issues are you having?

Neil


Reply With Quote




Last Updated on April 22, 2023


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts