Getting "Floor Trader Pivot" to work in WL5
Author: Mac_Trader
Creation Date: 12/12/2008 12:40 PM
profile picture

Mac_Trader

#1
I translated "Floor Trader Pivot" to 5.1 and it doesn't work.(works fine in 4.5) I get 4 error messages "Error CS0103 the name 'IntraDayFromDaily' does not exist in the current context". Can anyone help me with this as I know very little about writting code. Thanks in advance

CODE:
Please log in to see this code.
profile picture

Cone

#2
I can't help with WSTL, but here's a manual translation that you can copy and paste -

CODE:
Please log in to see this code.
profile picture

Mac_Trader

#3
Thanks for the help Cone!!..I'll work on it this weekend and let you know the results. I probably should have included the original 4.5 code in my original post..so here it is



t NUMTICKS = 2; // Number of ticks past the pivot
{ Floor Trader Pivots }
consvar
Bar, cnt, StartBar, p,
hPivot, hDayHigh, hDayClose, hDayLow,
hS1, hR1, hR2, hS2: integer;
var
boVal: float;

SetScaleDaily;
hPivot := IntraDayFromDaily( #AverageC );
hDayHigh := IntraDayFromDaily( #High );
hDayClose := IntraDayFromDaily( #Close );
hDayLow := IntraDayFromDaily( #Low );
hR1 := SubtractSeries( MultiplySeriesValue( hPivot, 2 ), hDayLow );
hS1 := SubtractSeries( MultiplySeriesValue( hPivot, 2 ), hDayHigh );
hR2 := AddSeries( SubtractSeries( hPivot, hS1 ), hR1 );
hS2 := SubtractSeries( hPivot, SubtractSeries( hR1, hS1 ) );
RestorePrimarySeries;

HideVolume;
PlotSeriesLabel( hR2, 0, #Maroon, #Dotted, 'R2' );
PlotSeriesLabel( hR1, 0, #Olive, #Thin, 'R1' );
PlotSeriesLabel( hPivot, 0, #Blue, #Thin, 'Pivot' );
PlotSeriesLabel( hS1, 0, #Fuchsia, #Dotted, 'S1' );
PlotSeriesLabel( hS2, 0, #Red, #Thin, 'S2' );

{ Find the StartBar of the 2nd day }
for Bar := 0 to BarCount - 1 do
begin
if BarNum( Bar ) = 0 then
Inc(cnt);
if cnt = 2 then
begin
StartBar := Bar;
break;
end;
end;

{ Breakout value to be added/subtracted from resistance/support }
boVal := GetTick * NUMTICKS;

{ Trading loop }
for Bar := StartBar to BarCount - 1 do
begin
{ Don't trade on the first 2 bars of the day, 0 and 1 }
if BarNum( Bar ) < 2 then
continue;

if LastPositionActive then
begin { ---- Exit Rules ---- }
p := LastPosition;
if PositionLong( p ) then
begin
if not SellAtStop( Bar + 1, @hS1[Bar], p, 'StopLoss' ) then
SellAtLimit( Bar + 1, @hR2[Bar], p, 'PftTgt' );
end
else
if not CoverAtStop( Bar + 1, @hR1[Bar], p, 'StopLoss' ) then
CoverAtLimit( Bar + 1, @hS2[Bar], p, 'PftTgt' );
end
else { ---- Entry Rules ---- }
begin
if not LastBar( Bar ) then
begin
var NewPositionEntered: boolean = false;
if PriceClose( Bar ) < @hR1[Bar] then
NewPositionEntered := BuyAtStop( Bar + 1, @hR1[Bar] + boVal, '' );
if not NewPositionEntered then
if PriceClose( Bar ) > @hS1[Bar] then
ShortAtStop( Bar + 1, @hS1[Bar] - boVal, '' );
end;
end;
end;
profile picture

Mac_Trader

#4
Cone.when I copy paste your code it pastes everything on the first line..a very long first line. probably something I'm doing wrong..Here is the 4.5 code again only inside CODE this time

CODE:
Please log in to see this code.
profile picture

Eugene

#5
QUOTE:
Cone.when I copy paste your code it pastes everything on the first line..a very long first line. probably something I'm doing wrong..

You're a IE7 user. This forum has a known bug when copying/pasting directly from IE7.

Two workarounds:

1. Use Firefox (preferred, as it makes your browsing more secure).
2. Copy, paste in Wordpad, copy from Wordpad, paste in WLD.
profile picture

Mac_Trader

#6
Thanks Eugene guess it's easy to tell I'm new around here :-)).. I'm off to Firefox
profile picture

Mac_Trader

#7
Firefox worked a lot better. Thanks again

I just ran the 4.5 and 5.1 systems on the same equity and could not get every trade to correlate. One difference was that the 5.1 version would trade on the first 2 bars even though it is not supposed to.
I'll work on that tomorrow. Enough progress for today....
profile picture

Cone

#8
It's impossible for it to trade on the first or second bar of the day because the following snippet skips trade processing on those bars -
CODE:
Please log in to see this code.

Maybe you still didn't copy the code correctly.
profile picture

Mac_Trader

#9
I have just recopied the code, updated and reran the 2 systems on a 1 month,10 minute chart, of EEV and still get differing results. I am going to include the trades. You can see that 4.5 has an open long and 5.1 has no open trades. Also 5.1 entered a long trade on 12/9 at 9:40, the first tick of the day. I would be glad to post the charts, but I haven't figured out how to do that and haven't found any FAQ.

Version 4.5 trades for EEV 10 Min from 11/13 until 12/14

Position Symbol Shares Entry Date Entry Price Exit Date Exit Price % Change Net Profit Bars Held Profit/Bar Entry Signal Exit Signal Cum Profit MAE % MFE %
Long EEV 108 11/17/2008 10:20:00 AM 92.53 11/18/2008 1:50:00 PM 100.74 8.87 886.68 61 14.54 PftTgt 886.68 -7.06 8.87
Long EEV 111 11/18/2008 4:00:00 PM 97.35 11/19/2008 3:40:00 PM 108.49 11.45 1,237.28 38 32.56 PftTgt 2,123.96 -1.45 11.45
Long EEV 104 11/20/2008 11:00:00 AM 116.52 11/20/2008 3:20:00 PM 121.80 4.54 549.81 26 21.15 PftTgt 2,673.77 -7.18 4.54
Short EEV 111 11/21/2008 10:40:00 AM 113.48 11/21/2008 3:40:00 PM 100.89 11.09 1,397.49 30 46.58 PftTgt 4,071.27 -4.42 11.09
Short EEV 165 11/24/2008 10:10:00 AM 85.08 11/26/2008 3:00:00 PM 72.17 15.18 2,130.48 109 19.55 PftTgt 6,201.75 -1.34 15.18
Short EEV 202 12/2/2008 10:10:00 AM 80.20 12/3/2008 9:40:00 AM 81.83 -2.04 -329.93 37 -8.92 StopLoss 5,871.81 -3.37 6.34
Long EEV 196 12/3/2008 10:10:00 AM 80.93 12/5/2008 2:50:00 PM 75.13 -7.17 -1,137.51 108 -10.53 StopLoss 4,734.31 -9.49 2.87
Short EEV 196 12/5/2008 3:20:00 PM 75.13 12/5/2008 4:00:00 PM 70.81 5.74 845.41 4 211.35 PftTgt 5,579.72 0.00 5.74
Long EEV 243 12/9/2008 2:40:00 PM 63.95 12/10/2008 9:40:00 AM 59.98 -6.21 -965.52 10 -96.55 StopLoss 4,614.20 -6.21 0.42
Short EEV 269 12/11/2008 10:30:00 AM 54.18 12/11/2008 3:40:00 PM 58.76 -8.45 -1,232.02 31 -39.74 StopLoss 3,382.18 -8.45 1.85
Long EEV 227 12/11/2008 3:50:00 PM 58.76 Open Open -3.06 -408.60 43 -9.50 2,973.58 -5.19 5.48




Version 5.1 trades for EEV 10 Min from 11/13 until 12/14

Position Symbol Quantity Entry Date Entry Price Exit Date Exit Price Profit % Profit $ Bars Held Profit per Bar Entry Name Exit Name MAE % MFE %
Long EEV 102 11/18/2008 4:00 PM 97.17 11/19/2008 3:40 PM 108.65 11.65 $1,154.96 38 $30.39 PftTgt -0.87 11.73
Long EEV 95 11/20/2008 12:10 PM 117.07 11/20/2008 3:20 PM 122.07 4.13 $459.00 20 $22.95 PftTgt -7.69 4.20
Short EEV 102 11/21/2008 9:40 AM 104.42 11/21/2008 3:40 PM 100.89 3.23 $344.06 37 $9.30 PftTgt -13.56 3.31
Short EEV 140 11/24/2008 10:10 AM 85.06 11/26/2008 3:00 PM 72.18 15.01 $1,787.20 108 $16.55 PftTgt -1.43 15.08
Short EEV 171 12/2/2008 9:40 AM 79.33 12/3/2008 9:40 AM 81.83 -3.27 ($443.50) 40 ($11.09) StopLoss -4.56 5.26
Long EEV 167 12/4/2008 3:20 PM 79.51 12/5/2008 2:50 PM 75.36 -5.34 ($709.05) 37 ($19.16) StopLoss -5.28 4.64
Short EEV 188 12/8/2008 9:40 AM 64.51 12/8/2008 10:40 AM 62.58 2.86 $346.84 7 $49.55 PftTgt -0.51 2.93
Long EEV 200 12/9/2008 9:40 AM 64.44 12/10/2008 9:40 AM 59.98 -7.05 ($908.00) 40 ($22.70) StopLoss -6.98 1.07
Short EEV 222 12/11/2008 10:30 AM 54.13 12/11/2008 3:40 PM 58.74 -8.65 ($1,039.42) 32 ($32.48) StopLoss -8.58 1.69

profile picture

Cone

#10
The problem was from not blocking the order from the close of the previous day. I added this condition to entry logic in the code above -
CODE:
Please log in to see this code.
profile picture

Mac_Trader

#11
Thanks again Cone I appreciate your help.
I copied and tried the revised system this morning. real time.
Now the support and resistance levels adjust with each new bar instead of just on the last bar of the day. I didn't do any more analysis after that happened.
Looks like I'll stick w/4.5
profile picture

Cone

#12
Do you always give up so easily? Try it again.
profile picture

Mac_Trader

#13
Thanks again Cone
You cured that problem. Support and resistance now steady through the day.

Next:
4.5 adjusts the S/R to the next days locations at the 4:00 bar.
5.1 waits until the 9:40 AM bar and it skews the trades. Even though the program is not supposed to trade the first two bars.

And I haven't given up on 5.1 but I don't have the confidence in it to use for trading.

profile picture

Cone

#14
This isn't really a "4.5 vs. 5.1". It's just a matter of getting the script translated to C# such that it's equivalent to "WealthScript 2", and I think we've got it now.

One difference that you'll see in 5.1 is that it automatically filters out data after the 4:00pm bar that's returned by the Fidelity history feed. Those "mini bars" after 4pm were not expected by 4.5, so they got through, but shouldn't be there in the first place.

With 4.5's Synchronization to Option #1, you probably see the change occurring on the 4:10 bar, and then S/R is held constant through the 9:40 bar. But if you change 4.5's Synchronization to Option #3 (F12), you'll see that 4.5 synch's to that last 4:10 bar and transitions on the 9:40 too.

The "problem" is that those 4:10 ticks are not there in 5.1. That's the difference.
profile picture

Mac_Trader

#15
Still have a failure to replicate trades..In the original the S/R lines adjust at exactly 4:00 when the bar is complete, I don't know if this causes the difference. Is there a way to post copies of the charts here?

Original/EEV 10 min 400bars

Position Symbol Shares Entry Date Entry Price Exit Date Exit Price % Change Net Profit Bars Held Profit/Bar Entry Signal Exit Signal Cum Profit MAE % MFE %
Long EEV 125 12/4/2008 3:20:00 PM 79.48 12/5/2008 2:50:00 PM 75.37 -5.18 -514.58 36 -14.29 StopLoss -514.58 -5.18 4.74
Short EEV 175 12/11/2008 10:30:00 AM 54.15 12/11/2008 3:40:00 PM 58.73 -8.46 -801.50 31 -25.85 StopLoss -1,316.08 -8.46 1.80
Long EEV 147 12/11/2008 3:50:00 PM 58.73 Open Open -1.23 -106.31 80 -1.33 -1,422.40 -5.15 5.53


C#

Position Symbol Quantity Entry Date Entry Price Exit Date Exit Price Profit % Profit $ Bars Held Profit per Bar Entry Name Exit Name MAE % MFE %
Long EEV 125 12/4/2008 3:20 PM 79.51 12/5/2008 2:50 PM 75.36 -5.38 ($534.75) 37 ($14.45) StopLoss -5.30 4.62
Short EEV 174 12/11/2008 10:30 AM 54.13 12/11/2008 3:40 PM 58.74 -8.69 ($818.14) 32 ($25.57) StopLoss -8.60 1.67
Long EEV 147 12/11/2008 3:50 PM 58.76 12/12/2008 9:40 AM 61.98 5.29 $457.34 3 $152.45 PftTgt -2.51 5.39

profile picture

Cone

#16
Those trades are approximately the same, but those 4:10 bars (post market trades) in Version 4.5 influence the Pivot results slightly. Since 5.1 filters out those post-market trades, the pivot calculations won't be precisely them. Ok?
profile picture

Mac_Trader

#17
Pivot is one of my primary tools. This will work fine. The lines are more important to me than the system trades. Thanks again for your help..Mac
profile picture

Mac_Trader

#18
Hi Guys..I'm back with the pivot again. I'm running 5.4.20.0 Error msgs I don't understand. Would appreciate any help.

CODE:
Please log in to see this code.



Thanks
Mac

profile picture

Cone

#19
I'm afraid it's a problem with synchronization that was broken when fixing other synch problems. This one is a different twist, however, so I'd appreciate it if you would create a support ticket for this one.

If you wish to downgrade to 5.3, please contact Fidelity phone support. Sorry for the inconvenience.
profile picture

Mac_Trader

#20
Support ticket created. I quoted you. LOL
Thanks Cone
Mac
profile picture

Cone

#21
Hi Mac,
I've got a work-around on this one for you. In a sense, it might actually be more efficient.

CODE:
Please log in to see this code.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).