Simple Coding Help - No Promise.

hmp

Well-Known Member
Dear Amit ji
I have already tried that but doesn't show result.Pl. try yourself also then you will understand.It gives result till hourly only.Or did you check it & got the result? In that case is there any other setting which i have to take care of?
Thanks & regards,
 
Last edited:

jallanankit

Well-Known Member
I am thinking of building a option trading afl.

What i m looking for is..
If system gets a BUY/SHORT/SELL/COVER condition on any logic..
For ex: a MA crossover system, the same time it shall be generated on the CE/PE..

The difference between the SPOT price and CE/PE Strike price can be set in a variable..??

For example.. If nifty is considered..
If MA crossover gets a buy on say 8000 as Nifty Fut price.. The system should generate a buy at 7900 CE (100 points lower Strike Price) and conversely, if a Short trade is generated on 8000, it should go for buying a PE of 8100 strike price.

This 100 points can be manually edited and let it be selected after rounding off nifty value if required...

Can anyone guide me how to do so?
Looking for an answer..?? Anyone..

Or anyone has an option trading afl. where BUY/SELL is executed on CE/PE based on Future Quote chart??
 

jallanankit

Well-Known Member
Dear Amit ji
I have already tried that but doesn't show result.Pl. try yourself also then you will understand.It gives result till hourly only.Or did you check it & got the result? In that case is there any other setting which i have to take care of?
Thanks & regards,
Word of caution for u:

The afl reference future quotes.. It may give you astounding results on backtest but similar performance will not be achieved while trading live..

Regards,
 

amitrandive

Well-Known Member
Looking for an answer..?? Anyone..

Or anyone has an option trading afl. where BUY/SELL is executed on CE/PE based on Future Quote chart??
My 2 cents on this ,

Any moving average crossover, like 315 will work.

But due to varying premiums,buy/sell signals will not be generated at the same time as the spot/future chart.

Signals will be slightly ahead or behind the spot/future charts.

I may be wrong, experts can advise on this.
 

jallanankit

Well-Known Member
My 2 cents on this ,

Any moving average crossover, like 315 will work.

But due to varying premiums,buy/sell signals will not be generated at the same time as the spot/future chart.

Signals will be slightly ahead or behind the spot/future charts.

I may be wrong, experts can advise on this.
Even I will support u on this, u r right when u say, signals may be genrated at different time..
What I want is when we get a Buy/Sell signal on future chart, it should give the same signal of the CE/PE chart in the same candlestick.

Which CE/PE to be selected for giving the signal, will be selcted from the variable part, which i mentioned in my last post..

Am i clear now?
 
Last edited:

amitrandive

Well-Known Member
Even I will support u on this, u r right when u say, signals may be genrated at different time..
What I want is when we get a Buy/Sell signal on future chart, it should give the same signal of the CE/PE chart in the same candlestick.

Which CE/PE to be selected for giving the signal, will be selcted from the variable part, which i mentioned in my last post..

Am i clear now?
Yes, was clear about your request earlier too.

I think you are talking about a buy/sell signal generated in the PE/CE chart on the same candlestick,when it is generated on the Spot/Future chart.

Need expert help whether that is really possible because we are taking of generating signals in one AFL on the basis of codes in another or maybe transferring signals from one AFL to another via some linking code.
 
Yes, was clear about your request earlier too.

I think you are talking about a buy/sell signal generated in the PE/CE chart on the same candlestick,when it is generated on the Spot/Future chart.

Need expert help whether that is really possible because we are taking of generating signals in one AFL on the basis of codes in another or maybe transferring signals from one AFL to another via some linking code.
@jallanankit, @amitrandive, @hmp

Yes, it is perfectly possible to look at quote price of future and execute trades in Options. It took me approximately 15 days to write this and lot longer to refine the errors and back test the strategy. At the moment, we are awaiting approvals from regulatory authorities to release the strategy.
 

bapu4

Well-Known Member
Hi Seniors,
I have this afl which doesn't work due to errors which I cant correct being too amature for afls, here is the code,

Code:
_SECTION_BEGIN("BUY");
_SECTION_BEGIN ( "Chart Display Theme" );
ChartDisplayTheme = ParamList ( "Chart Display Theme", "White background with B/W candles|Black background with R/G candles", 1 );
param_ShowSystemTitle = ParamToggle ( "Show System Title ?", "No|Yes", 1 );
_SECTION_END ();

//============================End of Chart Display Style=============================//
//============================Take User Inputs=============================//
_SECTION_BEGIN ( "Alerts" );
Param_AudioAlert = ParamToggle ( "Audio / text Alert?", "No|Yes", 1 );
Param_ShowValuesBox = ParamToggle ( "Display values in Box?", "No|Yes", 1 );
Param_BoxLocation = ParamList ( "Box Location?", "Left Top|Left Bottom|Right Top|Right Bottom", 0 );
Param_BoxBackgroundColour = ParamColor ( "Box background colour?",colorDarkGrey);
Param_HideBoxBehindChart = ParamToggle ( "Hide Box behind Chart?", "No|Yes" );
_SECTION_END ();
_SECTION_BEGIN ( "Money Management" );
Param_Show_Equity = ParamToggle ( "Show Equity ?(Enter correct INITIAL EQUITY in AA Settings)", "No|Yes" );
Param_Margin = Param ( "Margin required (used for backtesting only)", 15, 0.001, 100, 0.001 );
Param_LotSize = Param ( "Lot Size - DO NOT CHANGE", 50, 5, 5000, 5 );
Param_NoOfLots = Param ( "No of lots normally traded (used for backtesting only)", 2, 1, 10000, 1 );
Param_drawdown= ParamList ( "Trailing Stoploss Method - DO NOT CHANGE", "% of total trade value|Fixed amount per share" );
Param_Stoploss_percent = Param ( "Stoploss % per trade", 0.7, 0.01, 5, 0.01 );
Param_Stoploss_amount = Param ( "Stoploss Amount per share", 15, 0.01, 50000, 0.01 );
_SECTION_END ();
//============================End of User Inputs=============================//
//==========================Start of Show Resistance and Support Lines===============================//
_SECTION_BEGIN ( "Support-Resistance" );
Param_ShowResSup = ParamToggle ( "Show Resistance / Support ?", "No|Yes" );
Param_HowManyRS = Param ( "How many Support / Resistance to show ?", 2, 0, 10, 1 );
Param_ResSupVolatility = Param ( "Support / Resistance Volatility ", 0.1, 0.1, 100, 0.1 );
Param_SupLineColor = ParamColor ( "Support Line Color",colorBrightGreen);
Param_SupLineStyle = ParamStyle ( "Support Line Style", styleLine|styleNoTitle);
Param_ResLineColor = ParamColor ( "Resistance Line Color",colorRed);
Param_ResLineStyle = ParamStyle ( "Resistance Line Style", styleLine|styleNoTitle);
if(Param_ShowResSup AND Param_HowManyRS> 0 )  (Param_HowManyRS [U]Param_ResSupVolatility,Param_SupLineColor,Param_ResLineColor,Param_SupLineStyle,Param_ResLineStyle),[/U]
Error 30-Syntex error UNEXPECTED INDENTIFIER
_SECTION_END ();
//===========End of Resistance and Support Lines===========//
_SECTION_BEGIN ( "Trading System" );
//====================Show Reversals ?====================//
Param_ShowReversals = ParamToggle ( "Show possible reversals ?", "No|Yes" );
if(Param_ShowReversals) TA_ShowReversals);
[B][U]Error -30[/U][/B]
//====================End of Show Reversals ?====================//
//====================Start of Trading System====================//
Param_ShowArrows = ParamToggle ( "Show Buy/Sell/Short/Cover Arrows ?", "No|Yes", 1 );
firstBarEntryExit = ParamToggle ( "First bar trade entry / exit ?", "No|Yes" );
A = Param ( "A - 14, 2, 25, 1 );
B = Param ( B )- 5, 2, 25, 1 );
CC = Param ( C) - 5, 1, 25, 1 );
D = Param ( D) - 5, 1, 25, 1 );
E = Param ( E) - 18, 1, 20, 1 );
TA_TradingSystemCheckEntry (A,B,CC,D,E,firstBarEntryExit);
_SECTION_END ();


//====================End of Trading System====================//
//==================Plot Equity, Arrows, AudioAlerts and box containing values================//
TA_PlotEquityArrowsAlertsValueBox (Param_BoxLocation, Param_Show_Equity,Param_ShowArrows,Param_AudioAlert,param_ShowSystemTitle,Param_ShowValuesBox, Param_HideBoxBehindChart,Param_BoxBackgroundColour);
//=================== End of Plot Arrows, AudioAlerts and box containing values================//
//=================== Start of Volume Display================//
_SECTION_BEGIN ( "Volume Selector" );
showVolume = ParamToggle ( "Show Volume ?", "No|Yes", 1 );
Erro31-UNEXPECTED IDENTIFIER 
displayStyle = ParamList ( "Volume Display Mode", "Normal Volume|Coloured Volume|Volume at Price|Volume at Price (grouped)|Volume at Price + Volume|Volume at Price + Coloured Volume|Volume at Price (grouped) + Volume|Volume at Price (grouped) + Coloured Volume|Customised VAP / candles|Customised VAP / candles + Volume|Customised VAP / candles + Coloured Volume" );
Param_NormalVolumeColor = ParamColor ( "Normal Volume Colour", colorDarkBlue);
Param_NormalVolumeStyle = ParamStyle ( "Normal Volume Style", styleHistogram | styleOwnScale | styleNoLabel, maskHistogram );
Param_UpVolumeColor = ParamColor ( "Up Volume Colour", colorGreen);
Param_DownVolumeColor = ParamColor ( "Down Volume Colour", colorRed);
Param_ColouredVolumeStyle = ParamStyle ( "Coloured Volume Style", styleHistogram | styleOwnScale | styleNoLabel, maskHistogram);
Param_VAPLinesCount = Param ( "VAP Lines Count", 100, 5, 1000, 1 );
Param_VAPLinesWidth = Param ( "VAP Lines Width", 40, 1, 100, 1 );
Param_VAPVolumeColor = ParamColor ( "VAP Color", colorGold);
Param_VAPSide = ParamToggle ( "VAP Side", "Left|Right" );
Param_VAPOverlay = 4 * ParamToggle ( "VAP Z-order", "On top|Behind", 1 );
Param_VAPStyle = 2 * ParamToggle ( "VAP(grouped) Style", "Fill|Lines", 1 );
Param_Segment = Param ( "No. of candles for Customized VAP", 10, 2, 1000, 1 );
if(showVolume)
{
segmentValue = IIf ( Interval () < inDaily, Day (), Month () );
segmentValue = segmentValue != Ref ( segmentValue, - 1 );
if(displayStyle == "Normal Volume" )
{
Plot ( Volume, "Vol ", Param_NormalVolumeColor, Param_NormalVolumeStyle, 2 );
}
else if(displayStyle == "Coloured Volume" )
{
Plot ( Volume, "Vol ", IIf ( C > O, Param_UpVolumeColor,Param_DownVolumeColor), Param_ColouredVolumeStyle, 2 );
}
else if (displayStyle == "Volume at Price" )
{
PlotVAPOverlay ( Param_VAPLinesCount, Param_VAPLinesWidth, Param_VAPVolumeColor, Param_VAPSide | Param_VAPOverlay );
}
else if (displayStyle== "Volume at Price (grouped)" )
{
PlotVAPOverlayA (segmentValue, Param_VAPLinesCount, Param_VAPLinesWidth, Param_VAPVolumeColor, Param_VAPSide | Param_VAPStyle | Param_VAPOverlay);
}
else if (displayStyle == "Volume at Price + Volume" )
{
Plot ( Volume, "Vol ", Param_NormalVolumeColor, Param_NormalVolumeStyle, 2 );
PlotVAPOverlay ( Param_VAPLinesCount, Param_VAPLinesWidth, Param_VAPVolumeColor, Param_VAPSide | Param_VAPOverlay );
}
else if (displayStyle == "Volume at Price + Coloured Volume" )
{
Plot ( Volume, "Vol ", IIf ( C > O, Param_UpVolumeColor,Param_DownVolumeColor), Param_ColouredVolumeStyle, 2 );
PlotVAPOverlay ( Param_VAPLinesCount, Param_VAPLinesWidth, Param_VAPVolumeColor, Param_VAPSide | Param_VAPOverlay );
}
else if (displayStyle== "Volume at Price (grouped) + Volume" )
{
Plot ( Volume, "Vol ", Param_NormalVolumeColor, Param_NormalVolumeStyle, 2 );
PlotVAPOverlayA (segmentValue, Param_VAPLinesCount, Param_VAPLinesWidth, Param_VAPVolumeColor, Param_VAPSide | Param_VAPStyle | Param_VAPOverlay);
}
else if (displayStyle== "Volume at Price (grouped) + Coloured Volume" )
{
Plot ( Volume, "Vol ", IIf ( C > O, Param_UpVolumeColor,Param_DownVolumeColor), Param_ColouredVolumeStyle, 2 );
PlotVAPOverlayA (segmentValue, Param_VAPLinesCount, Param_VAPLinesWidth, Param_VAPVolumeColor, Param_VAPSide | Param_VAPStyle | Param_VAPOverlay);
}
else if(displayStyle== "Customised VAP / candles" ) TA_ShowCustomizedVAP (Param_Segment,Param_VAPLinesCount, Param_VAPLinesWidth, Param_VAPVolumeColor, Param_VAPSide,Param_VAPStyle,Param_VAPOverlay);
else if(displayStyle== "Customised VAP / candles + Volume" ) 
{
Plot ( Volume, "Vol ", Param_NormalVolumeColor, Param_NormalVolumeStyle, 2 );
TA_ShowCustomizedVAP (Param_Segment,Param_VAPLinesCount, Param_VAPLinesWidth, Param_VAPVolumeColor, Param_VAPSide,Param_VAPStyle,Param_VAPOverlay);
}
else if(displayStyle== "Customised VAP / candles + Coloured Volume" ) 
{
Plot ( Volume, "Vol ", IIf ( C > O, Param_UpVolumeColor,Param_DownVolumeColor), Param_ColouredVolumeStyle, 2 );
TA_ShowCustomizedVAP (Param_Segment,Param_VAPLinesCount, Param_VAPLinesWidth, Param_VAPVolumeColor, Param_VAPSide,Param_VAPStyle,Param_VAPOverlay);
}
_SECTION_END ();
}
//=================== End of Volume Display================//
_SECTION_END();

_SECTION_BEGIN("T3");
function T3(price,periods)
{
 s = 0.84;
 e1=EMA(price,periods);
 e2=EMA(e1,Periods);
 e3=EMA(e2,Periods);
 e4=EMA(e3,Periods);
 e5=EMA(e4,Periods);
 e6=EMA(e5,Periods);
 c1=-s*s*s;
 c2=3*s*s+3*s*s*s;
 c3=-6*s*s-3*s-3*s*s*s;
 c4=1+3*s+s*s*s+3*s*s;
 Ti3=c1*e6+c2*e5+c3*e4+c4*e3;
 return ti3;
}

Plot(C,"",4,64);
Plot(T3(C,50),"T3",colorYellow,1);
Plot(t3(C,20),"T3",colorBlue,1);
_SECTION_END();
Thanx and regards
 
Last edited:

Similar threads