Afl problems and basic afl programming (problems which i felt difficulties )

#32
Hi,
Most guys put different EMA of different timeframe for knowing What's happening in other timeframe?
TimeFrameSet( in5Minute ); // switch to 5 minute frame

/* MA now operates on 5 minute data, ma5_13 holds time-compressed 13 bar MA of 5min bars */

ma5_13 = MA( C, 13 );

TimeFrameRestore(); // restore time frame to original

TimeFrameSet( inHourly ); // switch now to hourly

mah_9 = EMA( C, 9 ); // 9 bar moving average from hourly data

TimeFrameRestore(); // restore time frame to original

Plot( Close, "Price", colorWhite, styleCandle );

// plot expanded average

Plot( TimeFrameExpand( ma5_13, in5Minute), "13 bar moving average from 5 min bars", colorRed );
Plot( TimeFrameExpand( mah_9, inHourly), "9 bar moving average from hourly bars", colorRed );
It's sure that timeframeset, timeframerestore function gonna be use for mutliple timeframe MACD crossover.
regards
 
Last edited:
#33
Hi,
Here's formula of normal MACD
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
Plot( ml = MACD(r1, r2), StrFormat(_SECTION_NAME()+"(%g,%g)", r1, r2), ParamColor("MACD color", colorRed ), ParamStyle("MACD style") );
Plot( sl = Signal(r1,r2,r3), "Signal" + _PARAM_VALUES(), ParamColor("Signal color", colorBlue ), ParamStyle("Signal style") );
Plot( ml-sl, "MACD Histogram", ParamColor("Histogram color", colorDefault ), styleNoTitle | ParamStyle("Histogram style", styleHistogram | styleNoLabel, maskHistogram ) );
 
#34
Hi,
Here's formula of normal MACD
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
Plot( ml = MACD(r1, r2), StrFormat(_SECTION_NAME()+"(%g,%g)", r1, r2), ParamColor("MACD color", colorRed ), ParamStyle("MACD style") );
Plot( sl = Signal(r1,r2,r3), "Signal" + _PARAM_VALUES(), ParamColor("Signal color", colorBlue ), ParamStyle("Signal style") );
Plot( ml-sl, "MACD Histogram", ParamColor("Histogram color", colorDefault ), styleNoTitle | ParamStyle("Histogram style", styleHistogram | styleNoLabel, maskHistogram ) );
What we have seen in different timeframe EMA? each timeframe have
TimeFrameSet( innMinute ); // switch to n minute frame

// Your indicator

TimeFrameRestore(); // restore time frame to original
For plotting like what we see in EMA multiple timeframe
Plot( TimeFrameExpand( ma5_13, in5Minute), "13 bar moving average from 5 min bars", colorRed );
same like
//Plot( TimeFrameExpand( Certain Timeframe Variable, inNMinute), "Little explanation of Timeframe variable ", colorRed );

For our case,
Plot( TimeFrameExpand( macd5, in5Minute), "Standard MACD in 5 minute", colorRed );
maybe something like that ?


What will happen if you use same thing in MACD, I even don't know, we will see it later?
regards
 
Last edited:
#35
In all probability, the MACD slope example given in the pic a few months back will not work. Almost every candle the trigger slope in the logic will remain true and AMI will take it as a buy/short.

Try this: sell when close >= 1.001 times buyprice or when 0.998* buyprice and the shortcoming will become clear.
 

Similar threads