Multitimeframe Ichimoku

Created at 03 Aug 2022, 06:40
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

Multitimeframe Ichimoku
03 Aug 2022, 06:40


Hello,

i am new to calgo cbot writing. Made my first bot almost complete, but stuck on the multitimeframe support.

In Tradingview JSON i am using the following:

ichi_m30_bullish = request.security(syminfo.tickerid, '30', ichi_bullish, lookahead=barmerge.lookahead_on)
ichi_m30_bearish = request.security(syminfo.tickerid, '30', ichi_bearish, lookahead=barmerge.lookahead_on)

ichi_h1_bullish = request.security(syminfo.tickerid, '60', ichi_bullish, lookahead=barmerge.lookahead_on)
ichi_h1_bearish = request.security(syminfo.tickerid, '60', ichi_bearish, lookahead=barmerge.lookahead_on)

ichi_h4_bullish = request.security(syminfo.tickerid, '240', ichi_bullish, lookahead=barmerge.lookahead_on)
ichi_h4_bearish = request.security(syminfo.tickerid, '240', ichi_bearish, lookahead=barmerge.lookahead_on)

ichi_d_bullish = request.security(syminfo.tickerid, 'D', ichi_bullish, lookahead=barmerge.lookahead_on)
ichi_d_bearish = request.security(syminfo.tickerid, 'D', ichi_bearish, lookahead=barmerge.lookahead_on)
 

That´s all needed to use the variable to request the timeframe.I have already looked in the new annoncement thread regarding multitimeframe, but don´t understand it completely how to use it for Ichimoku in the definitions and declarations. The definitions for Ichimoku are already made and working. Now i need only the request for example if this "var ssa_bullish = (ssa.LastValue > ssa.LastValue);" is true in a different timeframe, when executing on M5.

Thanks in advanced

Alex


@mindfulness
Replies

mindfulness
03 Aug 2022, 06:46

RE:

mindfulness said:

Hello,

i am new to calgo cbot writing. Made my first bot almost complete, but stuck on the multitimeframe support.

In Tradingview JSON i am using the following:

ichi_m30_bullish = request.security(syminfo.tickerid, '30', ichi_bullish, lookahead=barmerge.lookahead_on)
ichi_m30_bearish = request.security(syminfo.tickerid, '30', ichi_bearish, lookahead=barmerge.lookahead_on)

ichi_h1_bullish = request.security(syminfo.tickerid, '60', ichi_bullish, lookahead=barmerge.lookahead_on)
ichi_h1_bearish = request.security(syminfo.tickerid, '60', ichi_bearish, lookahead=barmerge.lookahead_on)

ichi_h4_bullish = request.security(syminfo.tickerid, '240', ichi_bullish, lookahead=barmerge.lookahead_on)
ichi_h4_bearish = request.security(syminfo.tickerid, '240', ichi_bearish, lookahead=barmerge.lookahead_on)

ichi_d_bullish = request.security(syminfo.tickerid, 'D', ichi_bullish, lookahead=barmerge.lookahead_on)
ichi_d_bearish = request.security(syminfo.tickerid, 'D', ichi_bearish, lookahead=barmerge.lookahead_on)
 

That´s all needed to use the variable to request the timeframe.I have already looked in the new annoncement thread regarding multitimeframe, but don´t understand it completely how to use it for Ichimoku in the definitions and declarations. The definitions for Ichimoku are already made and working. Now i need only the request for example if this "var ssa_bullish = (ssa.LastValue > ssa.LastValue);" is true in a different timeframe, when executing on M5.

Thanks in advanced

Alex


I have just found this on cTDN Forum - Multi time frame Ichimoku indicator (ctrader.com), but because it is 9 years old, there are some outdated things in it. Would be good if can get help on it.

thanks

Alex


@mindfulness

PanagiotisCharalampous
03 Aug 2022, 10:43

Hi Alex,

Here is how you can initialize an Ichimoku indicator using a different timeframe

 var ichimoku = Indicators.IchimokuKinkoHyo(MarketData.GetBars(TimeFrame.Minute2),9,26,52);

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous

mindfulness
03 Aug 2022, 11:27

RE:

PanagiotisCharalampous said:

Hi Alex,

Here is how you can initialize an Ichimoku indicator using a different timeframe

 var ichimoku = Indicators.IchimokuKinkoHyo(MarketData.GetBars(TimeFrame.Minute2),9,26,52);

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Hi Panagiotis,

 

thanks for the fast reply. Sorry if i have to ask another question. ;)

How can i combine a condition together with the timeframe variable above, like:

var A = B & C

where C is the var Ichimoku you mentioned.and is only checked in that timeframe.

 

thanks Alex


@mindfulness

PanagiotisCharalampous
03 Aug 2022, 11:35

Hi Alex,

I am not sure what are you trying to do. Do you want to compare two ichimoku indicators from two different timeframes?

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous

mindfulness
03 Aug 2022, 12:13

RE:

PanagiotisCharalampous said:

Hi Alex,

I am not sure what are you trying to do. Do you want to compare two ichimoku indicators from two different timeframes?

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Hi Panagiotis,

 

I want to use the bot in the M5. Now i need to check the higher and middle TF if there is a condition true. So for example:

The value of var A is true, when:

1. var B in daily is true (var B = senkouSpanA.Last(0) > senkouSpanB.Last(0)

In JSON fiormat like mentioned above it looks like this:
ichi_d_bullish = request.security(syminfo.tickerid, 'D', ichi_bullish, lookahead=barmerge.lookahead_on)

ichi_d_bullish would var A and ichi_bullish var B in the example

Hope that makes it more clear and understandable.

Thanks 

Alex

 

 


@mindfulness

PanagiotisCharalampous
03 Aug 2022, 12:19

Hi mindfullness,

Here you go

 var B = ichimoku.SenkouSpanA.Last(0) > ichimoku.SenkouSpanB.Last(0);

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous

mindfulness
03 Aug 2022, 12:32

RE:

PanagiotisCharalampous said:

Hi mindfullness,

Here you go

 var B = ichimoku.SenkouSpanA.Last(0) > ichimoku.SenkouSpanB.Last(0);

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Maybe not easy to explain. I will try it again:

1. This bot will run in M5 timeframe
2. I have to check within the bot, if var A is true in timeframe daily. So maybe a combination of your explaination regarding using Ichimoku and timeframe and using in M5 is needed. ?
3. I need to check two conditions in the bot:
    a) is var A true in daily timeframe

     b) is var B true in M5 timeframe
4. If both true , then execute the trade.

Sorry for the missunderstandings.


@mindfulness

PanagiotisCharalampous
03 Aug 2022, 12:37

How about this?

            var ichimoku = Indicators.IchimokuKinkoHyo(9,26,52);
            var b =  ichimoku.SenkouSpanA.Last(0) > ichimoku.SenkouSpanB.Last(0);
            var ichimokuDaily = Indicators.IchimokuKinkoHyo(MarketData.GetBars(TimeFrame.Daily),9,26,52);
            var c = ichimokuDaily.SenkouSpanA.Last(0) > ichimokuDaily.SenkouSpanB.Last(0);
            var a = c && b;

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous

mindfulness
03 Aug 2022, 12:50

RE:

PanagiotisCharalampous said:

How about this?

            var ichimoku = Indicators.IchimokuKinkoHyo(9,26,52);
            var b =  ichimoku.SenkouSpanA.Last(0) > ichimoku.SenkouSpanB.Last(0);
            var ichimokuDaily = Indicators.IchimokuKinkoHyo(MarketData.GetBars(TimeFrame.Daily),9,26,52);
            var c = ichimokuDaily.SenkouSpanA.Last(0) > ichimokuDaily.SenkouSpanB.Last(0);
            var a = c && b;

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

That easy? Was all the time thinking, that i have to join it together like in JSON. ;)

Wow ... you made my day. :) Thank you very much

Alex


@mindfulness