aditya after reading both your posts i tried to combine both the posts .. i have arrived at some set of codes however they are not working ...for some reason my i am unable to send you a pm it is blocked or something.. i have written to the admin but till then here is what i have..
//i have taken exmaple of this simple ema cross over signal system.
//lets Say Buy is at EMA Cross over AND the Sell is at the condidionts mentioned below...its just that this is NOT generating any trades at all
//i am trying to generate multiple sell signals for one buy signal.. ie multiple ways in which the position can be exited..and in multiple portions
//what i am trying here is to exit 50% at points enough to make my position breakeven ..even if after first exit the rest hits stoploss
//second i want the rest 50% to run free till the trend is over.. in this case i am judging the trend by ema cross over..
//third thing if the price goes below stop loss before even achieving the first target then book loss on whole position
//can you please correct this and point the mistakes so that i know where i was wrong...i should say where all i was wrong ;-)
SetPositionSize(100,4);//to analyse the system on trading just 2 lots..
Buy= Cross(Close,EMA(Close,34));
Sell=0;
lastBuyPrice = ValueWhen(Buy,BuyPrice,1);
brokeragePoints=5;
stopLossInPoints = abs(LastBuyPrice - Ref(Low,-BarsSince(Buy))); //as i want the stop loss to be the low of the bar i bought at.
FirstExitPrice = LastBuyPrice + stopLossInPoints + brokeragePoints;//earning sl + brokerage will make rest 50% position free
doScaleOut1 = Buy==1 AND Cross(Close,FirstExitPrice);//first 50% to be sold at this price
doscaleout2=Buy==1 AND Cross(EMA(Close,34),Close); // second 50% to be sold at this price..this is to allow the trade to capture the whole move...in this case let assume the second exit is at ema,price cross over
Sell = IIf( doScaleOut1 OR doscaleout2, sigScaleOut, Sell);
PosSizeScaleOut = 50;
SetPositionSize(IIf( Sell == sigScaleOut , PosSizeScaleOut, 100 ), spsPercentOfPosition); //i have replaces flase with 100 thinking that the position should be exited 100% in event of stoploss hit
ApplyStop(stopTypeLoss, stopModePoint, stopLossInPoints); //this is in case the stop loss hits..
thanks for the help and guidance ..