NexusFi: Find Your Edge


Home Menu

 





Suggestions for this code please: SetPercentTrailing


Discussion in TradeStation

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




 
Search this Thread

Suggestions for this code please: SetPercentTrailing

  #1 (permalink)
 highjohn 
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 ;

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
How to apply profiles
Traders Hideout
REcommedations for programming help
Sierra Chart
Trade idea based off three indicators.
Traders Hideout
About a successful futures trader who didnĀ“t know anyth …
Psychology and Money Management
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
  #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


© 2024 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 - Privacy Policy - Downloads - Top
no new posts