Hello, Can anybody help me with the following problem, I got stuck for several hours
Let me explain the problem first----
I am trying to get the Put/Call ratio of option chain of "NIFTY" (Index traded in India), but in a very different manner suppose the closing price of NIFTY in 5min TF at the end of 5 min is 14030, then I will look for 03 strike prices i.e 14000,14050,13950 of CE and PE each and find the P/E ratio by the individual sum of OI of each strike prices of CE and PE respectively and then divide and similarly at the end of every 5 minutes.
I have written the code but it is showing the error "subscript out of range, you attempted to access non-existing %d-th element of an array" @fxshrat please help me
I think something is wrong here: you are assigning the values of a matrix row to the same entire matrix (essentially changing the original matrixes dimensions).
@prabhas, there are plenty of solutions on Option OI given by @fxshrat and other seniors in this forum if you search carefully, however, I thought to revert since your requirement doesn't require any matrix or VarSetText/VargetText.
Here is the code for your requirement you can simply define the logic as per your data vendor requirement.
NStrikes = Param( "Number of Strikes +/- ATM", 2, 1, 30, 1 );
StrikeInterval = 50;
ATMStrike = Round( Close / StrikeInterval ) * StrikeInterval;
Symbol = StrReplace( Name(), "-FUT", "WK" ); //Check your database vendor requirement for symbol.
for( i = ( NStrikes * -1 ) ; i <= NStrikes; i++ )
{
OptionStrike = NumToStr( ATMStrike + ( i * StrikeInterval ), 1.0, False );
CallStrike = Symbol + OptionStrike + "CE"; // Check your database vendor requirement for symbol.
PutStrike = Symbol + OptionStrike + "PE"; // Check your database vendor requirement for symbol.
ArrayRow = i + NStrikes;
if( SetForeign( CallStrike ) )
{
CallOI[ArrayRow] = LastValue( OI );
RestorePriceArrays();
}
if( SetForeign( PutStrike ) )
{
PutOI[ArrayRow] = LastValue( OI );
RestorePriceArrays();
}
}
PCR = SafeDivide( Cum( PutOI ), Cum( CallOI ) );
//_TRACE( "PutOI = " + Cum( PutOI ) );
//_TRACE( "CallOI = " + Cum( CallOI ) );
//_TRACE( "PCR = " + PCR );