Reply

Using a Custom Indicator as an Oscillator

5 replies

Robbie

Customer, bbp_participant, community, 17 replies.

Visit profile

7 years ago #115281

I’ve imported a version of Supertrend as a custom indicator.  The data for the indicator looks like this:

 

06.03.2016,18:29,16971,1
06.03.2016,18:30,16969,1
06.03.2016,18:31,16967,1
06.03.2016,18:32,16966,1
06.03.2016,18:33,16963,-1
06.03.2016,18:34,16963,-1
06.03.2016,18:35,16963,-1
06.03.2016,18:38,16962,-1
06.03.2016,18:39,16964,-1

 

The indicator value is “1” for Long trend and -1 for Short trend.  It acts like an Oscillator with its middle value of “0”

 

The Custom Indicator definition looks like the screen print I attached.

 

I tried using it as a building block for strategies and the trading rules that are created by SQ look like this:

——————————————————————–
Pseudo Source Code of Strategy 1.87
  with parameter names.

  Generated by StrategyQuant version 3.8.1
  Generated at Wed Jun 22 16:39:00 GMT 2016
                                                          
  Tested on YM_M01_100D, M1, 03/06/2016 – 06/16/2016
  Spread: 1.0, Slippage: 0.0, Min distance of stop from price: 5.0
——————————————————————–
====================================================================
== Entry conditions
====================================================================
LongEntryCondition = (((High(15) + (PivotPP – AuSQCallSuperTrendU11(3).UpTrend[0])) + (HeikenAshiHigh(11) + (Close(6) + PivotS2))) < PivotS3)

 

SQ is treating the custom indicator I imported as a “Price” by subtracting it from PivotPP, even though I defined it as number that an oscillates above & below zero.

 

I there a way to define this custom indicator so that SQ knows that a positive number above zero = Long trend and a negative number below zero = Short trend ?

0

mikeyc

Customer, bbp_participant, community, 877 replies.

Visit profile

7 years ago #137959

 

SQ is treating the custom indicator I imported as a “Price” by subtracting it from PivotPP, even though I defined it as number that an oscillates above & below zero

 

It’s another SQ3 bug I’m afraid.

 

Do it again, but this time don’t select the Oscillator checkbox, define it’s return type as number.

 

It’s a pity there are so many bugs around custom indicators…

0

Robbie

Customer, bbp_participant, community, 17 replies.

Visit profile

7 years ago #137976

Thanks for the suggestion Mikeyc.

 

It looks like SQ stopped treating the indicator as a price and recognized it as a number now.

 

Only thing is, SQ has no context on how to implement the indicator.  SQ has no knowledge of logical domain (-1 <= 0 <= 1) or context.

 

We know that a value of +1 is trending long and -1 is trending short, but all I can specify to SQ is that its some number…. ?!?

 

As you say, its a pity… 

I can’t see any reason to continue try and use all the Ninjatrader indicators I’ve accumulated and developed over the years.

 

Here is an example of what got created, not at all within proper context:

——————————————————————–
Pseudo Source Code of Strategy 1.13
  with parameter names.

  Generated by StrategyQuant version 3.8.1
  Generated at Thu Jun 23 13:42:00 GMT 2016
                                                          
  Tested on YM_M01_100D, M1, 03/06/2016 – 06/16/2016
  Spread: 1.0, Slippage: 0.0, Min distance of stop from price: 5.0
——————————————————————–
====================================================================
== Entry conditions
====================================================================
LongEntryCondition = (AuSQCallSuperTrendU11(3).UpTrend[0] < 2.4)
ShortEntryCondition = (AuSQCallSuperTrendU11(3).UpTrend[0] > -2.4)

 

0

mikeyc

Customer, bbp_participant, community, 877 replies.

Visit profile

7 years ago #137977

There is a way to make SQ use the +1 for uptrend, -1 for downtrend and 0 for notrend.

 

Define two outputs on your indicator.

 

One is signal (+1, -1 and 0)

Other I name baseline and it is just 0 for every row of the indicator output:

 

06.03.2016,18:29,16971,1,0
06.03.2016,18:30,16969,1,0
06.03.2016,18:31,16967,1,0
06.03.2016,18:32,16966,1,0
06.03.2016,18:33,16963,-1,0
06.03.2016,18:34,16963,-1,0
06.03.2016,18:35,16963,-1,0
06.03.2016,18:38,16962,-1,0
06.03.2016,18:39,16964,-1,0

 

You can add the column of zeroes in Excel for example.

 

Include both outputs when generating strategies and SQ will create rules such as:

 

LongEntryCondition = (AuSQCallSuperTrendU11(3).UpTrend[0] < AuSQCallSuperTrendU11(3).BaseLine[0])
ShortEntryCondition = (AuSQCallSuperTrendU11(3).UpTrend[0] > AuSQCallSuperTrendU11(3).BaseLine[0])

 

Which is what you require.

0

Robbie

Customer, bbp_participant, community, 17 replies.

Visit profile

7 years ago #137987

Thanks again Mikeyc for the help.

 

I’ve attached a screen print of the updated Supertrend indicator definition.

 

SQ is now occasionally creating trading rules that have the correct context:

——————————————————————–
Pseudo Source Code of Strategy 1.98
  with parameter names.

  Generated by StrategyQuant version 3.8.1
  Generated at Fri Jun 24 07:56:00 GMT 2016
                                                          
  Tested on NQ_M01_100D, M1, 03/06/2016 – 06/16/2016
  Spread: 1.0, Slippage: 0.0, Min distance of stop from price: 5.0
——————————————————————–
====================================================================
== Entry conditions
====================================================================
LongEntryCondition = ((ATR(78) Crosses Above ATR(41)) And (AuSQCallSuperTrendU11(3).ZeroLine[0] < AuSQCallSuperTrendU11(3).Trend[0]))
ShortEntryCondition = ((ATR(78) Crosses Below ATR(41)) And (AuSQCallSuperTrendU11(3).ZeroLine[0] > AuSQCallSuperTrendU11(3).Trend[0]))

I assume the times when SQ is still creating rules that are Out of context is due to the “genetic” way the SQ engine assembles the various outputs of indicators to form all possible combinations of trading rules, for example:

——————————————————————–
Pseudo Source Code of Strategy 1.167
  with parameter names.

  Generated by StrategyQuant version 3.8.1
  Generated at Fri Jun 24 08:05:00 GMT 2016
                                                          
  Tested on NQ_M01_100D, M1, 03/06/2016 – 06/16/2016
  Spread: 1.0, Slippage: 0.0, Min distance of stop from price: 5.0
——————————————————————–
====================================================================
== Entry conditions
====================================================================
LongEntryCondition = ((ATR(15) Crosses Below ATR(11)) And ((ATR(80) Crosses Below ATR(75)) Or (((AuSQCallSuperTrendU11(3).ZeroLine[0] < -77.279999) Or (ATR(97) < ATR(63))) And (ATR(41) Crosses Above ATR(53)))))
ShortEntryCondition = ((ATR(15) Crosses Above ATR(11)) And ((ATR(80) Crosses Above ATR(75)) Or (((AuSQCallSuperTrendU11(3).ZeroLine[0] > 77.279999) Or (ATR(97) > ATR(63))) And (ATR(41) Crosses Below ATR(53)))))
 

We know that the Zeroline is always equal to 0, so the above rule of -77.279999 > 0 > 77.279999 will Never Be TRUE.

 

What SQ still needs is a way for me to tell it that the domains of the indicator output are ZeroLine = 0 and Trend = -1 or 1, and that the context is Long: Trend > Zeroline and Short: Trend < Zeroline.

 

If I could, SQ would then know how to properly use the custom SuperTrend indicator and not bother generating trading rules that are just never going to work.

 

Therefore I think the SQ Custom Indicator Definition should include a section for “Simple Rules” similar to the ones defined for the other standard indicators included with SQ, in “Building Blocks”. For example, “Long Term RSI > 50” or “Close Above Bollinger Band”

0

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

7 years ago #138043

Hello,

 

I will ask Mark if anything can be improved in this area with the new SQ4. I also like this indicator especially when combined with tick based chart (range bar, volume)

0

Viewing 5 replies - 1 through 5 (of 5 total)