Hello,
How do I put a stop-loss( ex 0.5%) for long or short position.
Please see my comment within code.
Here is a code for long
CODE:
Please log in to see this code.
Here is a code for short
CODE:
Please log in to see this code.
Thanks,
Sofia
Size:
Color:
This is a wizard-generated code (as can be seen from the usage of GetTradingLoopStartBar(), .Contains, "Group1|"). Why don't you simply add a percentage stop loss in the wizard and convert to code again?
Size:
Color:
Hello,
I don't have that option as I am using Channel breakout to close position (under entries and exits)
and it doesn't have place to put %age stop-loss.
Thanks,
Sofia
Size:
Color:
That's a misconception. You're always able to drag the "Sell at Stop Loss" condition (from "Basic exits") and drop it near to your channel breakout/down exit.
Size:
Color:
Hello,
How do I close the floating active positions with this code?
Please see my comments below in the code
//here is part of my code
// The first trade, I am using certain math functions to define ratioup,maXo,ratiodown and maXu
// I initiate long and short based on these functions as defined below
if ( ratioup )
if ( maXo )
BuyAtClose( Bar );
if (ratiodown )
if (maXu)
ShortAtClose( Bar );
// Subsequent trades, I close the trade as below, but not all trades get closed as the closing criteria
// is not always met. I still have some active positions. This code below closes about 70% of my trades
if (IsLastPositionActive)
{
Position p = LastPosition;
if ( p.PositionType == PositionType.Long )
SellAtLimit(Bar + 1, p, Highest.Value(Bar, High, 13),"Exit at 13thbar");
else
CoverAtLimit(Bar + 1, p, Lowest.Value(Bar, Low, 13), "Exit at 13thbar");
}
///The code below is used to cover the remaining 25% of active positions based on another criteria
//as defined below, This closes rest 25% of my active positions, but I Still have
//few long and short positions active after this loop
for(int pos = ActivePositions.Count - 1; pos >= 0; pos--)
{
Position p = ActivePositions[pos];
if ( p.PositionType == PositionType.Long )
if (ratio[Bar] < ratio[Bar-1])
if (Close[Bar] > Close [p.EntryBar] )
ExitAtMarket( Bar+1, p, "Timed Long" );
///When the above condition doesn't hold true, I want to close floating open position on next
//new short position
if ( p.PositionType == PositionType.Short )
if (ratio[Bar] > ratio[Bar-1])
if (Close[Bar] < Close [p.EntryBar] )
ExitAtMarket( Bar+1, p, "Timed Short" );
/// When the above condition doesn't hold true, I want to close floating short position on next /
//new long position
}
//I don't want to use stops to close these, as I get better results when I close these on next new open
//position.
//I am using filtering mechanism like sifting through trades. As the randomness of market goes up,
//more filtering is needed to remove noise.
//The last 5% of the trades that I am having difficulty closing, turn up to be a major direction
//changing event. That's why I want to close the last 5% based on my reasoning above.
Any help is appreciated.
Thanks,
Sofia
Size:
Color:
Not sure what the question is about, you're asking for an exit idea?
P.S. Ideally, your AtMarket orders should precede the AtLimit group of exits (more in the Guides).
Size:
Color: