hello everyone, my code first creates a buy and sell signal and then i use ATR to determine a trailing Sl. But i also use a couple of other attributes to determine the exact Stop for my buy or sell . But when i write the code.. i dont see any buy signal, its only sell signal and m plot of SL line is always below the price. I am using FLIP to accomplish the automatic move of buy to sell stop line. But i guess its not used in right context.
// this is the smoothed line i have to determine the buy and entry signal.
Plot(rr," ",colorBlue,1);
Buy= (C > "blueline") AND Volume > MA (Volume,vol);
Sell= "blue line" >C AND Volume > MA ( Volume,vol);
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Short=Sell;
Cover=Buy;
period=100;
multiplier= Optimize("multiplier",9,4,10,1);
stoplevel=multiplier*ATR(period);
ApplyStop(stopTypeTrailing,stopModePoint,stoplevel,True,True);
// screenshot -1 is normal with buy and selll signals
// as soon as i introduce the below code all the buy signals go off the chart and i only see my blue line and sell signal ( attached is the chart ) - SCREENSHOT-2
intrade=Flip(buy,sell);
stopline=IIf(intrade,HighestSince(Buy,High)-stoplevel,LowestSince(Short,Low)-stoplevel );
shortSL=(Cross(H,stopline) AND Buy=False AND Sell =false AND intrade=false);
longSL= ( Cross(L,stopline) AND Buy=false AND Sell =False AND intrade= true );
SetChartOptions(0,chartShowDates);
Plot(C,"Close",colorLightGrey,styleCandle);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
/// this lines are not getting plotted correctly. PLease check the sscreenshot
Plot(stopline,"trailing SL ",colorRed);
PlotShapes(shortSL * shapeDigit1,colorRed,0,L,offset=-30);
PlotShapes(longSL* shapeDigit2,colorGreen,0,L,offset= -30);
``` 
I am not sure why this is happening ?
do i need to ?
1. change any part of the code?
2. Do some settings at database or system level for the FLIP to work?
PLease help