NexusFi: Find Your Edge


Home Menu

 





how to setup condition which change another condition in strategy?


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one rleplae with 2 posts (1 thanks)
    2. looks_two Tomass with 2 posts (0 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 msfinedu with 1 posts (0 thanks)
    1. trending_up 1,460 views
    2. thumb_up 1 thanks given
    3. group 4 followers
    1. forum 5 posts
    2. attach_file 1 attachments




 
Search this Thread

how to setup condition which change another condition in strategy?

  #1 (permalink)
 Tomass 
Prague Czech republic
 
Experience: Beginner
Platform: Ninjatrader
Trading: Futures
Posts: 4 since Sep 2015
Thanks Given: 1
Thanks Received: 0

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
Click image for larger version

Name:	Snímek obrazovky (52).png
Views:	176
Size:	98.1 KB
ID:	216399  
Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Exit Strategy
NinjaTrader
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
ZombieSqueeze
Platforms and Indicators
Deepmoney LLM
Elite Quantitative GenAI/LLM
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
38 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
GFIs1 1 DAX trade per day journal
19 thanks
The Program
18 thanks
  #3 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 3,003 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,863


You can use boolean flag's.

your additional condition would then set or reset the flag.

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #4 (permalink)
 Tomass 
Prague Czech republic
 
Experience: Beginner
Platform: Ninjatrader
Trading: Futures
Posts: 4 since Sep 2015
Thanks Given: 1
Thanks Received: 0


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!

Started this thread Reply With Quote
  #5 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 3,003 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,863


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 :



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

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #6 (permalink)
 msfinedu 
Chennai, India
 
Experience: Intermediate
Platform: IB
Trading: ES
Posts: 1 since Apr 2012
Thanks Given: 2
Thanks Received: 0

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




Last Updated on September 14, 2016


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts