Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Entering OnPriceChange, exiting on full BarClose using Swing

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Entering OnPriceChange, exiting on full BarClose using Swing

    Background for discussion purposes:
    • Strategy calc set to OnPriceChange - minute candlesticks are basis for trade - tick replay enabled on chart when testing
    • Entry is calculated OnPriceChange using various indicators (indicators not relevant to issue)
    • Looking to exit when price crosses the most recent previous Swing (high or low not particularly relevant to issue)
    • Noticed from Swing indicator code that it is set to calculate OnBarClose
    • I'm reasonably familiar with Swing behavior, how it calculates, etc
    • MUCH research and reviewing of help guides, forum posts, etc has been done but open to all suggestions
    • I have print statements throughout my strategy
    Issue where help would be appreciated:
    • When looking to exit a position on price cross of previous swing, the Swing value strategy is able to calculate is not same as swing plot on chart
      • Code sample - if Close[0] < High[Math.Max(0, Swing1.SwingHighBar(0, 1, varSwingPeriod*2))]
    • I'm guessing Swing sees each price change as a new "bar close" and uses that to base it's calc on and not a full bar close, but looking to experts on that theory
    • Given the PriceChange calc approach, what can be done to allow Swing to calc on full bar close and rest of logic OnPriceChange?
      • I thought of adding another data series but didn't see a way to have series 0 be OnPriceChange and series 1 to be OnBarClose.
    • Help, please! :-)

    #2
    Hello cshox,

    With the swing that can be difficult because its plot values are not constant and will be re written. To use the swing you need to manually code the strategy and use its custom methods which return a finalized swing value based on the instance. The swing has the SwingHighBar and SwingLowBar methods which return an instance of a swing.



    The OnPriceChange aspect of your script shouldn't matter other than the swings plots can be re written intran bar which leads to further deviations from the instance that eventually gets plotted.

    Comment


      #3
      Thanks Jesse. I failed to mention in my intro I'm in Editor not in Builder - manually coding from scratch and I'm using the SwingHighBar method per my code snippet in intro. Maybe I can further simplify the question:
      • Swing indicator plots exactly what I need for my strategy. I'm plotting the indicator on the chart from within the strategy code. Somehow the indicator logic is making the swing lines appear where I need them to be. I know there is a lag in Swing calculations and I know they can adjust intrabar but yet it puts the lines up on the screen in the "right place".
      • How can I access what it's plotting? I'm open to overriding or extending Swing code to customize indicator if that's how.
      Apologies but it's just frustrating and confusing how it plots one things but reports another to strategy - I'm guessing it's something I don't understand so frustration is with me not NT. :-)

      Comment


        #4
        Hello cshox,

        If the swings custom methods are not providing the value you wanted then you would have to incorporate the entire swing logic into your strategy. The swing indicator is not intended to be used as a signal as mentioned in its help guide page so anything beyond what it does currently would involve you making you own custom code. It has custom methods that can be used to find finalized swing instances, the plots it shows on the chart are not finalized so they will change as the strategy tries to read the plot values.

        Comment


          #5
          Thank you for the explanation and your time.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          52 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          130 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          70 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          44 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          49 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X