Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trade /ES on VIX chart

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

    Trade /ES on VIX chart

    Hello, I would like to run a strategy on a VIX chart (primary bars), but place trades on /ES (secondary bars). I have cobbled together example code below, however, it doesn't do what I want to achieve. Any help on how to do this would be appreciated.

    Code:
            protected override void Initialize()
            {
                CalculateOnBarClose = true;
                Add("ES ##-##", PeriodType.Day, 1);
            }
    
            protected override void OnBarUpdate()
            {
            if (BarsInProgress != 0)
                return;
            
                // Long Entry #1
                if (CrossAbove(SMA(5), SMA(20), 1))
                {
                    EnterLong(1, DefaultQuantity, "LEn1");
                }
    
                // Long Exit #1
                if (CrossBelow(SMA(5), SMA(20), 1))
                {
                    ExitLong(1, "LEx1", "LEn1");
                }
            }

    #2
    It looks okay by reading the code... can you be more specific as to what it is not doing? Is it disabling?


    Open an output window to check for any error messages if it is disabling.

    You might have a CurrentBar check issue?

    Comment


      #3
      Thanks Sledge. I opened the output window and I saw what was going on. In my original code I didn't specify BarsInProgress parameter with BarsSinceEntry() > 10.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      580 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      335 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      554 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      552 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X