NexusFi: Find Your Edge


Home Menu

 





Is there a Function like ValueWhen for MultiCharts in EasyLanguage?


Discussion in MultiCharts

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




 
Search this Thread

Is there a Function like ValueWhen for MultiCharts in EasyLanguage?

  #1 (permalink)
milkysahai001
Agra+India
 
Posts: 42 since Sep 2016
Thanks Given: 17
Thanks Received: 3

Have to translate a code from AmiBroker AFL to easylanguage. need a function which works like the ValueWhen function of AFL. Searched in the reserved words book by MC, tried using IFF function but still not able to achieve it.

the code is:

avn=ValueWhen(avd!=0,avd,1);

somebody please help.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
REcommedations for programming help
Sierra Chart
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
MC PL editor upgrade
MultiCharts
Exit Strategy
NinjaTrader
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
43 thanks
Just another trading journal: PA, Wyckoff & Trends
30 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
21 thanks
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,435 since Apr 2013
Thanks Given: 482
Thanks Received: 1,628

milkysahai001,

you can likely accomplish the same with the IFF function. What code did you try for it?
Otherwise you can either code your own function using "if... else.." statements or use them directly in the indicator
code.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
  #3 (permalink)
milkysahai001
Agra+India
 
Posts: 42 since Sep 2016
Thanks Given: 17
Thanks Received: 3



ABCTG View Post
milkysahai001,

you can likely accomplish the same with the IFF function. What code did you try for it?
Otherwise you can either code your own function using "if... else.." statements or use them directly in the indicator
code.

Regards,

ABCTG

ABCTG,

here, I am putting both the codes.

1. afl code:
avd=IIf(C>Ref(res,-1), 1, IIf(C<Ref(sup,-1), -1, 0));
avn=ValueWhen(avd!=0,avd,1);

2. easylanguage version: I tried getting to it with IFF function:
value1 = Iff (C < sup[1], -1, 0);
Avd = Iff (C > res[1], 1, value1);
Avn = Iff (Avd[0] <> 0, Avd, 0);


but the results are coming different from the codes.

Reply With Quote
  #4 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,435 since Apr 2013
Thanks Given: 482
Thanks Received: 1,628

milkysahai001,

you would have to post compileable code at least, that demonstrates the problem. With the code you posted one could only guess.
A description of what your code does and what you want it to do might be helpful, too (with a screenshot for example).

From the way you wrote the code I would guess that you misunderstand how the "ValueWhen" reserved word works and I would suggest to re-read the documentation. Think about what "ValueWhen" will return if avd = 0.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
  #5 (permalink)
milkysahai001
Agra+India
 
Posts: 42 since Sep 2016
Thanks Given: 17
Thanks Received: 3


ABCTG View Post
milkysahai001,

you would have to post compileable code at least, that demonstrates the problem. With the code you posted one could only guess.
A description of what your code does and what you want it to do might be helpful, too (with a screenshot for example).

From the way you wrote the code I would guess that you misunderstand how the "ValueWhen" reserved word works and I would suggest to re-read the documentation. Think about what "ValueWhen" will return if avd = 0.

Regards,

ABCTG

Think about what "ValueWhen" will return if avd = 0.

zero? i guess.

Reply With Quote
  #6 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,435 since Apr 2013
Thanks Given: 482
Thanks Received: 1,628

milkysahai001,

please post the link to the description where it states that.

Regards,

ABCTG


milkysahai001 View Post
Think about what "ValueWhen" will return if avd = 0.

zero? i guess.


Follow me on Twitter Reply With Quote
  #7 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,435 since Apr 2013
Thanks Given: 482
Thanks Received: 1,628

Judging by this link https://www.amibroker.com/guide/afl/valuewhen.html
you will need to find out what the n-th most recent occurrence exactly means here.

It sounds like
 
Code
avn=ValueWhen(avd!=0,avd,0);
would be the most recent one, but does this mean
 
Code
avn=ValueWhen(avd!=0,avd,1);
is from one bar ago or is it actually the prior occurrence before the last one, which could be X bars ago.

I don't work with AFL and can't say for sure unfortunately.

The first case would be simple, but the second one might require a bit more programming as you'd have to find the
prior occurrence first.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
  #8 (permalink)
milkysahai001
Agra+India
 
Posts: 42 since Sep 2016
Thanks Given: 17
Thanks Received: 3


ABCTG View Post
Judging by this link https://www.amibroker.com/guide/afl/valuewhen.html
you will need to find out what the n-th most recent occurrence exactly means here.

It sounds like
 
Code
avn=ValueWhen(avd!=0,avd,0);
would be the most recent one, but does this mean
 
Code
avn=ValueWhen(avd!=0,avd,1);
is from one bar ago or is it actually the prior occurrence before the last one, which could be X bars ago.

I don't work with AFL and can't say for sure unfortunately.

The first case would be simple, but the second one might require a bit more programming as you'd have to find the
prior occurrence first.

Regards,

ABCTG


ABCTG,

I have the same confusion about the nth most recent bar. i will dig more. Thanks for your inputs.

Reply With Quote
  #9 (permalink)
milkysahai001
Agra+India
 
Posts: 42 since Sep 2016
Thanks Given: 17
Thanks Received: 3

ABCTG,






Please find the attached images. one is the right signals in Amibroker the other is wrong-ish Indicator in Multicharts where i am not able to get signals.

Reply With Quote




Last Updated on November 25, 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