Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to Do Something after a stop loss/after exiting ?

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

  • NinjaTrader_Jesse
    replied
    Hello alantse123,

    Thank you for the reply.

    If you are looking for an order fill, you should use OnExecutionUpdate for that purpose as this override deals directly with the scripts executions.
    https://ninjatrader.com/support/help...ub=onexecution

    You have provided the syntax a++ which is valid syntax, you would just need to put that where you want it to be executed. If an order execution is where you would like that to happen, you could put the a++ inside of OnExecutionUpdate within a condition checking for the order you want. We have some examples showing how OnExecution can be used in the help guide link I provided above.

    If you are using the Set methods for the stoploss, you will need to look in the control center orders tab at the orders name and use that in place of the name provided in the sample "myEntryOrder". Upon finding the stop order you could execute the a++ inside of that condition.

    As I am unsure of the scope where you have defined the "a" variable, I would suggest using the help guide sample to implement the OnExecutionUpdate override in your script. At that point, if you are having difficulty with a portion of using this override in contrast to what you have coded, I would suggest uploading what you coded so I can see specifically what you wrote. This would help me to provide more detailed answers surrounding your questions.

    I look forward to being of further assistance.

    Leave a comment:


  • alantse123
    replied
    Sorry for the unclear meaning. What I mean is
    if (EventA)
    {
    a++;
    }
    EventA is "When my stop loss is hit./When I exit by a stop loss but not a profit target".
    How should I code for the above event?
    I want the action "a++" to be taken right after the an exit order is executed, does that mean I should put it inside OnOrderUpdate? If yes, what should the code look like?
    Last edited by alantse123; 12-18-2018, 09:18 PM.

    Leave a comment:


  • NinjaTrader_Jesse
    replied
    Hello alantse123,

    Thank you for the post.

    Your logic would likely work for the purpose you described, but I am unsure what you mean by what to type into the bracket, Can you clarify what you mean by bracket in contrast to the syntax you provided? Is this the stoploss something condition you are speaking about?

    I look forward to being of further assistance.

    Leave a comment:


  • How to Do Something after a stop loss/after exiting ?

    I am building a trend trading strategy. As everyone knows, there would be some 'false trends' recognised by a strategy whenever it is not a strategy perfect for recognising trend. I would like to spot those false trends by counting the times I hit my stop loss in a trend. For example, how should I code if I want to call a trend false after my stop loss has been hit 3 times? I have thought of the following
    if (stoploss something)
    {
    a++;
    }
    and when a = 3, I call this trend a false one. But I just do not know what to type in the bracket.
    Also, I would like to stop entering the market after having 3 profiting trades in a single trend. What should I type in the bracket?
    Thank you!

Latest Posts

Collapse

Topics Statistics Last Post
Started by i2w8am9ii2, Today, 06:29 PM
2 responses
7 views
0 likes
Last Post i2w8am9ii2  
Started by Kirk Thorns, Today, 05:34 PM
0 responses
7 views
0 likes
Last Post Kirk Thorns  
Started by JobDjassem, Today, 05:24 PM
0 responses
12 views
0 likes
Last Post JobDjassem  
Started by Kirk Thorns, Today, 05:06 PM
0 responses
12 views
0 likes
Last Post Kirk Thorns  
Started by CyberNate, Today, 03:11 PM
5 responses
32 views
0 likes
Last Post CyberNate  
Working...
X