Disable/Rest Strategy - futures io
futures io futures trading



Disable/Rest Strategy


Discussion in NinjaTrader

Updated
    1. trending_up 665 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 5 posts
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Disable/Rest Strategy

(login for full post details)
  #1 (permalink)
Brooklyn + New York/USA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: NQ, YM, 6E
 
Posts: 6 since Dec 2017
Thanks: 4 given, 1 received

I have searched for the life cycle of NinjaScript for NT7 but I wasn't able to find it. I have a strategy that I don't want to over trade, so I will be enabling my strategy and it will activate an ATMStrategy. For now what I have

private bool tradeAgain = true;

protected override void OnBarUpdate()
{

if(tradeAgain)
{

// programming logic

}

tradeAgain = false;

}

After the trade, whether its profit or loss, I want to be able to make the variable tradeAgain = true.

I am wondering if I disable the strategy, and then enable it again, will variable tradeAgain be true or false?

Started this thread Reply With Quote

Can you help answer these questions
from other members on futures io?
Webinar: Finding your own way in trading w/Adam Grimes
The Elite Circle
If ES tracks SPX, why do support/resistance, Level 2, vo …
Emini and Emicro Index
Automating strategies on multiple charts with same symbol
TradeStation
OFA (Order Flow Analytics) Licence
NinjaTrader
SimplerOptions
Trading Reviews and Vendors
 
 
(login for full post details)
  #3 (permalink)
charlotte nc
 
Experience: Master
Platform: ninjatrader
Broker: NinjaTrader
Trading: Emini (ES, YM, NQ, ect.)
 
Posts: 398 since Jan 2015
Thanks: 76 given, 1,081 received


If you want to trade or not trade based on if your last trade was a profit or not you will need something like this.



// In order to run this, you have to call the method below to check and make sure there is at least one trade in the
// collection otherwise it will just error out.

if (Performance.RealtimeTrades.Count > 1)
{

// get variables to hold information about the last trade

Trade lastTrade = Performance.RealtimeTrades[Performance.RealtimeTrades.Count - 1];
double lastProfit = lastTrade.ProfitCurrency * lastTrade.Quantity;

// Run condition to check if the last trade was profitable or not
if(lastProfit > 0)
{
// last trade was a winner do something
}

if (lastProfit <0)
{
// last trade was a loser do something
}


}


In terms of disabling or enabling your strategy, you can do something inside of the code blocks I have provided. There are a number of easy way to tell it to trade or not trade.

Visit my futures io Trade Journal Reply With Quote
The following user says Thank You to iantg for this post:
 
(login for full post details)
  #4 (permalink)
Brooklyn + New York/USA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: NQ, YM, 6E
 
Posts: 6 since Dec 2017
Thanks: 4 given, 1 received


iantg View Post
If you want to trade or not trade based on if your last trade was a profit or not you will need something like this.



// In order to run this, you have to call the method below to check and make sure there is at least one trade in the
// collection otherwise it will just error out.

if (Performance.RealtimeTrades.Count > 1)
{

// get variables to hold information about the last trade

Trade lastTrade = Performance.RealtimeTrades[Performance.RealtimeTrades.Count - 1];
double lastProfit = lastTrade.ProfitCurrency * lastTrade.Quantity;

// Run condition to check if the last trade was profitable or not
if(lastProfit > 0)
{
// last trade was a winner do something
}

if (lastProfit <0)
{
// last trade was a loser do something
}


}


In terms of disabling or enabling your strategy, you can do something inside of the code blocks I have provided. There are a number of easy way to tell it to trade or not trade.


Thanks. Will this be for each script or will it take into account all the trades? I need it to run separately on each script. And if lastprofit > 0, simple return will suffice?

Started this thread Reply With Quote
 
(login for full post details)
  #5 (permalink)
charlotte nc
 
Experience: Master
Platform: ninjatrader
Broker: NinjaTrader
Trading: Emini (ES, YM, NQ, ect.)
 
Posts: 398 since Jan 2015
Thanks: 76 given, 1,081 received

The way the code works it is only looking at the last trade.
The variable lastTrade is indexed to -1 which means it will always look at the last trade. You can add a new variable called twotradesago and index it to -2, and do threetradesago with -3, etc. Each of these would be a different trade variable and you would have to extract the p&l stats the same way.

VariableName.ProfitCurrency for example. But I think if all you are looking for is the last trade then go with the -1 index and you have it.

Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #6 (permalink)
Brooklyn + New York/USA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: NQ, YM, 6E
 
Posts: 6 since Dec 2017
Thanks: 4 given, 1 received


iantg View Post
The way the code works it is only looking at the last trade.
The variable lastTrade is indexed to -1 which means it will always look at the last trade. You can add a new variable called twotradesago and index it to -2, and do threetradesago with -3, etc. Each of these would be a different trade variable and you would have to extract the p&l stats the same way.

VariableName.ProfitCurrency for example. But I think if all you are looking for is the last trade then go with the -1 index and you have it.

Thank you very much!

Started this thread Reply With Quote


futures io Trading Community Platforms and Indicators NinjaTrader > Disable/Rest Strategy


Last Updated on December 13, 2017


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
 

Importance of Finding Your Own Way w/Adam Grimes

Elite only
 

Journal Challenge w/Jigsaw

April
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts