NexusFi: Find Your Edge


Home Menu

 





Variable value set by output condition of IF


Discussion in NinjaTrader

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




 
Search this Thread

Variable value set by output condition of IF

  #1 (permalink)
 b16aln 
London
 
Experience: None
Platform: ninjatrader
Trading: ftse100
Posts: 67 since Sep 2017
Thanks Given: 11
Thanks Received: 23

Hello,

Does anyone here know how to set a variable value based on the output of an IF statement so that my variable value is dependent on the IF outcome?

I tried the code below but I am not getting any value outputs for varA1

double varA1:

if(condition)
{varA1 = value1}
else
{varA1 = value2}

Many thanks in advance

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
ZombieSqueeze
Platforms and Indicators
MC PL editor upgrade
MultiCharts
How to apply profiles
Traders Hideout
Exit Strategy
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #3 (permalink)
 
xplorer's Avatar
 xplorer 
London UK
Site Moderator
 
Experience: Beginner
Platform: CQG
Broker: S5
Trading: Futures
Posts: 5,973 since Sep 2015
Thanks Given: 15,490
Thanks Received: 15,386



b16aln View Post
Hello,

Does anyone here know how to set a variable value based on the output of an IF statement so that my variable value is dependent on the IF outcome?

I tried the code below but I am not getting any value outputs for varA1

double varA1:

if(condition)
{varA1 = value1}
else
{varA1 = value2}

Many thanks in advance

You can download and open most code available in the Downloads section and see for yourself.


For example, this snippet works

 
Code
					if (L0 >= A)       
					{ 
						deltaM =   tv;	
					} 
					
				   	if (L0 <= B)       
					{ 
						deltaM =  -tv;	
					}


It's probably a matter of using the right syntax.

Reply With Quote
  #4 (permalink)
 b16aln 
London
 
Experience: None
Platform: ninjatrader
Trading: ftse100
Posts: 67 since Sep 2017
Thanks Given: 11
Thanks Received: 23

Thanks, got it. My IF statement logic was wrong....

Started this thread Reply With Quote




Last Updated on July 25, 2019


© 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