Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
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 for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
When setting a Boolean value in strategy builder NinjaScript
I enter a trade and set that Boolean value to true.
Then when I exit I have two variations of exits.
One is by an indicator another is if profit target is hit.
Issue is if profit target hits I don’t know where that gets hit to where I can set that Boolean value back to false because it gets triggered outside of the on bar update method.
This is when I use the SetProfitTarget();
Maybe I’m just having a brain fart but any help is appreciated
Can you help answer these questions from other members on NexusFi?
If your boolean only tracks if you have a position or not, I would recommend just using MarketPosition instead of your boolean. If MarketPosition == MarketPosition.Flat then you don't have a position.
I don't know which event would suit you best. Some of them will trigger on any order update, so you would have to check the parameters to only set your boolean when an order is filled and not on any update.
Use the first option if possible. It's the simplest
This worked out. I guess maybe I was calling it wrong before?? No idea.
Does anyone know how to basically hold off before taking a trade.
So what I mean is. Say a specific type of trade triggered. So lets say I enter a short and it has a specific type of tag for it. I save that tag and it goes through the trade and finishes. The tag is still saved but now I want it to wait for at least 4 bars to complete before I want it to reevaluate the indicators its looking at to see if it should re-enter a trade again.
So trade enters short -> trade closes -> tag saved -> waits 4 bars while tag is a specific type. After 4 bars tag is cleared and strategy goes back to reevaluating the setups to determine if it should re-enter again.
I figured out the 4 bars situation. Hopefully this helps someone else:
// Only enter if at least 4 bars has passed since our last exit or if we have never traded yet
if ((BarsSinceExitExecution() > 4 || BarsSinceExitExecution() == -1) && CrossAbove(SMA(10), SMA(20), 1))
EnterLong();