how to setup condition which change another condition in strategy? - NinjaTrader Programming | futures.io
futures.io futures trading


how to setup condition which change another condition in strategy?
Started:September 12th, 2016 (06:25 PM) by Tomass Views / Replies:195 / 5
Last Reply:September 14th, 2016 (09:13 AM) Attachments:1

Welcome to futures.io.

Welcome, Guest!

This forum was established to help traders (especially futures traders) by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

We are fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.


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, and we will never resell your private information.

-- Big Mike

Reply
 
Thread Tools Search this Thread
 

how to setup condition which change another condition in strategy?

Old   #1 (permalink)
Elite Member
Prague Czech republic
 
Futures Experience: Beginner
Platform: Ninjatrader
Favorite Futures: Futures
 
Posts: 3 since Sep 2015
Thanks: 1 given, 0 received

how to setup condition which change another condition in strategy?

Hello guys, I am struggling finish my automatic strategy. Strategy is nearly done, just missing one last step. Hope it will be more clear from picture

I have a strategy which works with 3 indicators.
One shows me high/low till 15:30
Second shows me high/low of a day.
third shows me EMA slope (green, grey, red)

Situation 1:if ema slope is green-> if open> "high till 15:30 "= buy signal

Situation 2:if ema slope turns red -> since that time if open > high of a day = buy signal.

If EMA slope is green whole day, my entries are based on "high till 15:30" whole day.. But if Ema slope turns red (at least once, no matter if it turns back to green again) - since that moment entries only: if open > "current high of day" = buy signal(no high till 15:30 anymore...

my problem is that I do not know how to code that change. Basically - if indicator EMA slope turns red, I need to replace order (if open> "high till 15:30 "= buy signal) by order (if open > "current high of day"= buy signal).

Hope it makes some sence what I am trying to code. Will be glad for any advice.

Concrete codes for my strategy:

1. "If open> high till 15:30 -> buy"(that is what I want until some indicator change does not appear)

if (Open[0] >= HiLoOfTimeRange_WithTargetNT7(8, 0, 15, 30, 0, 0).TheHigh[0]
&& EMA (100)[0] > EMA(200)[0]
&& Open[0] > EMA(100)[0]
&& ToTime(Time[0]) >= ToTime(15, 30, 0)
&& ToTime(Time[0]) <= ToTime(21, 30, 0))
{
EnterLong(DefaultQuantity, "high breakout");
}

2. "indicator change". If that condition appears, it will trigger a change.

if (EMA (100)[0] > EMA(200)[0]
&& (EMA(100)[0] == emaslopes2(5, 15, 30, 100).EMAslopedown[0]
|| EMA(100)[0] == emaslopes2(5, 15, 30, 100).EMAdown[0])
&& ToTime(Time[0]) >= ToTime(15, 30, 0)
&& ToTime(Time[0]) <= ToTime(21, 30, 0))


3. new conditions: "if open> high of a day ->buy"

if (Open[0] >= BTH_OHLbyDay(0).CurrentHigh[1]
&& EMA (100)[0] > EMA(200)[0]
&& Open[0] > EMA(100)[0]
&& ToTime(Time[0]) >= ToTime(15, 30, 0)
&& ToTime(Time[0]) <= ToTime(21, 30, 0))
{
EnterLong(DefaultQuantity, "superlong");
}

I just do not know how to make it work all together. I was thinking about using Count if somehow, but I am not sure. Will be glad for any idea or advice. I tried ninjatrader support, but no luck.

Attached Thumbnails
how to setup condition which change another condition in strategy?-snimek-obrazovky-52-.png  
Reply With Quote
 
Old   #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
Old   #3 (permalink)
Elite Member
Omer עומר / Israel י
 
Futures Experience: Master
Platform: NinjaTrader, Proprietary,
Broker/Data: Ninjabrokerage/IQfeed + Synthetic datafeed
Favorite Futures: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, CL, ZB, ZN, ZC, ZS, GC
 
rleplae's Avatar
 
Posts: 1,651 since Sep 2013
Thanks: 1,211 given, 2,488 received
Forum Reputation: Legendary


You can use boolean flag's.

your additional condition would then set or reset the flag.

Reply With Quote
The following user says Thank You to rleplae for this post:
 
Old   #4 (permalink)
Elite Member
Prague Czech republic
 
Futures Experience: Beginner
Platform: Ninjatrader
Favorite Futures: Futures
 
Posts: 3 since Sep 2015
Thanks: 1 given, 0 received


rleplae View Post
You can use boolean flag's.

your additional condition would then set or reset the flag.

Thank you for your advice, I will definitely do some research. To be honest, I am not very good with Ninjascript and never heard about boolean flags before. Do you know any code, or example how it works and how to use it in coding? I will try my research anyway hopefully will find some info. Thank you for your advice once again anyway!

Reply With Quote
 
Old   #5 (permalink)
Elite Member
Omer עומר / Israel י
 
Futures Experience: Master
Platform: NinjaTrader, Proprietary,
Broker/Data: Ninjabrokerage/IQfeed + Synthetic datafeed
Favorite Futures: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, CL, ZB, ZN, ZC, ZS, GC
 
rleplae's Avatar
 
Posts: 1,651 since Sep 2013
Thanks: 1,211 given, 2,488 received
Forum Reputation: Legendary

Futures Edge on FIO

Which products do you trade?

 

Tomass View Post
Thank you for your advice, I will definitely do some research. To be honest, I am not very good with Ninjascript and never heard about boolean flags before. Do you know any code, or example how it works and how to use it in coding? I will try my research anyway hopefully will find some info. Thank you for your advice once again anyway!

From an educational point of view, you may want to look at the following :

https://futures.io/elite-automated-trading/32559-ron-s-alpha-trade-method-ninjatrader-advanced-trade-management-bot.html

At the start of the strategy you will see various booleans that drive particular behavior..

Reply With Quote
 
Old   #6 (permalink)
Elite Member
Chennai, India
 
Futures Experience: Intermediate
Platform: IB
Favorite Futures: ES
 
Posts: 1 since Apr 2012
Thanks: 2 given, 0 received

Like rleplae suggests reading that thread will definitely hep you learn many things and you should.

Basically if you are going to get to code, you need to have a basic idea of syntax and programming or every small obstacle will tire you. If you haven't gone through NinjaTrader Version 7 please go through to begin with.

In your case in the variable section declare the following:

bool cond1 = false;
bool cond2 = false;
bool cond3 = false;

In your barupdate method, inside each if condition just set the above flags to true

Outof all the ifs you can create the following or whatever combination to go long

if (cond1 && cond2 && cond3)

This is just to get you to the next step while you learn a bit of programming. All the best

MS

Reply With Quote

Reply



futures.io > > > > > how to setup condition which change another condition in strategy?

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

2016 True Edge Awards: Voting is open until Jan 21!

Now
 

Bookmap New Indicator Panel, Cumulative Delta, Order Flow demo

Jan 17

An Afternoon with FIO member Massive I

Elite only

Leo Murphy: Making sense of Technical Analysis and Random Walk

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
link an exit condition to a particular entry condition vegtrip ThinkOrSwim 0 October 12th, 2013 09:49 AM
Strategy Template with Condition counter nanook77 Elite Automated Trading 6 April 2nd, 2012 09:58 PM
to get NT to perform an action only once while a strategy condition is true richwaters NinjaTrader Programming 3 February 28th, 2011 09:38 PM
Same condition every hour rajafx1 NinjaTrader Programming 5 August 13th, 2010 06:43 AM
Strategy Condition Logic >> my wetware Trader.Jon NinjaTrader Programming 2 May 24th, 2010 05:17 PM


All times are GMT -4. The time now is 11:10 AM.

no new posts
Page generated 2017-01-16 in 0.12 seconds with 20 queries on phoenix via your IP 54.147.253.45