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 f.saeidi, Today, 12:14 PM
    4 responses
    11 views
    0 likes
    Last Post f.saeidi  
    Started by Russ Moreland, Today, 12:54 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Erick  
    Started by philmg, Today, 12:55 PM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_ChristopherJ  
    Started by TradeForge, 04-19-2024, 02:09 AM
    2 responses
    32 views
    0 likes
    Last Post TradeForge  
    Started by aprilfool, 12-03-2022, 03:01 PM
    3 responses
    329 views
    0 likes
    Last Post NinjaTrader_Adrian  
    Working...
    X