Forum Replies Created
-
AuthorPosts
-
JulianCohenParticipant
Thanks Said so much…it’s 95% there now. I should be able to tweak the rest. Appreciate the help VERY much. I was getting a massive headache!
JulianCohenParticipantSo remove it from the looping completely?
JulianCohenParticipantI want the stop to stay in one place.
I will buy one tic over the top of the set up bar and create a stop loss 1 tic below the set up bar. That S/L will stay in place until hit or the C>SMA exit works.
That’s what I am trying to do…
JulianCohenParticipantTrent…It makes sense but it didn’t work haha…Thanks anyway. It’s given me another 1000 things to try
JulianCohenParticipantYou’re right…Appreciate it.
JulianCohenParticipantThanks Trent…doesn’t this code in the looping cover that occurrence?
if (LBIT[j]>1 AND LEx[j]) //Exit on SMA
{
Sell[j] = True;
SellPrice[j] = Max(Open[j],SMA[j-1]);
PriceAtBuy = 0;It appears to be working correctly at first glance but I got so hung up with trying to work out the initial stop I haven’t had a good look at that yet.
JulianCohenParticipantWith this code my trailing stop is always either 0 or 1 and I can’t figure out why. What painfully obvious thing am I missing?
Code://=================================================================================
//Entry and Exit Signals
//=================================================================================Cond1 = L < Ref(L,-1); Cond2 = BullDB > ClsSt;
Cond3 = H < SMA; Cond4 = C > SMA;
Cond5 = OptFilt AND IndexUp AND UniverseFilter AND HDBFilter; //All the optional filtersOnLastTwoBarsOfDelistedSecurity = BarIndex() >= (LastValue(BarIndex()) -1) AND !IsNull(GetFnData(“DelistingDate”));
OnSecondLastBarOfDelistedSecurity = BarIndex() == (LastValue(BarIndex()) -1) AND !IsNull(GetFnData(“DelistingDate”));BuySetUp = Cond1 AND Cond2 AND Cond3 AND Cond5;
Buy = Ref(BuySetUp,-1);
BuyStop = H + 0.01;
SellStop = L – 0.01;LE = Ref(BuySetUp,-1) AND H >=Ref(BuyStop,-1) AND NOT OnLastTwoBarsOfDelistedSecurity;// TRIGGER BAR Entry is all conditions fulfilled and above the BuyStop
LEPrice = Max(Open,Ref(BuyStop,-1)); //Entry PriceLEx = C > SMA; //Long Exit
LIS = Ref(BuySetUp,-1) AND L <=Ref(SellStop,-1) AND NOT OnLastTwoBarsOfDelistedSecurity; //Initial stop a tic below SetUpBar //-------------------------------------------------------------------------- //MCS code part 2 if(MCP) LE = LE && Random()*100>=MCP; // Identifier MUST match the Identifier in the trigger bar line above
//————————————————————————–//=================================================================================
//Looping
//=================================================================================
Buy = 0;
Sell = 0;
PriceAtBuy = 0;
LBIT = 0;
LStop = Null;
//=================================================================================
for (j = 1; j < BarCount; j++) { if (PriceAtBuy==0 AND LE[j]) { Buy[j] = True; PriceAtBuy = LEPrice[j]; BuyPrice[j] = LEPrice[j]; LStop[j] = LIS[j-1]; LStop[j-1] = LIS[j-1]; LBIT[j] = 1; if (LBIT[j]>1 AND L[j] <= LStop[j-1]) { Sell[j] = True; SellPrice[j] = LStop[j-1]; PriceAtBuy = 0; } } else if (PriceAtBuy > 0)
{
LBIT[j] = LBIT[j-1]+1;if (LBIT[j]>1)
{
LStop[j] = LStop[j-1];
}if (LBIT[j]>1 AND L[j] <= LStop[j-1]) { Sell[j] = True; SellPrice[j] = LStop[j-1]; PriceAtBuy = 0; } if (LBIT[j]>1 AND LEx[j]) //Exit on SMA
{
Sell[j] = True;
SellPrice[j] = Max(Open[j],SMA[j-1]);
PriceAtBuy = 0;
}
}
}JulianCohenParticipantOK thanks. I’m trying to write a system with an initial stop and an exit but I’m struggling with the looping. I’ll keep at it. Thanks for the help guys
JulianCohenParticipantYou have a very relevant point!
JulianCohenParticipantIgnore me…I’m an idiot!!! Which means of course I found it in the last place I chose to look, which should have been the first place I chose to look
JulianCohenParticipantWhy do you not trade the Rescources stocks?
JulianCohenParticipantThanks a lot Said and Nick. Perfect explanations
JulianCohenParticipantI’m a little confused over the difference between a trend following system and a momentum system. Would someone mind explaining please?
JulianCohenParticipantBuy the rumour, sell the fact
JulianCohenParticipantI subscribe to this blog which often has a good read or two in it
-
AuthorPosts