Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Beginner Advice Needed

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

  • NinjaTrader_ChelseaB
    replied
    Hello hifreq,

    You can use SetStopLoss at any time including in an if statement.

    Once the stop loss has been set with SetStopLoss, you will not be able to remove the stop loss, however, you can modify the price at which it is sitting.

    If you are only wanting to exit the trade when particular conditions are true (and not after the conditions were true but no longer are), it may be better to an exit order.

    Leave a comment:


  • hifreq
    replied
    A little off topic here. But how do I write a Stoploss with an if statement. meaning i only want it to trigger or be true "if" a condition is met?
    does it matter where in the code i insert the code for a stoploss

    Leave a comment:


  • NinjaTrader_Brett
    replied
    Hello,

    What instrument are you trading on and if you switch to the points mode for the account performance report by selected it in the drop down menu to the right of the generate button does it show now?

    If not toggle between the orders tab and the account performance tab to refresh it and try generate again.

    -Brett

    Leave a comment:


  • pswarts
    replied
    Now a paid Ninja customer whooohooo, quick question, when I do Market Replay and enter treades even while I stay connected to market replay when I pick the Replay account and the instrument I traded on it does not generate anything, keep showing just 0.00's , no report. Please advise how I can fix this

    Leave a comment:


  • NinjaTrader_Brett
    replied
    PSwarts,

    Yes that should do the trick. If you run into further problem please let me know what output you are getting that is not expected so we know where to isolate.

    -Brett

    Leave a comment:


  • pswarts
    replied
    How do I set my stoploss to be (x)ticks below the lowest low of last three bars,when I make the changes as shown it does not work
    SetStopLoss(
    "Entry3", CalculationMode.Price, MIN(Low, 3)[0], true);
    changed to
    SetStopLoss("Entry3", CalculationMode.Price, MIN(Low, 3)[0]-20, true);
    I presume it has to do with Price vs Ticks but does not know how to fix it

    Oh think I found it: is this the correct way?:
    SetStopLoss("Entry3", CalculationMode.Price, MIN(Low, 3)[0]-20 * TickSize, true);
    Last edited by pswarts; 12-13-2011, 03:14 AM.

    Leave a comment:


  • koganam
    replied
    Originally posted by pswarts View Post
    The strategy as discussed above when backtesting , give me frequent Exit on Close orders with (to me ) random distances from the entry orders at times, at other times the orders execute properly ,but I have no ExitLong or any other Exit for that matter in my code at all. Please advise on what the problem may be. Tnx

    On the attached image the 2nd stoploss was at low of last three bars which is correct, the first order with an ExitOnClose makes no sense. I can attach more images if you need to demonstrate
    I believe that ExitOnClose = true; is the default. If you do not have any ExitOnClose statement, then you will be closed at exit.

    Leave a comment:


  • NinjaTrader_Bertrand
    replied
    pswarts, do you intend to hold positions overnight with this strategy? Then simply add ExitOnClose = false; to your Initialize() section and recompile - and those NT end of session exits should be disabled.

    Leave a comment:


  • pswarts
    replied
    con'd
    // Once 2st Profittarget attained, set stop loss to trail by Low of (x)bars
    elseif (High[0] > Position.AvgPrice + ((2*Profitfactor) * (ATR(20)[0]))
    &&MIN(Low ,
    3)[0] > Position.AvgPrice)
    {
    SetStopLoss(
    "Entry3", CalculationMode.Price, MIN(Low, 3)[0], true);
    }
    }
    // Entry Conditions
    if (EMA(Ema)[0] > EMA(Ema)[1]
    && SMA(Sma)[
    0] > SMA(Sma)[1]
    && EMA(Ema)[
    0] > SMA(Sma)[0]
    && Close[
    0] > Open[0]
    && Position.MarketPosition == MarketPosition.Flat)
    {
    EnterLong(
    100, "Entry1");
    EnterLong(
    100, "Entry2");
    EnterLong(
    100, "Entry3");
    }
    }

    Leave a comment:


  • pswarts
    replied
    cont'd
    // Once 1st Profittarget attained, set stop loss to breakeven
    if (High[0] >= Position.AvgPrice + ((1*Profitfactor) * (ATR(20)[0]))
    &&High[
    0] <= Position.AvgPrice + ((2*Profitfactor) * (ATR(20)[0]))
    &&Close[
    0] > Position.AvgPrice )

    {
    SetStopLoss("Entry2", CalculationMode.Price, Position.AvgPrice, true);
    SetStopLoss(
    "Entry3", CalculationMode.Price, Position.AvgPrice, true);
    }

    Leave a comment:


  • pswarts
    replied
    code cont'd
    // If a long position is open, allow for stop loss and target modification
    elseif (Position.MarketPosition == MarketPosition.Long)
    {
    SetProfitTarget(
    "Entry1", CalculationMode.Price, Position.AvgPrice+((1*Profitfactor) * (ATR(20)[0])));
    SetProfitTarget(
    "Entry2", CalculationMode.Price, Position.AvgPrice+((2*Profitfactor) * (ATR(20)[0])));
    SetStopLoss(
    "Entry1", CalculationMode.Price, MIN(Low, 3)[0], true);
    SetStopLoss(
    "Entry2", CalculationMode.Price, MIN(Low, 3)[0], true);
    SetStopLoss(
    "Entry3", CalculationMode.Price, MIN(Low, 3)[0], true);

    Leave a comment:


  • pswarts
    replied
    My current code as follows
    protectedoverridevoid OnBarUpdate()
    {
    // Resets the stop loss and Targets to the original value when all positions are closed
    if (Position.MarketPosition == MarketPosition.Flat)
    {
    SetStopLoss(
    "Entry1", CalculationMode.Ticks, Stopfactor*3000, false);
    SetStopLoss(
    "Entry2", CalculationMode.Ticks, Stopfactor*3000, false);
    SetStopLoss(
    "Entry3", CalculationMode.Ticks, Stopfactor*3000, false);
    SetProfitTarget(
    "Entry1", CalculationMode.Ticks, 3000);
    SetProfitTarget(
    "Entry2", CalculationMode.Ticks, 3000);
    }

    Leave a comment:


  • pswarts
    replied
    The strategy as discussed above when backtesting , give me frequent Exit on Close orders with (to me ) random distances from the entry orders at times, at other times the orders execute properly ,but I have no ExitLong or any other Exit for that matter in my code at all. Please advise on what the problem may be. Tnx

    On the attached image the 2nd stoploss was at low of last three bars which is correct, the first order with an ExitOnClose makes no sense. I can attach more images if you need to demonstrate
    Attached Files
    Last edited by pswarts; 12-08-2011, 02:34 AM.

    Leave a comment:


  • koganam
    replied
    Originally posted by pswarts View Post
    Just to confirm: I'm to add the following between my Initialize and OnBarUpdate ?
    protected override void Initialize ()
    SetProfitTarget("Entry1", CalculationMode.Ticks, 200);
    SetProfitTarget("Entry2", CalculationMode.Ticks, 200);


    protected override void OnStartUp ()
    SetProfitTarget("Entry1", CalculationMode.Price, (1*Profitfactor) * (ATR(20)[0]));
    SetProfitTarget("Entry2", CalculationMode.Price, (2*Profitfactor) * (ATR(20)[0]));


    protected override void OnBarUpdate ()
    asbefore........
    Pretty much. Remember to reset your SetProfitTarget() when you go flat.

    Leave a comment:


  • pswarts
    replied
    Just to confirm: I'm to add the following between my Initialize and OnBarUpdate ?
    protected override void Initialize ()
    SetProfitTarget("Entry1", CalculationMode.Ticks, 200);
    SetProfitTarget("Entry2", CalculationMode.Ticks, 200);


    protected override void OnStartUp ()
    SetProfitTarget("Entry1", CalculationMode.Price, (1*Profitfactor) * (ATR(20)[0]));
    SetProfitTarget("Entry2", CalculationMode.Price, (2*Profitfactor) * (ATR(20)[0]));


    protected override void OnBarUpdate ()
    asbefore........

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by SalmaTrader, 07-07-2026, 10:26 PM
0 responses
103 views
0 likes
Last Post SalmaTrader  
Started by CarlTrading, 07-05-2026, 01:16 PM
0 responses
62 views
0 likes
Last Post CarlTrading  
Started by CaptainJack, 06-17-2026, 10:32 AM
0 responses
28 views
0 likes
Last Post CaptainJack  
Started by kinfxhk, 06-17-2026, 04:15 AM
0 responses
36 views
0 likes
Last Post kinfxhk
by kinfxhk
 
Started by kinfxhk, 06-17-2026, 04:06 AM
0 responses
40 views
0 likes
Last Post kinfxhk
by kinfxhk
 
Working...
X