Home › Forums › Trading System Mentor Course Community › AmiBroker Coding and AFL › Profitable closes
- This topic is empty.
-
AuthorPosts
-
October 23, 2016 at 4:17 am #101580LeeDanelloParticipant
Hi, Just testing profitable closes on my MR system. Not sure which lines of code are correct. They give me different backtest results. Anyone know why?
Code:if( LBIT[j] > 1 and (C[j-1] > LPriceAtBuy) AND (C[j-2] > LPriceAtBuy)){
Sell[j] = True;
SellPrice[j] = LExPrice[j];
LPriceAtBuy = 0;
}or
Code:if( LBIT[j] > 1 and (C[j-1] AND C[j-2]) > LPriceAtBuy){
Sell[j] = True;
SellPrice[j] = LExPrice[j];
LPriceAtBuy = 0;
}I even tried this
Code:Profitable_closes = C>Ref(C,-1);if( LBIT[j] > 1 and (Profitable_closes[j-1] > LPriceAtBuy))
{
Sell[j] = True;
SellPrice[j] = LExPrice[j];
LPriceAtBuy = 0;
}This gave different results again. Bit puzzled.
October 23, 2016 at 12:52 pm #105621SaidBitarMemberMaurice Petterlin wrote:Hi, Just testing profitable closes on my MR system. Not sure which lines of code are correct. They give me different backtest results. Anyone know why?Code:if( LBIT[j] > 1 and (C[j-1] > LPriceAtBuy) AND (C[j-2] > LPriceAtBuy)){
Sell[j] = True;
SellPrice[j] = LExPrice[j];
LPriceAtBuy = 0;
}or
Code:if( LBIT[j] > 1 and (C[j-1] AND C[j-2]) > LPriceAtBuy){
Sell[j] = True;
SellPrice[j] = LExPrice[j];
LPriceAtBuy = 0;
}I even tried this
Code:Profitable_closes = C>Ref(C,-1);if( LBIT[j] > 1 and (Profitable_closes[j-1] > LPriceAtBuy))
{
Sell[j] = True;
SellPrice[j] = LExPrice[j];
LPriceAtBuy = 0;
}This gave different results again. Bit puzzled.
three different results because they are three different things
Code:if( LBIT[j] > 1 and (C[j-1] > LPriceAtBuy) AND (C[j-2] > LPriceAtBuy)){
Sell[j] = True;
SellPrice[j] = LExPrice[j];
LPriceAtBuy = 0;
}this one means yesterday’s close is higher than the price you bought at and the day before yesterday close is also higher than the the price you bought at if these conditions are met then you are selling at the exit price.
Code:if( LBIT[j] > 1 and (C[j-1] AND C[j-2]) > LPriceAtBuy){
Sell[j] = True;
SellPrice[j] = LExPrice[j];
LPriceAtBuy = 0;
}this is wrong syntax the correct syntax is (C[j-1] > LPriceAtBuy) AND (C[j-2] >LPriceAtBuy) which is the first scenario
Code:Profitable_closes = C>Ref(C,-1);if( LBIT[j] > 1 and (Profitable_closes[j-1] > LPriceAtBuy))
{
Sell[j] = True;
SellPrice[j] = LExPrice[j];
LPriceAtBuy = 0;
}this one is also wrong since profitable_closes will return true (1) or false (0) all the time and you are comparing it to the price at buy.
here is how it should be
Code:Profitable_closes = C>Ref(C,-1);if( LBIT[j] > 1 and Profitable_closes[j-1] )
{
Sell[j] = True;
SellPrice[j] = LExPrice[j];
LPriceAtBuy = 0;
}October 23, 2016 at 1:28 pm #105624LeeDanelloParticipantSaid Bitar wrote:this one is also wrong since profitable_closes will return true (1) or false (0) all the time and you are comparing it to the price at buy.here is how it should be
Code:Profitable_closes = C>Ref(C,-1);if( LBIT[j] > 1 and Profitable_closes[j-1] )
{
Sell[j] = True;
SellPrice[j] = LExPrice[j];
LPriceAtBuy = 0;
}Thanks Said, good explanation but the last peice of code doesn’t compare it to the entry price. It only says sell if the close is higher than the previous close. Not necessarily profitable.
October 23, 2016 at 1:52 pm #105626SaidBitarMemberso you want to see only if you have profit?
in this caseif( LBIT[j] > 1 and C[j-1] > LPriceAtBuy)
{
Sell[j] = True;
SellPrice[j] = LExPrice[j];
LPriceAtBuy = 0;
}but what you will do if the stock never came above your buy price
October 23, 2016 at 2:08 pm #105627LeeDanelloParticipantI was just thinking of one scenario for taking a profit.
I suppose if I had the following
Code:Profitable_closes = C>Ref(C,-1) and Ref(C,-1)> Ref(C,-2);I could use
Code:if( LBIT[j] > 1 and Profitable_closes[j-1] and C[j-1] > LPriceAtBuy ){
Sell[j] = True;
SellPrice[j] = LExPrice[j];
LPriceAtBuy = 0;
}October 24, 2016 at 3:31 pm #105628SaidBitarMemberMaurice Petterlin wrote:I was just thinking of one scenario for taking a profit.I suppose if I had the following
Code:Profitable_closes = C>Ref(C,-1) and Ref(C,-1)> Ref(C,-2);I could use
Code:if( LBIT[j] > 1 and Profitable_closes[j-1] and C[j-1] > LPriceAtBuy ){
Sell[j] = True;
SellPrice[j] = LExPrice[j];
LPriceAtBuy = 0;
}I understand but still you need another exit in case your conditions never met mainly the one that is higher than the price at buy, maybe sell after x days in case the sell conditions are not met.
i do not have any examples to show what i am talking about but imagine the following you bought one stock at 10$ bad luck came and then it went to 5$ in this case you will be holding the stock till you have two higher closes and the last one is higher than 10$ which maybe few years.
with your condition you are targeting 100% success rate since you are only selling if there is a profit. maybe 100% it a bit exaggerated since it can still open low but you got where i am heading
October 25, 2016 at 2:40 am #105632LeeDanelloParticipantThanks Said I do have other exits. I have a timed exit and an exit at MA. Just investigating other scenarios. Trying to extract more out of the system.
-
AuthorPosts
- You must be logged in to reply to this topic.