• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to Reset using BarsSinceExitExecution

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

    How to Reset using BarsSinceExitExecution

    My logic for BarsSinceEntryExecution is working but it seems my integer variable StopBars is not being reset to 0 upon a position exit before my SetStopLoss method call.

    if (BarsSinceEntryExecution()>=0)
    {
    StopBars=BarsSinceEntryExecution();
    }
    else
    {
    StopBars=0;
    }

    // I'm trying to reset my ticks calculation here.
    if (BarsSinceExitExecution()==0)
    {
    StopBars=0;
    }
    DynamicStopTicks=Some Function using StopBars as a Variable);
    SetStopLoss("", CalculationMode.Ticks,DynamicStopTicks, true);
    Last edited by DuggyLou; 04-08-2017, 07:07 AM.

    #2
    I thought about it during the night and I realize that the call of BarsSinceEntryExecution is overwriting the StopBars value on the next OnBarUpdate call. Should be a simple fix by setting a flag once I reset StopBars and modifying my if then statement. looking for whether my flag has been set or not. Thanks

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mike Winfrey, Today, 11:27 AM
    0 responses
    6 views
    0 likes
    Last Post Mike Winfrey  
    Started by swcooke, Yesterday, 07:35 PM
    3 responses
    23 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by brownsfan019, Today, 10:45 AM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_ChrisL  
    Started by brownsfan019, Today, 10:41 AM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_ChrisL  
    Started by bchip, Today, 09:25 AM
    1 response
    17 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X