NexusFi: Find Your Edge


Home Menu

 





Variable value set by output condition of IF


Discussion in NinjaTrader

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




 
Search this Thread
  #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?
Help re translation of ninjascript to EL
NinjaTrader
Elite Trader Funding, Avoid?
Funded Trading Evaluation Firms
MC PL editor upgrade
MultiCharts
tick data interval discrepancy
NinjaTrader
MC Advanced Simulated Trading.
MultiCharts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
ApexTraderFunding.com experience and review
78 thanks
What is Markets Chat (markets.chat) real-time trading ro …
54 thanks
HumbleTraders next chapter
38 thanks
Tao te Trade: way of the WLD
27 thanks
1 Minute Man
22 thanks
  #3 (permalink)
 
xplorer's Avatar
 xplorer 
London UK
Site Moderator
 
Experience: Beginner
Platform: CQG
Broker: S5
Trading: Futures
Posts: 6,013 since Sep 2015
Thanks Given: 15,601
Thanks Received: 15,561



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 - Sitemap - Downloads - Top
no new posts