• 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 taylorv817, Today, 07:19 PM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by asmmbillah, Today, 05:13 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by firstlanetech, Today, 01:05 AM
    2 responses
    16 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by rgoudie, Today, 08:11 PM
    0 responses
    2 views
    0 likes
    Last Post rgoudie
    by rgoudie
     
    Started by futures2020, 03-19-2020, 03:08 PM
    2 responses
    22 views
    0 likes
    Last Post ccl3093
    by ccl3093
     
    Working...
    X