NexusFi: Find Your Edge


Home Menu

 





EasyLanguage. Code for no script action when condition is met. NT8 Return equivalence


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one futurenow with 4 posts (1 thanks)
    2. looks_two Fu510n with 1 posts (1 thanks)
    3. looks_3 ABCTG with 1 posts (2 thanks)
    4. looks_4 kevinkdog with 1 posts (2 thanks)
      Best Posters
    1. looks_one kevinkdog with 2 thanks per post
    2. looks_two ABCTG with 2 thanks per post
    3. looks_3 Fu510n with 1 thanks per post
    4. looks_4 futurenow with 0.3 thanks per post
    1. trending_up 1,056 views
    2. thumb_up 6 thanks given
    3. group 4 followers
    1. forum 6 posts
    2. attach_file 0 attachments




 
Search this Thread

EasyLanguage. Code for no script action when condition is met. NT8 Return equivalence

  #1 (permalink)
futurenow
Earth planet
 
Posts: 49 since Feb 2017
Thanks Given: 38
Thanks Received: 13

Hello

I’m trying to find an EasyLanguage example about how to work the cases where you want the script doesn’t execute any action of the code (any action of the main logic) when a kind of “general” condition is met, even if the rest of the code contains other conditions that could do certain actions during that general condition. But I’m unable to find examples that covers this kind of cases.

For example, in NinjaScript when you want a strategy doesn’t do anything under a certain general condition, like for example not to place trades on Sundays, then a way to get this is with:

 
Code
if (Time[0].DayOfWeek == DayOfWeek.Sunday)
    return;
And with this simple code as a general condition, then the strategy won’t execute any action when this condition is true, even if the entry condition is met.


Of course I understand that for this specific simple example, in EasyLanguage you could do the opposite with something like:

 
Code
If Dayofweek <> 0 Then
    // you can trade
But that was just a very simple example, just to illustrate the idea, because I need this for other kind of situations (but with a similar base).


By the way, I tried with something like:

 
Code
If Dayofweek = 0 Then
    Return;
But it shows a compilation error saying that “Return keyword can be used only inside a method”, so it seems that `Return` couldn’t be used in the exact way as used in the given NinjaTrader example here, and if possible the idea would be to have an equivalence in a kind of simple and efficient way just as the ` Return` example here.


Thank you for any help

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Exit Strategy
NinjaTrader
Better Renko Gaps
The Elite Circle
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
MC PL editor upgrade
MultiCharts
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
36 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
19 thanks
Spoo-nalysis ES e-mini futures S&P 500
18 thanks
GFIs1 1 DAX trade per day journal
16 thanks
  #2 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,663 since Jul 2012
Thanks Given: 1,892
Thanks Received: 7,356


futurenow View Post
Hello

I’m trying to find an EasyLanguage example about how to work the cases where you want the script doesn’t execute any action of the code (any action of the main logic) when a kind of “general” condition is met, even if the rest of the code contains other conditions that could do certain actions during that general condition. But I’m unable to find examples that covers this kind of cases.

For example, in NinjaScript when you want a strategy doesn’t do anything under a certain general condition, like for example not to place trades on Sundays, then a way to get this is with:

 
Code
if (Time[0].DayOfWeek == DayOfWeek.Sunday)
    return;
And with this simple code as a general condition, then the strategy won’t execute any action when this condition is true, even if the entry condition is met.


Of course I understand that for this specific simple example, in EasyLanguage you could do the opposite with something like:

 
Code
If Dayofweek <> 0 Then
    // you can trade
But that was just a very simple example, just to illustrate the idea, because I need this for other kind of situations (but with a similar base).


By the way, I tried with something like:

 
Code
If Dayofweek = 0 Then
    Return;
But it shows a compilation error saying that “Return keyword can be used only inside a method”, so it seems that `Return` couldn’t be used in the exact way as used in the given NinjaTrader example here, and if possible the idea would be to have an equivalence in a kind of simple and efficient way just as the ` Return` example here.


Thank you for any help

I would just use if...else block and have no commands/action under that

If Condition1 And Condition2 Then Begin
//no code here, do nothing

End
Else Begin
{Your Code Line3}
{Your Code Line4, etc.}
End;

Follow me on Twitter Reply With Quote
Thanked by:
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627


futurenow,

you would have to move parts of your code inside a method if you want to be able to use the return statement. The approach @kevinkdog shared will do exactly what you have in mind while sticking to legacy EasyLanguage principles and a method might not give you any benefit here.

Regards,

ABCTG


futurenow View Post
Hello

I’m trying to find an EasyLanguage example about how to work the cases where you want the script doesn’t execute any action of the code (any action of the main logic) when a kind of “general” condition is met, even if the rest of the code contains other conditions that could do certain actions during that general condition. But I’m unable to find examples that covers this kind of cases.

For example, in NinjaScript when you want a strategy doesn’t do anything under a certain general condition, like for example not to place trades on Sundays, then a way to get this is with:

 
Code
if (Time[0].DayOfWeek == DayOfWeek.Sunday)
    return;
And with this simple code as a general condition, then the strategy won’t execute any action when this condition is true, even if the entry condition is met.


Of course I understand that for this specific simple example, in EasyLanguage you could do the opposite with something like:

 
Code
If Dayofweek <> 0 Then
    // you can trade
But that was just a very simple example, just to illustrate the idea, because I need this for other kind of situations (but with a similar base).


By the way, I tried with something like:

 
Code
If Dayofweek = 0 Then
    Return;
But it shows a compilation error saying that “Return keyword can be used only inside a method”, so it seems that `Return` couldn’t be used in the exact way as used in the given NinjaTrader example here, and if possible the idea would be to have an equivalence in a kind of simple and efficient way just as the ` Return` example here.


Thank you for any help


Follow me on Twitter Reply With Quote
Thanked by:
  #4 (permalink)
 
Fu510n's Avatar
 Fu510n 
Suffield, CT
 
Experience: Advanced
Platform: MC, TS, Python, Rust
Broker: IB, IQFeed, TS, Kraken
Trading: ES, NQ, RTY, YM, CL, RB, 6E
Frequency: Several times daily
Duration: Seconds
Posts: 144 since Oct 2009
Thanks Given: 902
Thanks Received: 143

OP didn't mention whether the EL was on TradeStation or MultiCharts, but if MultiCharts, there is support for the #Return keyword that doesn't exist on TradeStation.

If on TradeStation, what the others mentioned already is great though I still have always wondered why TS never provided a way to "return early and often" .

Follow me on Twitter Reply With Quote
Thanked by:
  #5 (permalink)
futurenow
Earth planet
 
Posts: 49 since Feb 2017
Thanks Given: 38
Thanks Received: 13


kevinkdog View Post
I would just use if...else block and have no commands/action under that

If Condition1 And Condition2 Then Begin
//no code here, do nothing

End
Else Begin
{Your Code Line3}
{Your Code Line4, etc.}
End;


Thanks @kevinkdog, the if-else block from your answer worked as should

Reply With Quote
Thanked by:
  #6 (permalink)
futurenow
Earth planet
 
Posts: 49 since Feb 2017
Thanks Given: 38
Thanks Received: 13


Fu510n View Post
OP didn't mention whether the EL was on TradeStation or MultiCharts, but if MultiCharts, there is support for the #Return keyword that doesn't exist on TradeStation.

If on TradeStation, what the others mentioned already is great though I still have always wondered why TS never provided a way to "return early and often" .


Thanks @Fu510n

In this case was on TS, however your reference for MC will also be useful.

Reply With Quote
  #7 (permalink)
futurenow
Earth planet
 
Posts: 49 since Feb 2017
Thanks Given: 38
Thanks Received: 13


ABCTG View Post
futurenow,

you would have to move parts of your code inside a method if you want to be able to use the return statement. The approach @kevinkdog shared will do exactly what you have in mind while sticking to legacy EasyLanguage principles and a method might not give you any benefit here.

Regards,

ABCTG


Thanks @ABCTG

As you say, in this case the @kevinkdog answer works well.

About to work with a Method, in EasyLanguage I haven't yet tried specifically using an empty Return specifying no variable value as returned result from the Method, with the idea to avoid running any script process when the condition inside the Method is met, but I think it could also work for that purpose.

Regards.

Reply With Quote




Last Updated on March 17, 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