// Downloaded From https://www.WiseStockTrader.com
////////////////////////////////////////// jbmarwood.com
//     RSI 2 TEST		        // Code provided for educational purposes only.
////////////////////////////////////////// No responsibility shall be accepted for any kind of personal loss. 
////////////////////////////////////////// Please read the full disclaimer at jbmarwood.com/disclaimer

SetFormulaName("RSI 2 TEST");
size1 = 10;//Optimize("size1",15,2,100,2);
SetOption( "InitialEquity",  100000);
SetOption( "MinShares", 1 );
SetOption( "MarginRequirement", 100);
SetOption( "UsePrevBarEquityForPosSizing", True );
SetTradeDelays( 0, 0, 0, 0 );	
SetOption( "MaxOpenpositions", size1);
SetOption( "AllowSameBarExit", true);
Numberpositions = size1;
SetOption("Maxopenpositions",numberpositions);
SetPositionSize( 1, spsShares );
PositionSize= -100/size1;
PositionScore = 100/RSI(2);

SetOption("CommissionMode",3);
Setoption("CommissionAmount",0.01);

//* Amendment for delisted securities

ThisIsLastBar = BarIndex() == LastValue( BarIndex() );

//* Divergence

bull1 = C>MA(C,200);
cum1 = Ref(RSI(2),-1) + RSI(2);

//* Rules

Buy =  cum1<5 and bull1 AND Open>5 AND MA(V,100)>250000;
Sell = cum1>65 OR ThisIsLastbar;

BuyPrice = c;
SellPrice = c;

//Buy = ExRem( Buy, Sell );//*removes extra signals
//Sell = ExRem( Sell, Buy );

/////////////////////////////////////////////////////////////////////