NexusFi: Find Your Edge


Home Menu

 





Variable value set by output condition of IF


Discussion in NinjaTrader

Updated
    1. trending_up 717 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?
Has anyone taken trading from Agnieska Wood - Ahead Coach?
Psychology and Money Management
Radarscreen
TradeStation
MC PL editor upgrade
MultiCharts
Topstep experience and review
Trading Reviews and Vendors
tick data interval discrepancy
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
ApexTraderFunding.com experience and review
135 thanks
1 Minute Man
60 thanks
HumbleTraders next chapter
42 thanks
Winning attitudes create winning traders
36 thanks
Vinny E-Mini & Algobox Review TRADE ROOM
25 thanks
  #3 (permalink)
 
xplorer's Avatar
 xplorer 
London UK
Site Moderator
 
Experience: Beginner
Platform: CQG
Broker: S5
Trading: Futures
Posts: 6,007 since Sep 2015
Thanks Given: 15,582
Thanks Received: 15,543



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