@travick From my previous post :
I added option chain in the watchlist. I want to trade one of the options on predefined conditions. I am not able to get the result (buy the put/call option) in either exploration/backtesting.
listname = "NIFTY18DEC";
category = categoryWatchlist;
listnum = CategoryFind( listname, category );
list = CategoryGetSymbols( category, listnum);
Call = "NIFTY18DEC" + (round(C /100)+ 5 )*100 + "CE";
Put = "NIFTY18DEC" + (round(C /100)- 5 )*100 + "PE";
for( n = 0; ( symbol = StrExtract( list, n ) ) != ""; n++ )
{
if ( buycall[i-1] == 1 && symbol == Call)
{
AddTextColumn(Symbol, "Symbol");
SetForeign(symbol);
Buy = timeok;
RestorePriceArrays();
}
else if ( Buyput[i-1] == 1 && symbol == Put)
{
AddTextColumn(Symbol, "Symbol");
SetForeign(symbol);
Buy = timeok;
RestorePriceArrays();
}
}
Sell = something
SellPrice = Open;
Short = 0;
Cover = 0;
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
You Suggested
You can't trade a foreign symbol, like the way you have written. All trades are for current symbol.
If you are trading live and just want to fire a signal for example, then you can call your Brokers API from that IF() and fire a trade right away but these are two very different things.
There are more code examples in the Forum, but you need to write a CBT (Mid-level atleast) and that is fairly advanced.
Now::
Instead of using watchlist, I decided to run code only on few options. Based on Moving average calculation I arrived at Value
Value = tot60 + tot15;
case1 = IIf( ( Value >= 26.05 AND Value < 26.45 ), 1 , 0 );
case2 = IIf( ( Value >= 26.45 AND Value < 26.55 ), 1 , 0 );
for ( i = 0; i < BarCount; i++ )
{
if ( case1[i] == 1 )
{
Call = "BANKNIFTY19103" + "26500CE" ;
Put = "BANKNIFTY19103" + "26000PE" ;
}
else
if ( case2[i] == 1 )
{
Call = "BANKNIFTY19103" + "27000CE";
Put = "BANKNIFTY19103" + "26000PE";
}
}
if ( Name() == Call )
{
Buy = ..........
Sell = ..........
}
else if ( Name() == Put )
{
Buy = ..........
Sell = ..........
}
So If value comes between > 26.05 to 26.45 the BUY SIGNAL will be generated in chart 1. But if market changes the value shift between 26.45 - 26.55 and sell singal is generated Chart 2.
So, Please help me in coding to fix the chart/symbol using staticvarset.