Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

if statement

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

    if statement

    I have a strategy which triggers a trade, but when I ask it to trigger the trade, I also ask it to toggle the value of a two variables, but it does not. My Code looks like this;

    if(My criteria)

    {
    EnterLongLimit(
    2,Bollinger(1,21).Lower[0],"Long Recover RTM108");
    SetProfitTarget(
    "Long Recover RTM108", CalculationMode.Price, MyEntryPrice);
    Long1 =
    1;
    Recover =
    1;
    }

    In the above, the entry is made and the target is set, but my variables do not change to "1". I have verified this with the print statement. The variables are of the int type and start out as 0 value. Is my syntax incorrect? Am I limited to the number of lines I can write between the { } ?

    Thanks,

    Safetrading

    #2
    Hello,

    From what I can see here the code looks fine. However my first guess would be that you are not defining the variables properly.

    You will want to ensure your variables are defined in the #Region Variables section above the OnBarUpdate() if you were to define them in the OnBarUpdate() they will be reset every new bar.

    If this doesn't resolve the issue please attach the complete .cs file (or simplified version). If it's not too complex I can take a quick look at it.

    Located in (MY)Documents\NinjaTrader 7\bin\Custom\Strategy
    LanceNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    108 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    156 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    74 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    125 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    79 views
    0 likes
    Last Post PaulMohn  
    Working...
    X