How to move your stop with scale in? - or set different sell prices

I wrote the code below and the issue I am having is that because I didn't know how to adjust 'apply stop' when pyramiding in I added into my for loop as a sell signal, however I want to sell as soon as it hit's stop signal rather then at close.

So I was hoping someone can help me with how to move up my stop signal when I scale in if I use 'applystop()'?
and/or how to set the sell signals, only for when it 'hits my stop' to, the stop level rather then close?

I have included code below (I tried to cut it down to relevant parts so hopefully make sense, and hopefully shouldn't need to go through with explanation)

Thanks for any help!


//initialise vaiables 

//system buy and sell logic

for( i = 20; i < barcount; i++ ) //loop through all bars to check when signals occur 
	if(bx==0) //if there has been a sell signal since last buy
		//if buy logic { b1=1 bx=1 sx=0 }
	else If(sx==0) //if there has been a buy signal since last sell
		if(L[i]<(b2-stop[i])) //stop level 2N below entry price
			s1[i]=1; //need to reset this so stop is at 'b2-stop[i]' not close price
			//if sell logic { s1=1 sx=1 bx=0 }
				if((C[i]>b2+N[i]/2)AND(count<3)) //pirimid into position if close is 1/2 N above previous buy in, a maximum of 3 times
				ScaleIn[i]=1; //scale into trade (add an additional unit)
				b2=b2+N[i]/2; //moves current 'buy in'(and thus stop) up 1/2 N

Buy=IIf(b1 , 1, IIf(ScaleIn, sigScaleIn, 0));

///what price to buy

//positon size
EPS1 = Unit; // Size for first entry
EPS2 = Unit; // Size for 'scalein' entries
PosSize = (b1 * EPS1) + (scalein * EPS2); //set position size of b1 signals and scalein signals
SetPositionSize(PosSize, spsShares); //set position size of all buy signals


Read here

It's all there.

1 Like

thanks, did have a look around but missed this page

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.