Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

SetTrailStop()

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

    SetTrailStop()


    Ok, when I enter a trade TraceOrders tells me...

    Entered internal PlaceOrder() method at 4/4/2007 11:30:00 AM: Action=SellShort OrderType=Limit Quantity=2 LimitPrice=1.3414 StopPrice=0 SignalName=EXTREME short 3 4/4/2007 11:30:00 AM' FromEntrySignal=''

    The TrailStop get's set to it's initial value, which is 12 ticks...

    Entered internal SetStopTarget() method at 4/4/2007 11:30:00 AM: Type=TrailStop FromEntrySignal='EXTREME short 3 4/4/2007 11:30:00 AM' Mode=Ticks Value=12 Currency=0 Simulated=False

    Then I run my TrackTrade() in OnBarUpdate()...

    if
    (Position.MarketPosition != MarketPosition.Flat) {

    if (Position.GetProfitLoss(Close[0], PerformanceUnit.Points) >= 4){

    int stopLoss = 2;

    Print(
    "Setting stop to "+stopLoss+" in "+instrumentName+" at "+Time[0]);

    SetTrailStop(orderName, CalculationMode.Ticks, stopLoss,
    false);

    }

    The Print() outputs properly, indicating that this indeed get's called, however,TraceOrders does not display that the TrailStop() get's changed from 12 to 2.

    Steer me in the right direction please.

    #2
    imported post

    This would suggest thatthis the SetTrailStop() is not getting called if there was no trace output. I checked our code and there is nothing once a call to this method is made that would prevent a trace ouput.

    The only thing left to do is start stripping down the strategy and debug.

    What I would do is create a base strategy that sets the initial trail stop in the Initialize() method, then in OnBarUpdate() call it again with a different offset value and run the strategy. This should show the trace output with the change.

    Then start adding components until you get to a point where it does not behave as expected.

    Ray
    RayNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by trilliantrader, Today, 03:01 PM
    1 response
    4 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Started by geddyisodin, Today, 05:20 AM
    6 responses
    34 views
    0 likes
    Last Post geddyisodin  
    Started by pechtri, 06-22-2023, 02:31 AM
    9 responses
    122 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by frankthearm, 04-18-2024, 09:08 AM
    16 responses
    67 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Started by habeebft, Today, 01:18 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X