Crack Spread chart?

ebe8g4.jpg
 
hi polpolik here is an afl that might help just open heating oil chart up and type the crude and gasoline tickers in the parameter box
still learning how to do spreads in ami not much help around
cheers kg

//2Gasoline +1 Heating Oil - 3Crude Oil

SetChartBkGradientFill( ParamColor("BgTop", colorBlack),ParamColor("BgBottom", colorDarkGreen));
//////////////////////////////////////////////
Tickerg= ParamStr("long ticker", "type in Gasoline ticker");//long
///////////////
tickersgc=Foreign( tickerg, "C");//long gasoline
tickersgo=Foreign( tickerg, "O");//long gasoline
tickersgh=Foreign( tickerg, "H");//long gasoline
tickersgl=Foreign( tickerg, "L");//long gasoline
////////////////////////////////////////////
Ticker= ParamStr("Short ticker", "type in crude ticker");//short stock
//////////////////////////////////////
tickersc=Foreign( ticker, "C");//Short crude
tickerso=Foreign( ticker, "O");//Short crude
tickersh=Foreign( ticker, "H");//Short crude
tickersl=Foreign( ticker, "L");//Short crude
/////////////////////////////////////////////////////////////////
Longt=Param("Gasoline contracts",2,1,5,1);
Shortt=Param("Crude contracts",3,1,5,1);
//////////////////////////////////////////////////////////////////
spreadc=(((Longt)*(tickersgc))+C)-((Shortt)*(tickersc));
spreado=(((Longt)*(tickersgo))+O)-((Shortt)*(tickerso));
spreadh=(((Longt)*(tickersgh))+H)-((Shortt)*(tickersh));
spreadl=(((Longt)*(tickersgl))+L)-((Shortt)*(tickersl));
////////////////2 period moving average////////////////////////////////////
Cc1=EMA(spreadc,2);
Plot( spreadc,""+Ticker,colorGold,styleDashed);
Plot(Cc1,"",colorBrightGreen,5);
///////////displaced moving average////////////////////////
x1=MA(Cc1,13);
x2=Ref(x1,-3);
Plot(x2,"3 displaced 13 MA ",0,5);
///////////bollinger bands of ///////////////////////////////////
bb=1.7*(StDev( spreadc, 11 )) ;
Plot(Cc1+bb,"",54,styleDashed);
Plot(Cc1-bb,"",54,styleDashed);
 
Auric, thanks for the AFL script. I'll give that a shot later after the trading day. I appreciate the help!

Have you tried this type of formula

spread = Foreign( "ticker1", "C") - Foreign( "ticker2", "C");
Plot( spread, "spread", colorRed);

- Tools -> Apply Indicator
(replace ticker1, ticker2 with actual symbol names).

I suppose, in this case, just changing the formula a bit would give the spread. I'll work on it later and see how it turns out.
 
no problem here is rsi of the crack spread just do same as before open heating oil and type tickers in parameters etc should give you a base to play with cheers


//rsi of crack oil
//2Gasoline +1 Heating Oil - 3Crude Oil

SetChartBkGradientFill( ParamColor("BgTop", colorBlack),ParamColor("BgBottom", colorDarkGreen));
//////////////////////////////////////////////
Tickerg= ParamStr("long ticker", "type in Gasoline ticker");//long
///////////////
tickersgc=Foreign( tickerg, "C");//long gasoline
tickersgo=Foreign( tickerg, "O");//long gasoline
tickersgh=Foreign( tickerg, "H");//long gasoline
tickersgl=Foreign( tickerg, "L");//long gasoline
////////////////////////////////////////////
Ticker= ParamStr("Short ticker", "type in crude ticker");//short stock
//////////////////////////////////////
tickersc=Foreign( ticker, "C");//Short crude
tickerso=Foreign( ticker, "O");//Short crude
tickersh=Foreign( ticker, "H");//Short crude
tickersl=Foreign( ticker, "L");//Short crude
/////////////////////////////////////////////////////////////////
Longt=Param("Gasoline contracts",2,1,5,1);
Shortt=Param("Crude contracts",3,1,5,1);
//////////////////////////////////////////////////////////////////
spreadc=(((Longt)*(tickersgc))+C)-((Shortt)*(tickersc));
spreado=(((Longt)*(tickersgo))+O)-((Shortt)*(tickerso));
spreadh=(((Longt)*(tickersgh))+H)-((Shortt)*(tickersh));
spreadl=(((Longt)*(tickersgl))+L)-((Shortt)*(tickersl));

pd=Param("pd",13,1,100,1);
pp1=RSIa( spreadc, pd ) ;

Plot(pp1,"",5,5);
 
Back
Top