Page 1 of 4

Prior Day MidPoint Strategy

Posted: Thu Jun 29, 2006 8:54 pm
by jstockman
I need some help. I don't have a programmer background, but learning. I am trading 5 min ES and want to use the same concept that TRO uses but go long or short if current days price exceeds prior day's midpoint. This is ts code.


This does not generate any trades. Can't see error in logic.

I need help.

Here is my code

Code: Select all

{Takeoff of TRO Trillion Dollar Forex strategy. Goes long or short when the prior day mid point is broken. 
broken}

Input: iMaxDollarLoss(300), 
   iTarget(125),       
   Stime (0630),   
   ETime (1315),   
   MaxTradesPerDay(1);   

vars:  pMidpoint(0), MaxTrades (0);


Condition1 = EntriesToday (Date) < MaxTradesPerDay;  // limit max trades per day.
pMidpoint = (HighD (1) + LowD (1)) * .50;   //Previoue day midpoint

if currentbar > 1 and time = STime and Condition1 then begin
   If high >  pMidpoint then Buy next bar at market;    // enter buy at the previous midpoint
end;

if currentbar > 1 and time = STime and Condition1 then begin   
   If low = pMidpoint then SellShort next bar at market;   // enter sell at the previous day's midpoint
end;

SetStopPosition;

SetProfitTarget (iTarget);

SetStopLoss (iMaxDollarLoss);

SetExitOnClose;


[schild=6 fontcolor=000000 shadowcolor=C0C0C0 shieldshadow=1]I need help[/schild]

Posted: Thu Jun 29, 2006 10:06 pm
by blr121970
After taking just a cursory glance I would suggest you get rid of the

and time = STime

condition.

Time Start Deleted

Posted: Sat Jul 01, 2006 7:29 am
by jstockman
blr121970

I did as you suggested and I am now getting trades. I have posted code.


Code: Select all

{Takeoff of TRO Trillion Dollar Forex strategy. Goes long or short when the prior day mid point is broken. 
broken}

Input: iMaxDollarLoss(300),  // IN DOLLARS
   iTarget(125),         // IN DOLLARS
   MaxTradesPerDay(1);     // Limit Trades Per Day

vars:  pMidpoint(0), MaxTrades (0);


Condition1 = EntriesToday (Date) < MaxTradesPerDay;  // limit max trades per day.
pMidpoint = (HighD (1) + LowD (1)) * .50;   //Previoue day midpoint

if currentbar > 1 and Condition1 then begin
   If high >  pMidpoint then Buy next bar at market;    // enter buy at the previous midpoint
end;

if currentbar > 1 {and time = STime} and Condition1 then begin   
   If low = pMidpoint then SellShort next bar at market;   // enter sell at the previous day's midpoint
end;

SetStopPosition;

SetProfitTarget (iTarget);

SetStopLoss (iMaxDollarLoss);

SetExitOnClose;


I don't know how to show you performance reports. What I want to do is make a high percentage profitable and net at least 100 per day.

That is occuring but with no slippage or commission.

I am using ES 1 min. charts.

What type of slippage and commiss. do you use in your back tests.


Jimmyj

Posted: Wed Jul 05, 2006 12:42 am
by Ali Son
Jstockman,

Any lucky making that strat work with the appropriate commission/slippage? If so, what commission/slippage did you use? Best to use the most severe? (Check TS search feature forums for guidelines and pitfalls from some pro auomated traders like Nemo and Mathemagician.) Perhaps you're already having success.

Posted: Wed Jul 05, 2006 5:00 am
by JPT
On the ER2 you should use $10 per side per trade for commissions + slippage. What usually happens is that you get hit for one tick on one side if automated and not on the other.

I have found that for automated trading, 10 per side works great and in reality it very much tracks actual trading. Actually about 25% more conservative. Of course this is with only up to 7 contracts traded any one way with 14 contracts total on a switch.

Thnak=you

Posted: Thu Jul 06, 2006 2:32 pm
by jstockman
Thank-you for your help.

Learning how to program is like being a child again. You speak in fragments. ha ha !

Thank-you for all your help guys

Jimmyj

Slipage

Posted: Fri Jul 07, 2006 3:19 pm
by jstockman
Ali Son

I put in 10.00 per trade/contract. It killed me. Back to the drawing board.

Jimmyj

Posted: Fri Jul 07, 2006 11:56 pm
by JPT
Don't feel dicouraged. It happens to me all the time. That is why I never run a test, even when I start developing a strategy without 10 per side for slippage. If it works there, then it will work in real life. One other item. If you use % trailing stops you must use the inside bar testing check box. If you use a 5 min chart, you are best to use a 1 min granulation. I can take a great looking strategy and turn it to dust just by checking that box.

The theory is, TS in backtesting, only checks the open, high, low and close. In reality, the ticks don't come in that one preceise order, so sometimes you get the fill you want and in reality you would not get it. Very confusing. I also never do studies with out at least a 1min granularity for the back testing. Then you, at least have a chance.

Of course, if you write your own code for stop losses and trailing stops and only execute the stop at the open of the next bar, then you would not need to worry about this granularity.

Hope this helps

Posted: Sat Jul 08, 2006 6:33 pm
by jstockman
Thank-you for the advise. I really appreciate it.

Jimmyj


JPT wrote:Don't feel dicouraged. It happens to me all the time. That is why I never run a test, even when I start developing a strategy without 10 per side for slippage. If it works there, then it will work in real life. One other item. If you use % trailing stops you must use the inside bar testing check box. If you use a 5 min chart, you are best to use a 1 min granulation. I can take a great looking strategy and turn it to dust just by checking that box.

The theory is, TS in backtesting, only checks the open, high, low and close. In reality, the ticks don't come in that one preceise order, so sometimes you get the fill you want and in reality you would not get it. Very confusing. I also never do studies with out at least a 1min granularity for the back testing. Then you, at least have a chance.

Of course, if you write your own code for stop losses and trailing stops and only execute the stop at the open of the next bar, then you would not need to worry about this granularity.

Hope this helps

Posted: Sun Jul 09, 2006 11:06 am
by Ali Son
Yes, I found this Percentrailing stop is a BIG concern for Bacctesting with Look-Inside-The Bar Testing.

BUT JPT, so to clarify, it'sNOT only % tailing stops that one must use the look-inside-bar testing, RIGHT?? I am just asking. SO, ALL types of stops are apllicable unless they are custom designed stops that specify that it wants preceisely the open, high, low or close for backtesting?

And, if stops aren't used, just buy and sell orders, LIB should still be checked off, yes?

Also, to clarify once and for all, WHAT timeframes does Look-Inside-Bar Testing NOT a concern for; in other words, is this a concern equally for 1 iminute charts as it is for daily charts?

Finally, let's say one is doing walk-forward testing by papertrading the strat forward for one year, one still must still check the L-I-B testing?


Thanks in advance.
-OS