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 kevinkdog with 1 posts (2 thanks)
    3. looks_3 Fu510n with 1 posts (1 thanks)
    4. looks_4 ABCTG 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 2,308 views
    2. thumb_up 6 thanks given
    3. group 4 followers
    1. forum 6 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
futurenow
Earth planet
 
Posts: 53 since Feb 2017
Thanks Given: 42
Thanks Received: 14

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?
Iran Update May 8: Still Reviewing MOU, Demands Reparati …
Traders Hideout
ATFX Suspends Prop Trading Unit ATFunded -- Full Review …
Funded Trading Evaluation Firms
Election Sunday Resolves: Peru Heads to Runoff at 42pct, …
Prediction Markets & Event Contracts
Powell in 48 Hours: Word Markets Give 78% on Inflation, …
Prediction Markets & Event Contracts
UMA Votes Tonight: Polymarkets $80M Strategy Bitcoin Bat …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
196 thanks
Sober Journey With S&P
27 thanks
30 Sessions
20 thanks
BERN ALGOS algo trading journal
8 thanks
Volume Indicators
8 thanks
  #2 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,737 since Jul 2012
Thanks Given: 1,917
Thanks Received: 7,476


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 X Reply With Quote
Thanked by:
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642


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 X Reply With Quote
Thanked by:
  #4 (permalink)
 
Fu510n's Avatar
 Fu510n 
Suffield, CT
 
Experience: Advanced
Platform: TS, MC, MW, Python, Rust
Broker: TS, IB, IQFeed, Kraken
Trading: NQ, ES, CL, RTY
Frequency: Several times daily
Duration: Seconds
Posts: 165 since Oct 2009
Thanks Given: 943
Thanks Received: 166

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 X Reply With Quote
Thanked by:
  #5 (permalink)
futurenow
Earth planet
 
Posts: 53 since Feb 2017
Thanks Given: 42
Thanks Received: 14


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: 53 since Feb 2017
Thanks Given: 42
Thanks Received: 14


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: 53 since Feb 2017
Thanks Given: 42
Thanks Received: 14


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


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