I tried to do scale in for a simple logic based on MA. AFL is given below, The problem is always the BUY signal is only Buying 5 shares and not the 12 shares though there are several instances where the logic of buying 12 shares arises. If anybody helps me to understand the problem here ill be really helpful.
MA2= MA(C,20);
MA3 = MA (C,34);
buysig1 = Cross(MA1, MA2);
buysig2 = Cross(MA1, MA3);
buysig3 = Cross(MA2,MA3);
sellsig1 = Cross(MA2,MA1);
Buy=IIf((buysig1 OR buysig2 OR buysig3), sigScaleIn,0);
X= SumSince(sellsig1, buy);
Sell=sellsig1;
firsttrade = X ==1;
secondtrade = X ==2;
Thirdtarde = X ==3;
SetOption("MaxOpenPositions", 3 );
SetPositionSize(IIf(firsttrade,12,5),spsShares);
/*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
DISPLAY & GRAPHICXS OPTION
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX*/
SetChartOptions(0,chartShowArrows|chartShowDates);
GraphXSpace = 10; // create empty space of 10% top and bottom of chart
ChartType = ParamList("Chart Type", "Price Chart");
if (ChartType == "Price Chart")
{
Plot( Close, "Price", colorRed, styleCandle );
Plot( MA1, "MA1", colorYellow, styleLine );
Plot( MA2, "MA2", colorBrightGreen, styleLine );
Plot( MA3, "MA3", colorWhite, styleLine );
//Plot( X, "X", colorPink, styleLine );
//Plot(SAR(minacc,maxacc), "PSAR", colorYellow, styleDashed );
PlotShapes( shapeUpArrow*Buy, colorGreen, 0, L, -20 );//shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shapeDownArrow*Sell, colorRed, 0, H, -20 );//PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0);//,offset=-12``