Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Conditional Stop-Loss query

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

    Conditional Stop-Loss query

    Hi,

    I was wondering if it is possible to program a stop-loss that activates only if volatility rises above a certain level. Basically I am running a strategy with the following stop-loss programmed in the Initialize() section: SetStopLoss("", CalculationMode.Ticks, stop, true);

    This works fine, however I noticed that in low volatility days I am often stopped out despite no real trend talking place. Is it possible to apply a volatility filter so that the stop-loss is only activated when standard deviation is above a certain threshold? would this need to be programmed in the OnBarUpdate() section? If yes, would the following code make the trick?

    Code:
      
           protected override void Initialize()
            {
                Add(PeriodType.Day, 1);
                CalculateOnBarClose = true;
                EntryHandling     =    EntryHandling.UniqueEntries;
                ExitOnClose = false;
            }
            protected override void OnBarUpdate()
            {
                [B]//Enter long condition with volatility filter[/B]
                if (CrossAbove(...)
                    && ATR(BarsArray[1],atrlength)[0] >= 1.5)
                {
                    EnterLong();
                    SetStopLoss("", CalculationMode.Ticks, stop, true);
                }
    
               [B] //Enter long condition[/B]
                if (CrossAbove(...)
                {
                    EnterLong();
                }

Latest Posts

Collapse

Topics Statistics Last Post
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
0 responses
648 views
0 likes
Last Post Geovanny Suaza  
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
0 responses
369 views
1 like
Last Post Geovanny Suaza  
Started by Mindset, 02-09-2026, 11:44 AM
0 responses
108 views
0 likes
Last Post Mindset
by Mindset
 
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
0 responses
572 views
1 like
Last Post Geovanny Suaza  
Started by RFrosty, 01-28-2026, 06:49 PM
0 responses
574 views
1 like
Last Post RFrosty
by RFrosty
 
Working...
X