Kyushu Ashi

Created at 25 Sep 2022, 18:00
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
MI

mindfulness

Joined 04.07.2021

Kyushu Ashi
25 Sep 2022, 18:00


Hello,

i need a maybe simple thing, but it is not working correct. When executing on Tradingview there are much more trades, then with backtesting in ctrader.

The origin part from pine of Tradingview looks like this:
 

len = input(8)
c = close
o = open[len]

kyushu_bullish = o < c
kyushu_bearish = o > c

kyushu_m5_bullish = request.security(syminfo.tickerid, '5', kyushu_bullish, lookahead=barmerge.lookahead_on)
kyushu_m5_bearish = request.security(syminfo.tickerid, '5', kyushu_bearish, lookahead=barmerge.lookahead_on)

kyushu_m15_bullish = request.security(syminfo.tickerid, '15', kyushu_bullish, lookahead=barmerge.lookahead_on)
kyushu_m15_bearish = request.security(syminfo.tickerid, '15', kyushu_bearish, lookahead=barmerge.lookahead_on)

kyushu_m30_bullish = request.security(syminfo.tickerid, '30', kyushu_bullish, lookahead=barmerge.lookahead_on)
kyushu_m30_bearish = request.security(syminfo.tickerid, '30', kyushu_bearish, lookahead=barmerge.lookahead_on)


kyushu_h1_bullish = request.security(syminfo.tickerid, '60', kyushu_bullish, lookahead=barmerge.lookahead_on)
kyushu_h1_bearish = request.security(syminfo.tickerid, '60', kyushu_bearish, lookahead=barmerge.lookahead_on)

kyushu_h4_bullish = request.security(syminfo.tickerid, '240', kyushu_bullish, lookahead=barmerge.lookahead_on)
kyushu_h4_bearish = request.security(syminfo.tickerid, '240', kyushu_bearish, lookahead=barmerge.lookahead_on)

kyushu_d_bullish = request.security(syminfo.tickerid, 'D', kyushu_bullish, lookahead=barmerge.lookahead_on)
kyushu_d_bearish = request.security(syminfo.tickerid, 'D', kyushu_bearish, lookahead=barmerge.lookahead_on)

kyushu_w_bullish = request.security(syminfo.tickerid, 'W', kyushu_bullish, lookahead=barmerge.lookahead_on)
kyushu_w_bearish = request.security(syminfo.tickerid, 'W', kyushu_bearish, lookahead=barmerge.lookahead_on)

kyushu_m_bullish = request.security(syminfo.tickerid, 'M', kyushu_bullish, lookahead=barmerge.lookahead_on)
kyushu_m_bearish = request.security(syminfo.tickerid, 'M', kyushu_bearish, lookahead=barmerge.lookahead_on)


kyushu_trend_confirmation = ((kyushu_d_bullish or kyushu_h4_bullish) and kyushu_h1_bullish and kyushu_m30_bullish and kyushu_m15_bullish and kyushu_m5_bullish) or ((kyushu_d_bearish or kyushu_h4_bearish) and (kyushu_h1_bearish and kyushu_m30_bearish and kyushu_m15_bearish and kyushu_m5_bearish))

 

In calgo i have made the following:
 

var kyushu_d = (MarketData.GetBars(TimeFrame.Daily));
var kyushu_h4 = (MarketData.GetBars(TimeFrame.Hour4));
var kyushu_h1 = (MarketData.GetBars(TimeFrame.Hour));
var kyushu_m30 = (MarketData.GetBars(TimeFrame.Minute30));
var kyushu_m15 = (MarketData.GetBars(TimeFrame.Minute15));
var kyushu_m5 = (MarketData.GetBars(TimeFrame.Minute5));



var kyushu_d_bullish = (kyushu_d.OpenPrices.Last(8) > kyushu_d.ClosePrices.LastValue);
var kyushu_h4_bullish = (kyushu_h4.OpenPrices.Last(8) > kyushu_h4. ClosePrices.LastValue);
var kyushu_h1_bullish = (kyushu_h1.OpenPrices.Last(8) > kyushu_h1.ClosePrices.LastValue);
var kyushu_m30_bullish = (kyushu_m30.OpenPrices.Last(8) > kyushu_m30.ClosePrices.LastValue);
var kyushu_m15_bullish = (kyushu_m15.OpenPrices.Last(8) > kyushu_m15.ClosePrices.LastValue);
var kyushu_m5_bullish = (kyushu_m5.OpenPrices.Last(8) > kyushu_m5.ClosePrices.LastValue);

var kyushu_bullish = ((kyushu_d_bullish || kyushu_h4_bullish) & (kyushu_h1_bullish & kyushu_m30_bullish & kyushu_m15_bullish & kyushu_m5_bullish));

var kyushu_bearish = ((kyushu_d_bearish || kyushu_h4_bearish) & (kyushu_h1_bearish & kyushu_m30_bearish & kyushu_m15_bearish & kyushu_m5_bearish));

Any idea, what i have to change and understand?

 

Thanks in advanced

 

Alex


@mindfulness
Replies

Sendgate
25 Sep 2022, 19:11

Quick glanced... Change & to &&?
& is a bitwise operand, && is a logical operand


@Sendgate

mindfulness
26 Sep 2022, 08:26

RE:

Sendgate said:

Quick glanced... Change & to &&?
& is a bitwise operand, && is a logical operand

Just give it a try, but makes no difference. Not sure, but i think it´s a mistake regarding converting the "len" from the former script to C# Calgo.


@mindfulness

Sendgate
27 Sep 2022, 10:06

RE:

mindfulness said:

Sendgate said:

Quick glanced... Change & to &&?
& is a bitwise operand, && is a logical operand

Just give it a try, but makes no difference. Not sure, but i think it´s a mistake regarding converting the "len" from the former script to C# Calgo.

Well it really should make a difference in the logical query.
I suggest you try to use the debugger to se your code working. You can download a free, community edition, of Visual Studio and get going :)

Cheers

This is the correct syntax:
 

var kyushu_bullish = ((kyushu_d_bullish || kyushu_h4_bullish) && (kyushu_h1_bullish && kyushu_m30_bullish && kyushu_m15_bullish && kyushu_m5_bullish));

var kyushu_bearish = ((kyushu_d_bearish || kyushu_h4_bearish) && (kyushu_h1_bearish && kyushu_m30_bearish && kyushu_m15_bearish && kyushu_m5_bearish));

 


@Sendgate

mindfulness
27 Sep 2022, 14:34

RE: RE:

Sendgate said:

mindfulness said:

Sendgate said:

Quick glanced... Change & to &&?
& is a bitwise operand, && is a logical operand

Just give it a try, but makes no difference. Not sure, but i think it´s a mistake regarding converting the "len" from the former script to C# Calgo.

Well it really should make a difference in the logical query.
I suggest you try to use the debugger to se your code working. You can download a free, community edition, of Visual Studio and get going :)

Cheers

This is the correct syntax:
 

var kyushu_bullish = ((kyushu_d_bullish || kyushu_h4_bullish) && (kyushu_h1_bullish && kyushu_m30_bullish && kyushu_m15_bullish && kyushu_m5_bullish));

var kyushu_bearish = ((kyushu_d_bearish || kyushu_h4_bearish) && (kyushu_h1_bearish && kyushu_m30_bearish && kyushu_m15_bearish && kyushu_m5_bearish));

 

Thanks for the answer. I have already made the above mentioned changes amde. still no difference. And i am already working with Visual Studio. VA has not thrown an error when using only one "&". Using version 2019, maybe this is in 2022 different.


@mindfulness

mindfulness
29 Sep 2022, 12:00

RE: RE: RE:

mindfulness said:

Sendgate said:

mindfulness said:

Sendgate said:

Quick glanced... Change & to &&?
& is a bitwise operand, && is a logical operand

Just give it a try, but makes no difference. Not sure, but i think it´s a mistake regarding converting the "len" from the former script to C# Calgo.

Well it really should make a difference in the logical query.
I suggest you try to use the debugger to se your code working. You can download a free, community edition, of Visual Studio and get going :)

Cheers

This is the correct syntax:
 

var kyushu_bullish = ((kyushu_d_bullish || kyushu_h4_bullish) && (kyushu_h1_bullish && kyushu_m30_bullish && kyushu_m15_bullish && kyushu_m5_bullish));

var kyushu_bearish = ((kyushu_d_bearish || kyushu_h4_bearish) && (kyushu_h1_bearish && kyushu_m30_bearish && kyushu_m15_bearish && kyushu_m5_bearish));

 

Thanks for the answer. I have already made the above mentioned changes amde. still no difference. And i am already working with Visual Studio. VA has not thrown an error when using only one "&". Using version 2019, maybe this is in 2022 different.

This one can be closed. Very poor failure on my side. The ">" and "<" were wrong sided. ;)


@mindfulness