NexusFi: Find Your Edge


Home Menu

 





Switches in function


Discussion in EasyLanguage Programming

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




 
Search this Thread

Switches in function

  #1 (permalink)
Linow
Odense, Denmark
 
Posts: 3 since May 2021
Thanks Given: 1
Thanks Received: 0

HI I´m trying code a function that has some switches so that I can finde the best filter.
Am I right that is a Boolean type?
I can´t get it to work, some one that knows what I´m missing here?

Input: Filter (numeric);

Switch ( Filter )
Begin
Case 0: xFilter= True;
Case 1: xFilter= Close < Average(Close, 5);
Case 2: xFilter= ADX(5) > 25;
Case 3: xFilter= (Volume > Average(Volume, 5));
End;

xFilter = True;

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
MC PL editor upgrade
MultiCharts
REcommedations for programming help
Sierra Chart
Trade idea based off three indicators.
Traders Hideout
Quantum physics & Trading dynamics
The Elite Circle
 
  #2 (permalink)
 bfulks 
Boston MA
 
Experience: Advanced
Platform: TradeStation
Trading: Stocks and options
Posts: 24 since Aug 2022
Thanks Given: 2
Thanks Received: 4

You are mixing variable types; Try this:

Input: Filter (numeric); // values = 0, 1 , 2, 3, ...
Vars: xFilter(False);

Switch ( Filter )
Begin
Case 0: xFilter= True;
Case 1: xFilter= Close < Average(Close, 5);
Case 2: xFilter= ADX(5) > 25;
Case 3: xFilter= (Volume > Average(Volume, 5));
End;

Bob

Reply With Quote
  #3 (permalink)
Linow
Odense, Denmark
 
Posts: 3 since May 2021
Thanks Given: 1
Thanks Received: 0


Hi Bob

Vars: xFilter(False);
I keep getting: A value was never assigned to user funtion

Do I not need a return value?
It keeps turnning of the strategy when I´m testing it...

Thomas

Reply With Quote
  #4 (permalink)
 TraderDoc2 
Plainview
 
Experience: Intermediate
Platform: TradeStation
Broker: TradeStation
Trading: Futures
Posts: 34 since Mar 2012
Thanks Given: 1
Thanks Received: 21

Here is a simple function and strategy that you can test. The function must have a Boolean (True/False) Return Type. You will optimize the strategy with filter values varying from 0 to 3.
I think that this should work. Give it a try.

 
Code
{Function: NexusFi_Test_1}

Input: Filter (numeric); 
Vars: xFilter(False);

Switch ( Filter )
Begin
Case 0: xFilter= True;
Case 1: xFilter= Close < Average(Close, 5);
Case 2: xFilter= ADX(5) > 25;
Case 3: xFilter= (Volume > Average(Volume, 5));
End;

NexusFi_Test_1 = xFilter;


{Strategy: Test.NexusFi.1}

Input: Filter (1); // values = 0, 1 , 2, 3, ...
Vars: MyBoolean(False);

MyBoolean = NexusFi_Test_1(Filter);

If MyBoolean then Buy next bar at market;
If Not MyBoolean then Sell Short next bar at market;

Follow me on Twitter Reply With Quote
Thanked by:
  #5 (permalink)
Linow
Odense, Denmark
 
Posts: 3 since May 2021
Thanks Given: 1
Thanks Received: 0

Thanks TraderDoc2

Reply With Quote




Last Updated on October 3, 2023


© 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