NexusFi: Find Your Edge


Home Menu

 





EasyLanguage SuperTrend indicator


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one Big Mike with 11 posts (59 thanks)
    2. looks_two ABCTG with 9 posts (6 thanks)
    3. looks_3 chtangwin with 6 posts (26 thanks)
    4. looks_4 Sam7768 with 5 posts (2 thanks)
      Best Posters
    1. looks_one Big Mike with 5.4 thanks per post
    2. looks_two chtangwin with 4.3 thanks per post
    3. looks_3 cedar with 1.3 thanks per post
    4. looks_4 ABCTG with 0.7 thanks per post
    1. trending_up 98,351 views
    2. thumb_up 103 thanks given
    3. group 42 followers
    1. forum 86 posts
    2. attach_file 9 attachments




 
Search this Thread

EasyLanguage SuperTrend indicator

  #61 (permalink)
NMC1
London
 
Posts: 14 since Jan 2013
Thanks Given: 0
Thanks Received: 3


Big Mike View Post
Gotcha.

The strend var is the key if i remember, monitor it for a change = if I remember it is 1 for long, -1 for short, so you could do something like:

if strend = 1 and strend[1] <> 1 then buy 1 contract next bar at market;

Mike

Mike - just adding my thanks to this old thread - I was able to get a Supertrend function up and running in MC with this post. It's my favourite indicator from a prorealtime past so v grateful for this.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Cheap historycal L1 data for stocks
Stocks and ETFs
MC PL editor upgrade
MultiCharts
NexusFi Journal Challenge - May 2024
Feedback and Announcements
How to apply profiles
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
  #62 (permalink)
sagetrade
Frankfurt / Germany
 
Posts: 47 since Jul 2013
Thanks Given: 28
Thanks Received: 11


Big Mike View Post
Gotcha.

The strend var is the key if i remember, monitor it for a change = if I remember it is 1 for long, -1 for short, so you could do something like:

if strend = 1 and strend[1] <> 1 then buy 1 contract next bar at market;

Mike

I cannot replicate this unfortunately. The Signal does not open Positions.


Quoting 
Inputs:

smalength ( 200 ),
emalength ( 50 ),
ATRLength ( 30 ),
ATRMult ( 10 ),
Strength ( 30 ),

Variables:

smav ( 0 ),
emav ( 0 ),
vSuperTrend ( 0 ),
strend ( 0 );

// Call MAs
smav = Average(Close, smalength);
emav = XAverage(Close, emalength);

// Call Supertrend
vSuperTrend = SuperTrend(ATRLength, ATRMult, Strength, vSTrend);

// Open new positions (Long Only)

if marketposition = 0 then begin // Only open new positions if flat

if close > vSuperTrend then begin // Checks if Supertrend is below price action

end;

// EMA and SMA Both Rising & Supertrend switches from Red to Green
if smav > smav[1] and emav > emav[1] and emav > smav
and sTrend = 1 and sTrend[1] <> 1 then begin

Buy ("Enter Long") 1 Contracts Next Bar At Market;

end;

end;


Reply With Quote
  #63 (permalink)
sagetrade
Frankfurt / Germany
 
Posts: 47 since Jul 2013
Thanks Given: 28
Thanks Received: 11


Anyone help for this?

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

The variable strend is never assigned a value, except the initial 0.
So your condition
 
Code
sTrend = 1 and sTrend[1] <> 1
can never become true.

Should it be
 
Code
vsTrend = 1 and vsTrend[1] <> 1
?

Regards,
ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #65 (permalink)
sagetrade
Frankfurt / Germany
 
Posts: 47 since Jul 2013
Thanks Given: 28
Thanks Received: 11

Hi ABC,

I referred to BigMike's post #22 on Page 3.

I would like to code a Buy/Sell signal for Supertrend crossings.

In Ninjatrader I did it through the following:


Quoting 
// Condition set 1
if (anaSuperTrendM11(ATRStrength, ATRMult, ATRPeriod, false).StopDot[1] > Close[1]
&& anaSuperTrendM11(ATRStrength, ATRMult, ATRPeriod, false).StopDot[0] < Close[0])
{
EnterLong(RiskSize, "Buy Long");
}

// Condition set 2
if (Position.Quantity > 0
&& anaSuperTrendM11(ATRStrength, ATRMult, ATRPeriod, false).StopDot[1] < Close[1]
&& anaSuperTrendM11(ATRStrength, ATRMult, ATRPeriod, false).StopDot[0] > Close[0])
{
ExitLong("Exit Long", "");
}

It works fine, but for Easy Language, I somehow don't get it

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

Hi sagetrade,

to check for a crossing is quite easy in EasyLanguage.
For an upcross you can do it like this:
 
Code
if MyVariable crosses over MyVariable[1]
or like this:
 
Code
if MyVariable > MyVariable[1] and MyVariable[1] < MyVariable[2]
or
 
Code
if MyVariable > MyVariable[1] and MyVariable[1] <= MyVariable[2]
depending on what you want.

For your code it makes a difference on the variable you want to use. Both sTrend and vSuperTrend are able to accomplish the task.
If you want to use vSuperTrend, then check for the cross. With sTrend you simply need to check for
 
Code
if sTrend = 1 and sTrend[1] = -1
Regards,
ABCTG


sagetrade View Post
Hi ABC,

I referred to BigMike's post #22 on Page 3.

I would like to code a Buy/Sell signal for Supertrend crossings.

In Ninjatrader I did it through the following:



It works fine, but for Easy Language, I somehow don't get it


Follow me on Twitter Reply With Quote
Thanked by:
  #67 (permalink)
sagetrade
Frankfurt / Germany
 
Posts: 47 since Jul 2013
Thanks Given: 28
Thanks Received: 11


ABCTG View Post
For your code it makes a difference on the variable you want to use. Both sTrend and vSuperTrend are able to accomplish the task.
If you want to use vSuperTrend, then check for the cross. With sTrend you simply need to check for
 
Code
if sTrend = 1 and sTrend[1] = -1

thx so much ABC once again. Can you explain where the specific difference between variables vSuperTrend & sTrend is?

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

The vSuperTrend carries the value of the Supertrend and sTrend carries the direction of the Supertrend indicator.
This will become clear if you plot both variables. On this image the blue line is vSuperTrend and the red line is displaying the value of sTrend.



Regards,
ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #69 (permalink)
sagetrade
Frankfurt / Germany
 
Posts: 47 since Jul 2013
Thanks Given: 28
Thanks Received: 11

But why do I need this sTrend variable at all?

When I look at my NinjaCode...


Quoting 
// Condition set 1
if (anaSuperTrendM11(ATRStrength, ATRMult, ATRPeriod, false).StopDot[1] > Close[1]
&& anaSuperTrendM11(ATRStrength, ATRMult, ATRPeriod, false).StopDot[0] < Close[0])
{
EnterLong(RiskSize, "Buy Long");
}

// Condition set 2
if (Position.Quantity > 0
&& anaSuperTrendM11(ATRStrength, ATRMult, ATRPeriod, false).StopDot[1] < Close[1]
&& anaSuperTrendM11(ATRStrength, ATRMult, ATRPeriod, false).StopDot[0] > Close[0])
{
ExitLong("Exit Long", "");
}

...there is no sTrend at all - just these three ATR variables.

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


You don't need it. The easiest thing is to just leave it in there, if you don't want to use it. You just have to use it as input of the function.
Otherwise delete the input and get rid of it within the code. This will leave you with the three ATR inputs to the function.

Regards,
ABCTG

Follow me on Twitter Reply With Quote
Thanked by:




Last Updated on October 31, 2021


© 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