KAMA Symmetry Issue and is rising for 1 bar not 2 and also strategy acting differently in terminal

None of these strategies with KAMA produce ANY short trades on ANY market. (attached below)
//--------------------------------------------------------------------
// Trading rule: Trading signals (On Bar Open)
//--------------------------------------------------------------------                   
LongEntrySignal = (UlcerIndex(Main chart, DOWN UI, UlcerIndexeePeriod)[3]   is below 16.63
   and (KAMA(Subchart1, D1,KAMAERPeriod, KAMAShortPeriod, KAMALongPeriod)[1] is rising));

ShortEntrySignal = (UlcerIndex(Main chart, UP UI, UlcerIndexeePeriod)[3]   is below 16.63
   and (KAMA(Subchart1, D1,KAMAERPeriod, KAMAShortPeriod, KAMALongPeriod)[1] is falling));

//--------------------------------------------------------------------
// Trading rule: Trading signals (On Bar Open)
//--------------------------------------------------------------------                   
LongEntrySignal = ((QQE(Main chart,QQEValue1RSIPeriod, QQEValue1sF, 4.236).Value1[1] > 49.46)
   and (KAMA(Subchart1, D1,KAMAERPeriod, KAMAShortPeriod, KAMALongPeriod)[2] is rising));

ShortEntrySignal = ((QQE(Main chart,QQEValue1RSIPeriod, QQEValue1sF, 4.236).Value1[1] < 50.54)
   and (KAMA(Subchart1, D1,KAMAERPeriod, KAMAShortPeriod, KAMALongPeriod)[2] is falling));

//--------------------------------------------------------------------
// Trading rule: Trading signals (On Bar Open)
//--------------------------------------------------------------------                   
LongEntrySignal = ((QQE(Main chart,QQEValue1RSIPeriod, QQEValue1sF, 4.236).Value1[1] < QQE.Value2)
   and Fast KAMA(Subchart1, D1,FastKMASlwKMAFstERPrd, FastKMASlwKMAFstShrPrd, FastKMASlwKMAFstLngPrd)[3] is above Slow KAMA(Subchart1, D1,FastKMASlwKMASlwERPrd, FastKMASlwKMASlwShrPrd, FastKMASlwKMASlwLngPrd)[3]);

ShortEntrySignal = ((QQE(Main chart,QQEValue1RSIPeriod, QQEValue1sF, 4.236).Value1[1] > QQE.Value2)
   and Fast KAMA(Subchart1, D1,FastKMASlwKMAFstERPrd, FastKMASlwKMAFstShrPrd, FastKMASlwKMAFstLngPrd)[3] is below Slow KAMA(Subchart1, D1,FastKMASlwKMASlwERPrd, FastKMASlwKMASlwShrPrd, FastKMASlwKMASlwLngPrd)[3]);


//--------------------------------------------------------------------
// Trading rule: Trading signals (On Bar Open)
//--------------------------------------------------------------------                   
LongEntrySignal = ((QQE(Main chart,QQEValue1RSIPeriod, QQEValue1sF, 4.236).Value1[1] > 49.46)
   and (KAMA(Subchart1, D1,KAMAERPeriod, KAMAShortPeriod, KAMALongPeriod)[2] is rising));

ShortEntrySignal = ((QQE(Main chart,QQEValue1RSIPeriod, QQEValue1sF, 4.236).Value1[1] < 50.54)
   and (KAMA(Subchart1, D1,KAMAERPeriod, KAMAShortPeriod, KAMALongPeriod)[2] is falling));

//--------------------------------------------------------------------
// Trading rule: Trading signals (On Bar Open)
//--------------------------------------------------------------------                   
LongEntrySignal = (AvgVolume(Main chart,AvgVolumeFallingPrd)[3] is falling
   and (KAMA(Subchart1, D1,KAMAERPeriod, KAMAShortPeriod, KAMALongPeriod)[1] is rising));

ShortEntrySignal = (AvgVolume(Main chart,AvgVolumeFallingPrd)[3] is falling
   and (KAMA(Subchart1, D1,KAMAERPeriod, KAMAShortPeriod, KAMALongPeriod)[1] is falling));


ALSO - the help text description is mistaken for KAMA rising/falling ('rising/falling for 2 bars') this code
only looks at the difference between two bars which equates to rising-falling for only 1 bar.
...
@Help("Is triggered if KAMA is rising 2 bars")
...
    
    @Override
    public boolean OnBlockEvaluate() throws TradingException {
        KAMA indicator = Strategy.Indicators.KAMA(Input, ERPeriod,ShortPeriod,LongPeriod);
        double value1 = indicator.Value.getRounded(Shift + 1);
        double value2 = indicator.Value.getRounded(Shift);
        
        return value1 < value2;
    }
...
Also, this one produces very few short trades even on EURUSD and USDJPY I have attached in another comment below and this is KAMA on the main H1 chart: //--------------------------------------------------------------------
// Trading rule: Trading signals (On Bar Open)
//--------------------------------------------------------------------                   
LongEntrySignal = (Fast KAMA(Main chart,FastKMASlwKMAFstERPrd, FastKMASlwKMAFstShrPrd, FastKMASlwKMAFstLngPrd)[2] is below Slow KAMA(Main chart,FastKMASlwKMASlwERPrd, FastKMASlwKMASlwShrPrd, FastKMASlwKMASlwLngPrd)[2]
   and (Momentum(Subchart1, D1,MomPeriod, PRICE_CLOSE)[3] is falling));

ShortEntrySignal = (Fast KAMA(Main chart,FastKMASlwKMAFstERPrd, FastKMASlwKMAFstShrPrd, FastKMASlwKMAFstLngPrd)[2] is above Slow KAMA(Main chart,FastKMASlwKMASlwERPrd, FastKMASlwKMASlwShrPrd, FastKMASlwKMASlwLngPrd)[2]
   and (Momentum(Subchart1, D1,MomPeriod, PRICE_CLOSE)[3] is rising)); EDIT: It should be noted that in the MT5 terminal, these strategies DO produce a normal amount of short trades....
Attachments
  • Votes +5
  • Project StrategyQuant X
  • Type Bug
  • Status New
  • Priority Normal

History

b
#1

bentra

01.03.2022 15:55

Task created

b
#2

bentra

01.03.2022 15:55
Voted for this task.
g
#3

geektrader

01.03.2022 16:58
Voted for this task.
b
#4

bentra

01.03.2022 18:17

Subject changed from Ulcer Index symmetry to delete me

Description changed:

delete me

b
#5

bentra

01.03.2022 19:17

Subject changed from delete me to Symmetry Issue

Description changed:

This strategy produces no short trades at all even when run on EURUSD. I suspect the reverse of the standard ulcer calculation (ulcer index up UI) is wrongly implemented but I haven't checked any code other than the pseudocode which looks fine.
//--------------------------------------------------------------------
// Trading rule: Trading signals (On Bar Open)
//--------------------------------------------------------------------                   
LongEntrySignal = (UlcerIndex(Main chart, DOWN UI, UlcerIndexeePeriod)[3]   is below 16.63
   and (KAMA(Subchart1, D1,KAMAERPeriod, KAMAShortPeriod, KAMALongPeriod)[1] is rising));

ShortEntrySignal = (UlcerIndex(Main chart, UP UI, UlcerIndexeePeriod)[3]   is below 16.63
   and (KAMA(Subchart1, D1,KAMAERPeriod, KAMAShortPeriod, KAMALongPeriod)[1] is falling));

LongExitSignal = (Ichimoku(Main chart,IchimokuKmoBrkBshTnkPrd, IchimokuKmoBrkBshKjnPrd, IchimokuKmoBrkBshSnkPrd)[1] Kumo breakout bullish
   and (Williams % R(Subchart1, D1,WPRPeriod)[1] > -50));

ShortExitSignal = (Ichimoku(Main chart,IchimokuKmoBrkBshTnkPrd, IchimokuKmoBrkBshKjnPrd, IchimokuKmoBrkBshSnkPrd)[1] Kumo breakout bearish
   and (Williams % R(Subchart1, D1,WPRPeriod)[1] < -50));



//--------------------------------------------------------------------
// Trading rule: Long entry (On Bar Open)
//--------------------------------------------------------------------                   
if (LongEntrySignal
   and Not LongExitSignal)
{
    // Action #1
    Open Long order at (High(Main chart)[3] + (ATR(Subchart1, D1,ATRPeriod)[1] * 0.5)) Stop;
        Order valid for 10 bars;
        Duplicate trades: disabled; 
        Replacing pending orders: allowed; 
        
        Stop Loss = StopLossCoef * ATR(24);
}


//--------------------------------------------------------------------
// Trading rule: Short entry (On Bar Open)
//--------------------------------------------------------------------                   
if (ShortEntrySignal
   and Not ShortExitSignal)
{
    // Action #1
    Open Short order at (Low(Main chart)[3] - (ATR(Subchart1, D1,ATRPeriod)[1] * 0.5)) Stop;
        Order valid for 10 bars;
        Duplicate trades: disabled; 
        Replacing pending orders: allowed; 
        
        Stop Loss = StopLossCoef * ATR(24);
}


Attachment bugged_Strategy 6152628.sqx added

bugged_Strategy 6152628.sqx
(36.38 KiB)
CG
#6

Chris G

01.03.2022 20:26
Voted for this task.
b
#7

bentra

03.03.2022 03:47

Description changed:

None of these strategies with KAMA produce ANY short trades on ANY market. (attached below) Looks like it has to do with KAMA being on D1 subchart...
//--------------------------------------------------------------------
// Trading rule: Trading signals (On Bar Open)
//--------------------------------------------------------------------                   
LongEntrySignal = (UlcerIndex(Main chart, DOWN UI, UlcerIndexeePeriod)[3]   is below 16.63
   and (KAMA(Subchart1, D1,KAMAERPeriod, KAMAShortPeriod, KAMALongPeriod)[1] is rising));

ShortEntrySignal = (UlcerIndex(Main chart, UP UI, UlcerIndexeePeriod)[3]   is below 16.63
   and (KAMA(Subchart1, D1,KAMAERPeriod, KAMAShortPeriod, KAMALongPeriod)[1] is falling));

//--------------------------------------------------------------------
// Trading rule: Trading signals (On Bar Open)
//--------------------------------------------------------------------                   
LongEntrySignal = ((QQE(Main chart,QQEValue1RSIPeriod, QQEValue1sF, 4.236).Value1[1] > 49.46)
   and (KAMA(Subchart1, D1,KAMAERPeriod, KAMAShortPeriod, KAMALongPeriod)[2] is rising));

ShortEntrySignal = ((QQE(Main chart,QQEValue1RSIPeriod, QQEValue1sF, 4.236).Value1[1] < 50.54)
   and (KAMA(Subchart1, D1,KAMAERPeriod, KAMAShortPeriod, KAMALongPeriod)[2] is falling));

//--------------------------------------------------------------------
// Trading rule: Trading signals (On Bar Open)
//--------------------------------------------------------------------                   
LongEntrySignal = ((QQE(Main chart,QQEValue1RSIPeriod, QQEValue1sF, 4.236).Value1[1] < QQE.Value2)
   and Fast KAMA(Subchart1, D1,FastKMASlwKMAFstERPrd, FastKMASlwKMAFstShrPrd, FastKMASlwKMAFstLngPrd)[3] is above Slow KAMA(Subchart1, D1,FastKMASlwKMASlwERPrd, FastKMASlwKMASlwShrPrd, FastKMASlwKMASlwLngPrd)[3]);

ShortEntrySignal = ((QQE(Main chart,QQEValue1RSIPeriod, QQEValue1sF, 4.236).Value1[1] > QQE.Value2)
   and Fast KAMA(Subchart1, D1,FastKMASlwKMAFstERPrd, FastKMASlwKMAFstShrPrd, FastKMASlwKMAFstLngPrd)[3] is below Slow KAMA(Subchart1, D1,FastKMASlwKMASlwERPrd, FastKMASlwKMASlwShrPrd, FastKMASlwKMASlwLngPrd)[3]);


//--------------------------------------------------------------------
// Trading rule: Trading signals (On Bar Open)
//--------------------------------------------------------------------                   
LongEntrySignal = ((QQE(Main chart,QQEValue1RSIPeriod, QQEValue1sF, 4.236).Value1[1] > 49.46)
   and (KAMA(Subchart1, D1,KAMAERPeriod, KAMAShortPeriod, KAMALongPeriod)[2] is rising));

ShortEntrySignal = ((QQE(Main chart,QQEValue1RSIPeriod, QQEValue1sF, 4.236).Value1[1] < 50.54)
   and (KAMA(Subchart1, D1,KAMAERPeriod, KAMAShortPeriod, KAMALongPeriod)[2] is falling));

//--------------------------------------------------------------------
// Trading rule: Trading signals (On Bar Open)
//--------------------------------------------------------------------                   
LongEntrySignal = (AvgVolume(Main chart,AvgVolumeFallingPrd)[3] is falling
   and (KAMA(Subchart1, D1,KAMAERPeriod, KAMAShortPeriod, KAMALongPeriod)[1] is rising));

ShortEntrySignal = (AvgVolume(Main chart,AvgVolumeFallingPrd)[3] is falling
   and (KAMA(Subchart1, D1,KAMAERPeriod, KAMAShortPeriod, KAMALongPeriod)[1] is falling));


ALSO - the help text description is mistaken for KAMA rising/falling ('rising/falling for 2 bars') this code
only looks at the difference between two bars which equates to rising-falling for only 1 bar.
...
@Help("Is triggered if KAMA is rising 2 bars")
...
    
    @Override
    public boolean OnBlockEvaluate() throws TradingException {
        KAMA indicator = Strategy.Indicators.KAMA(Input, ERPeriod,ShortPeriod,LongPeriod);
        double value1 = indicator.Value.getRounded(Shift + 1);
        double value2 = indicator.Value.getRounded(Shift);
        
        return value1 < value2;
    }
...

Attachment BuggedStrategy 4132734.sqx added

Attachment BuggedStrategy 41527411.sqx added

Attachment BuggedStrategy 41625611.sqx added

Attachment BuggedStrategy 813257.sqx added

Attachment BuggedStrategy 4112872.sqx added

Attachment BuggedStrategy 4192784.sqx added

Attachment BuggedStrategy 4272632.sqx added

Attachment BuggedStrategy 87273.sqx added

Attachment BuggedStrategy 813249.sqx added

Attachment BuggedStrategy 119290.sqx added

BuggedStrategy 813249.sqx
(1.45 MiB)
BuggedStrategy 4132734.sqx
(1.26 MiB)
BuggedStrategy 813257.sqx
(1.44 MiB)
BuggedStrategy 4272632.sqx
(1.39 MiB)
BuggedStrategy 87273.sqx
(1.41 MiB)
BuggedStrategy 41527411.sqx
(1.41 MiB)
BuggedStrategy 4112872.sqx
(1.41 MiB)
BuggedStrategy 41625611.sqx
(1.22 MiB)
BuggedStrategy 4192784.sqx
(1.33 MiB)
BuggedStrategy 119290.sqx
(1.34 MiB)
b
#8

bentra

03.03.2022 04:11

Attachment bugged_Strategy 1162611.sqx added

bugged_Strategy 1162611.sqx
(1.12 MiB)
I also attach this strategy which has KAMA on the main H1 chart and does produce a few short trades on USDJPY and EURUSD but not very many like only about 10% of the trades are short trades on USDJPY since 2011. Also EURUSD since 2011 has been trending down and only ~50% of the trades are short trades.

//--------------------------------------------------------------------
// Trading rule: Trading signals (On Bar Open)
//--------------------------------------------------------------------                   
LongEntrySignal = (Fast KAMA(Main chart,FastKMASlwKMAFstERPrd, FastKMASlwKMAFstShrPrd, FastKMASlwKMAFstLngPrd)[2] is below Slow KAMA(Main chart,FastKMASlwKMASlwERPrd, FastKMASlwKMASlwShrPrd, FastKMASlwKMASlwLngPrd)[2]
   and (Momentum(Subchart1, D1,MomPeriod, PRICE_CLOSE)[3] is falling));

ShortEntrySignal = (Fast KAMA(Main chart,FastKMASlwKMAFstERPrd, FastKMASlwKMAFstShrPrd, FastKMASlwKMAFstLngPrd)[2] is above Slow KAMA(Main chart,FastKMASlwKMASlwERPrd, FastKMASlwKMASlwShrPrd, FastKMASlwKMASlwLngPrd)[2]
   and (Momentum(Subchart1, D1,MomPeriod, PRICE_CLOSE)[3] is rising));



E
#9

Emmanuel

10.03.2022 04:07
Voted for this task.
MF
#10

Marti

07.04.2022 23:01
Voted for this task.

Votes: +5

Drop files to upload

or

choose files

Max size: 5MB

Not allowed: exe, msi, application, reg, php, js, htaccess, htpasswd, gitignore

...
Wait please