Crude Oil Trading

Shikamaru

What a drag!!!
Gap filling - intraday
missed both entry with 4tick SL and simply watching the chart :D
 
Vijkris bhai, holy grail to long term testing ke baad hi pata chalegi :p

SOPD and SOPK are stochastic oscillators. SOPK takes price as the input, while SOPD takes SOPK as the input, formula is same for the both. This is what Pi's Tradescript has to say about it

Stochastic Oscillator
SOPK(%K Periods, %K Slowing Periods, %D Periods, MA Type)
SOPD(%K Periods, %K Slowing Periods, %D Periods, MA Type)
Overview
The Stochastic Oscillator is a popular indicator that shows where a security’s
price has closed in proportion to its closing price range over a specified period of
time.
Interpretation
The Stochastic Oscillator has two components: %K (the SOPK function) and %D
(the SOPD function). %K is most often displayed on a stock chart as a solid line
and %D is often shown as a dotted line. The most widely used method for
interpreting the Stochastic Oscillator is to buy when either component rises
above 80 or sell when either component falls below 20. Another way to interpret
the Stochastic Oscillator is to buy when %K rises above %D, and conversely, sell
when %K falls below %D.
Recommended Parameters
% K Periods: 9
% K Slowing Periods: 3
% D Periods: 9
MA Type: SIMPLE
Example
SOPK(9, 3, 9, SIMPLE) > 80 OR SOPD(9, 3, 9, SIMPLE) > 80
Evaluates to true when the Stochastic Oscillator is in oversold territory.

I am having very basic knowledge of AFL. But I believe the code should be like below.
Need a research about both functions.

Code:
k = StochK( 14 , 14);
d = StochD( 14 , 14, 14);

Buy = Cover = Cross(k, d) AND Close > MA(Close,50);
Sell = Short = Cross(d, k) AND Close > MA(Close,50);
 

vijkris

Learner and Follower
In initial back testing on hourly chart look very good........:thumb:
Need some expert help to fine tune and find hidden issues if any........
since it is hourly so its swing type, no need to put codes related to intraday, specially time based exit.
ami takes close of the signal candle as entry/exit price, if u do not specify buyprice/sell price.
in settings u ned to input brokerage for realistic profit/loss value.
BTW, win% is more imp.
 
Named it as Arsh, Check below with backtester settings.

Code:
_SECTION_BEGIN("Arsh");

Param_LotSize = Param("Lot Size (used for backtesting only)", 1,1,5000,1);
Param_Margin = Param("Margin required (used for backtesting only)", 15,0.001,100,0.001);
Param_NoOfLots = Param("No of lots normally traded (used for backtesting only)",1,1,10000,1);

k = StochK( 14 , 14);
d = StochD( 14 , 14, 14);

Plot(C,"",colorBlue,styleCandle);

Buy = Cover = Cross(k, d) AND Close > MA(Close,50);
Sell = Short = Cross(d, k) AND Close > MA(Close,50);

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);

PlotShapes(shapeUpArrow*Buy,colorGreen, 0, L, Offset=-45);
PlotShapes(shapeDownArrow*Short,colorOrange, 0, H, Offset=-45);

//Settings for Backtester

SetOption("AllowSameBarExit", False);
SetOption("AllowPositionShrinking", False);
SetOption("FuturesMode", True);
SetOption("InterestRate",0);
SetOption("MaxOpenPositions",1);
RoundLotSize = Param_LotSize;
SetOption("MinShares",RoundLotSize);
SetOption("PriceBoundChecking",False);
//SetOption("CommissionMode",3);
//SetOption("CommissionAmount",12.5/RoundLotSize);
SetOption("AccountMargin",Param_Margin);
SetOption("ReverseSignalForcesExit",True);
SetOption("UsePrevBarEquityForPosSizing",True);
//ApplyStop(stopTypeTrailing, stopModePoint, DTSL, True, True );
PositionSize = C*RoundLotSize*Param_NoOfLots;
SetTradeDelays(0,0,0,0);
BuyPrice = Close;
SellPrice = Close;
ShortPrice = Close;
CoverPrice = Close;

//End of Settings for Backtester


_SECTION_END();
 
That's ok. I don't know much about Amibroker. Can you share MCX Crude historical data (if it's not an issue)? Maybe I can try to flirt with it.
I have started trading crude since 6months only. my data is not continuous. :(
BTW for backtesting purpose I m also searching for historical data. maybe in another forum may find it.. lets see. :thumb:
Edit: I don have issues in sharing as long as I own the rights to share. :)
I download earlier from some where. Don't know about the reliability of data. Please check.

http://www. 4shared. com /file/P4De9XZbba/CRUDEOIL1313_14.html
http://www. 4shared. com /file/XM_Y7AFrba/CRUDEOIL14_15.html

remove spaces........

PS: Ravi bhai sorry, if we are disturbing this thread with this AFL stuff.
 

vijkris

Learner and Follower

arsh22g

Well-Known Member
Named it as Arsh, Check below with backtester settings.

Code:
_SECTION_BEGIN("Arsh");

Param_LotSize = Param("Lot Size (used for backtesting only)", 1,1,5000,1);
Param_Margin = Param("Margin required (used for backtesting only)", 15,0.001,100,0.001);
Param_NoOfLots = Param("No of lots normally traded (used for backtesting only)",1,1,10000,1);

k = StochK( 14 , 14);
d = StochD( 14 , 14, 14);

Plot(C,"",colorBlue,styleCandle);

Buy = Cover = Cross(k, d) AND Close > MA(Close,50);
Sell = Short = Cross(d, k) AND Close > MA(Close,50);

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);

PlotShapes(shapeUpArrow*Buy,colorGreen, 0, L, Offset=-45);
PlotShapes(shapeDownArrow*Short,colorOrange, 0, H, Offset=-45);

//Settings for Backtester

SetOption("AllowSameBarExit", False);
SetOption("AllowPositionShrinking", False);
SetOption("FuturesMode", True);
SetOption("InterestRate",0);
SetOption("MaxOpenPositions",1);
RoundLotSize = Param_LotSize;
SetOption("MinShares",RoundLotSize);
SetOption("PriceBoundChecking",False);
//SetOption("CommissionMode",3);
//SetOption("CommissionAmount",12.5/RoundLotSize);
SetOption("AccountMargin",Param_Margin);
SetOption("ReverseSignalForcesExit",True);
SetOption("UsePrevBarEquityForPosSizing",True);
//ApplyStop(stopTypeTrailing, stopModePoint, DTSL, True, True );
PositionSize = C*RoundLotSize*Param_NoOfLots;
SetTradeDelays(0,0,0,0);
BuyPrice = Close;
SellPrice = Close;
ShortPrice = Close;
CoverPrice = Close;

//End of Settings for Backtester


_SECTION_END();
Sirji, sincere thanks for this :)

Can you please post the chart/trading log as well?
 

Similar threads